环境:hpux,oracle 9.1.2.0 ,cc
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
EXEC SQL include sqlca;
EXEC ORACLE OPTION (RELEASE_CURSOR = YES);
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20];
VARCHAR password[20];
EXEC SQL END DECLARE SECTION;
void sql_error()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\n Oracle error detected:\n");
printf("\n%.70s\n",sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
main()
{
strcpy(username.arr,"gdnum_true");
strcpy(password.arr,"gdnumtrue_10");
username.len=strlen(username.arr);
password.len=strlen(password.arr);
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("sqlca.sqlcode=%d;\n",sqlca.sqlcode);
printf("login user=%s",username.arr);
exit(0);
}
proc pro1.pc
cc -o pro1 pro1.c -L $ORACLE_HOME/lib32 -lclntsh
不作文字说明,只作例程记载
posted on 2007-09-17 14:12
有猫相伴的日子 阅读(490)
评论(0) 编辑 收藏 所属分类:
unix/windows C 程序设计