test.c

来自「使用Pro*C封装的访问数据库的源码」· C语言 代码 · 共 42 行

C
42
字号
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdlib.h>
#include <ctype.h>
#include "OraDBUtil.h"

main(argc, argv)
int argc;
char *argv[];
{
 DataSet ds;
 char errMsg[2048];
 if ( argc<2 )
 {
    printf("Usage OraDBUtil SQL \n");
    exit(0);
 }
 /*执行查询*/
 if( strncmp("SELECT", argv[1], 6 )==0 )
 {
   if( execQuery(argv[1], &ds, errMsg)!= 0 )
   {
     printf("err:%s", errMsg );
     exit(1);
   }
   /*打印查询结果*/  
   printDataSet(ds);
   /*根据列名查找 列数*/
   printf("the col: %s 's colNo is: %d\n","menu_title", getColNoByName(ds, "menu_title" ) );
   /*根据行号,列名查找值*/
   printf("the rowNo: %d colName: %s 's value is: %s\n", 0,"menu_title", elementAt(ds, 0, "menu_title" ) );
   /*设置某一单元的值*/
   setElementAt(ds, 0, 6, "WISEKING");
   /*根据行号,列名查找值*/
   printf("after set, the rowNo: %d colNo: %d 's value is: %s\n", 0, 6 , ds.content[0][6] );
   
   /*释放结果集*/
   freeDataSet(ds);
 }else
  execUpdate(argv[1]); /*执行变更,包括INSERT,UPDATE,DELETE*/
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?