分类: Oracle
2011-03-25 11:17:29
int connectDB(char *user, char *passwd)
{
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR uid[10]; /* username */
VARCHAR pwd[10]; /* password */
EXEC SQL END DECLARE SECTION;
strcpy((char *)uid.arr, user);
uid.len = (short) strlen((char *)uid.arr);
strcpy((char *)pwd.arr, passwd);
pwd.len = (short) strlen((char *)pwd.arr);
EXEC SQL WHENEVER SQLERROR DO errrpt();
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;
return 0;
}
int closeDB(void)
{
EXEC SQL rollback work release;
if(sqlca.sqlcode<0)
{
printf("close db error code:%d ",sqlca.sqlcode);
}
return 0;
}