> > php로 짠 프로그램을 c로 컨버트한 후에 실행을 했더니......
> >
> > 다음과 같이 에러가 나네여~~~~~
> >
> > NOTICE: (transaction aborted): all queries ignored until end of tra
> ns
> > action block
>
>
> 글쎄. 소스를 못보니 정답은 못드릴 것 같고....
>
> 아마도 transaction job 이 제대로 종료되지 못하고 (rollback/commit 등
> 의 명령으로), 비정상적인 종료를 하는 바람에 오는 에러로 보이는데....
소스 올립니다~~~~
형님~~~ 부탁 드립니다~~~~ :/)
#include "stdio.h"
#include "/usr/include/pgsql/libpq/fe.h"
#include "string.h"
int main()
{
char *pghost, *pgport, *pgoptions, *pgtty, *dbName;
PGconn *Connection;
PGresult *result;
int number_of_lotto;
int nTuples;
char sqlstr[200];
int i;
int level;
int lotto_number;
int t_lotto_number;
int l_point;
char temp[10];
char data1[20],data2[20],data3[20];
char *LOTTO_NAME="즉석복권";
pgoptions=NULL;
pgtty=NULL;
dbName="lotto";
pghost="localhost";
pgport="5432";
Connection=PQsetdb(pghost,pgport,pgoptions,pgtty,dbName);
if(PQstatus(Connection)==CONNECTION_BAD)
{
fprintf(stdout,"connection_to_database_%s_failed\n\n",dbName);
PQfinish(Connection);
exit(1);
}
strcpy(sqlstr,"declare dcursor cursor for select * from lotto where name='")
;
strcat(sqlstr,LOTTO_NAME);
strcat(sqlstr,"' ");
result=PQexec(Connection,"BEGIN");
result=PQexec(Connection,sqlstr);
result=PQexec(Connection,"FETCH forward 10 in dcursor");
strcpy(temp,PQgetvalue(result,0,1));
number_of_lotto=atoi(temp);
result=PQexec(Connection,"END;");
strcpy(sqlstr,"update lotto set number_of_lotto_usable=");
strcat(sqlstr,temp);
strcat(sqlstr," where name='");
strcat(sqlstr,LOTTO_NAME);
strcat(sqlstr,"' ;");
// result=PQexec(Connection,sqlstr);
PQexec(Connection,"delete from level where name='즉석복권';");
strcpy(sqlstr,"delete from level where name='");
strcat(sqlstr,"즉석복권");//LOTTO_NAME);
strcat(sqlstr,"';");
PQexec(Connection,sqlstr);
strcpy(sqlstr,"declare decursor cursor for select * from leveldata where nam
e='");
strcat(sqlstr,LOTTO_NAME);
strcat(sqlstr,"'");
result=PQexec(Connection,"BEGIN");
result=PQexec(Connection,sqlstr);
result=PQexec(Connection,"FETCH forward 50 in decursor");
nTuples=PQntuples(result);
for(i=0;i<number_of_lotto&&i<nTuples;i++)
{
strcpy(data1,PQgetvalue(result,i,1));
strcpy(data2,PQgetvalue(result,i,2));
strcpy(data3,PQgetvalue(result,i,3));
strcpy(sqlstr,"insert into level values ('");
strcat(sqlstr,LOTTO_NAME);
strcat(sqlstr,"',");
strcat(sqlstr,data1);
strcat(sqlstr,",");
strcat(sqlstr,data2);
strcat(sqlstr,",");
strcat(sqlstr,data2);
strcat(sqlstr,",");
strcat(sqlstr,data3);
strcat(sqlstr,");");
}
result=PQexec(Connection,"END;");
PQclear(result);
PQfinish(Connection);
return 0;
}
|