一个最简单的pro*c程序

一个最简单的pro*c程序
环境: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
不作文字说明,只作例程记载

你可能感兴趣的:(一个最简单的pro*c程序)