Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1613428
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类:

2012-07-03 14:12:15

原文地址:我的考查esql 作者:乐乐elephant

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sqlca.h"
exec sql begin declare section;
 char sfzbh[5];
 char chsfzbh[5];
 char tjrqz[15];
 char chtjrqz[15];
 char cxdmz[2];
 char sfdmz[2];
exec sql end declare section;

int test_insert()
{
 printf("please input your sfzbh:");
 scanf("%s", sfzbh);
 printf("please input your tjrqz:");
 scanf("%s", tjrqz);
 printf("please input your cxdmz:");
 scanf("%s", cxdmz);
        printf("please input your sfdmz:");
 scanf("%s", sfdmz);
 exec sql insert into test values(:sfzbh,:tjrqz,:cxdmz,:sfdmz);
 
 if(sqlca.sqlcode)
 {
  printf("insert data into table error[%d]\n",sqlca.sqlcode);
  exit(1);
 }
 return 0;
}
int test_select()
{
 printf("please input your sfzbh:");
 scanf("%s", chsfzbh);
 exec sql select * into :sfzbh,:tjrqz,:cxdmz,:sfdmz from test where sfzbh=:chsfzbh;
 if(sqlca.sqlcode)
  {
   printf("select from test error[%d]\n",sqlca.sqlcode);
   exit(0);
  }
 printf("SFZBH=%s\n",sfzbh);
 printf("TJRQZ=%s\n",tjrqz);
 printf("CXDMZ=%s\n",cxdmz);
 printf("SFDMZ=%s\n",sfdmz);
 return 0;
}
int test_update()
{
 printf("please input your sfzbh:");
 scanf("%s", chsfzbh);
 printf("please input your tjrqz:");
 scanf("%s", chtjrqz);
 exec sql update test set tjrqz=:chtjrqz where sfzbh=:chsfzbh;
 if(sqlca.sqlcode)
 {
  printf("update error[%d]\n",sqlca.sqlcode);
  exit(0);
 }
 return 0;
 
}
int main(int argc,char *argv[])
{
 exec sql begin declare section;
  char sfzbh[4];
  char tjrqz[15];
  char cxdmz[1];
  char sfdmz[1];
 exec sql end declare section; 
 fflush(stdout);
 exec sql database zlx;
 if(sqlca.sqlcode)
 {
  printf("connect the database error[%d]\n",sqlca.sqlcode);
  exit(1);
 }

 test_insert();
 test_select();
 test_update();
 test_select();
 exec sql close database;
 return 0;
}
阅读(672) | 评论(0) | 转发(0) |
0

上一篇:ESQL程序

下一篇:ETL介绍

给主人留下些什么吧!~~