- 论坛徽章:
- 0
|
小弟用c写的删除数据库程序,为什么执行后,我查询数据库,却显示没有删除掉呢??而且显示删除记录也总是那么多,请高人指点啊
是不是我的sql语句用错了?
#include < sqlca.h >; //声明SQL通讯区
#include <stdlib.h>;
#include < string.h >;
#include<stdio.h>;
EXEC SQL INCLUDE sqlca;
void connect();
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20],password[20],dbname[20];
char f_no[20],company[20],date[20],person[20],name[20],balance[20],totalbalance[20],allowance[20],copay[20],popay[20],pay[20];
char cont;
int count;
EXEC SQL END DECLARE SECTION;
void main()
{
connect();
if(sqlca.sqlcode==0)
printf("连接成功\n" ;
else
printf("%.*s\n",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
for( ; ; )
{
printf("请输入单位帐号(13):" ;
gets(company);
printf("请输入个人帐号( :" ;
gets(person);
EXEC SQL DELETE FROM t_hf_hosingaccfund_tmp
WHERE F_CORPORATIONNO=:company AND F_HOSINGACCFUNDNO=:person;
printf("继续吗?(y/n)" ;
scanf("%c",&cont);
fflush(stdin);
if(cont=='n'||cont=='N')
break;
}
EXEC SQL SELECT COUNT(*) INTO :count FROM t_hf_hosingaccfund_tmp;
printf("\n共删除%d条记录\n",count);
}
void connect()
{
strcpy((char *)username.arr,"pboradb" ;
username.len = strlen((char *)username.arr);
strcpy((char *)password.arr,"pboradb" ;
password.len = strlen((char *)password.arr);
strcpy((char *)dbname.arr,"abcd" ;
dbname.len = strlen((char *)dbname.arr);
EXEC SQL CONNECT :username IDENTIFIED BY :password USING:dbname;
} |
|