Chinaunix首页 | 论坛 | 博客
  • 博客访问: 49245
  • 博文数量: 25
  • 博客积分: 960
  • 博客等级: 准尉
  • 技术积分: 280
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-14 12:39
文章分类
文章存档

2011年(1)

2009年(20)

2008年(4)

我的朋友

分类: DB2/Informix

2009-05-07 15:02:04

/*******************************************************************
*File Name :select_info_tb.ec
*This is select  basic person informaion from the basic_info_tb
*The database name :

*The table name :basic_info_tb 
*Time :2009.5.7
*Author :zhou le xiang
*Compiler command :esql -o select_info_tb select_info_tb.ec
*******************************************************************/
//include head
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sqlca.h"
/*
//define head
exec sql begin declare section;
 int id;//use index keyword
 char name[20];
 int age;
 char sex[8];
 char tel[12];
 char e_mail[30];
 char addr[60]; 
exec sql end declare section;
*/
//main body
int main()
{
 exec sql begin declare section;
  int id;
  char name[20];
  int age;
  char sex[8];
  char tel[12];
  char e_mail[20];
  char addr[60];
 exec sql end declare section;
 
 printf("Do you want select data into the basic_info_tb  ?  0 ----no or 1 -----yes\n");
 exec sql database zlx;
 if(sqlca.sqlcode)
  {
   printf("connect the database error[%d]\n",sqlca.sqlcode);
   exit(1);
  }
  
  //select sql
 exec sql select * into :id,:name,:age,:sex,:tel,:e_mail,:addr from zlxtb where id=123456;
 if(sqlca.sqlcode)
  {
   printf("select data into table error[%d]\n",sqlca.sqlcode);
   exit(1);
  }
  printf("-------------------------------------------\n");
  printf("   your id:%d\n",id);
  printf("   your name:%s\n",name);
  printf("   your age:%d\n",age);
  printf("   your sex:%s\n",sex);
  printf("   your tel:%s\n",tel);
  printf("   your e_mail:%s\n",e_mail);
  printf("   your addr:%s\n",addr);
  printf("------------------------------------------\n\n");
 
  printf("Congratulations ! you select data into table sccess!\n");
  exec sql commit;
 return 0;
}
 
阅读(659) | 评论(0) | 转发(0) |
0

上一篇:esql insert

下一篇:esql update

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