ecpg code wont write to db

From: Andrew Jarcho <ajarcho(at)nyc(dot)rr(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: ecpg code wont write to db
Date: 2007-04-21 05:01:53
Message-ID: 46299AC1.9080904@nyc.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hi --
im using ecpg to issue commands to my postgresql db on my school's
Solaris system. The commands that read from the db seem to function
properly. Those that should write to the db run but have no effect. I
have no trouble writing to the db from php code.

a small multi-threaded server (written in C, using pthreads) accepts
calls on a stream internet socket. The server spawns a thread for each
incoming call. The code the thread executes calls a C wrapper for some
C++ code; the C++ code calls the C functions which were compiled from
the ecpg. This architecture is due to the fact that the C++ code must
control the program as a whole.

i doubt that the multi-threading is the cause of the problem, as the
client (php) makes only a single call each time it is run.

a sample of the code follows. i'd very much appreciate any help anyone
can give me with this.

int do_login(const char *mstsLname, const char *mstsPasswd)
{
EXEC SQL BEGIN DECLARE SECTION;
const char *mstsLogname = mstsLname;
const char *mstsPassword = mstsPasswd;
int mstsLoginStatus = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER NOT FOUND GOTO notfound;

connect_to_postgresql();

EXEC SQL
SELECT count(*) INTO :mstsLoginStatus
FROM ms_account A
WHERE A.logname = :mstsLogname AND
A.password = :mstsPassword;

if (mstsLoginStatus == 1) {
EXEC SQL INSERT INTO ms_logInOut (logname, logDate, isIn)
VALUES (:mstsLogname, SYSDATE, 'y');
EXEC SQL COMMIT;
}

disconnect_from_postgresql();

return mstsLoginStatus; /* -1 for error; 0 if no such login; 1 if OK */

notfound:
disconnect_from_postgresql_error();
return -1; /* return 'not found' */
}

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jasbinder Singh Bali 2007-04-21 05:25:57 Re: ecpg code wont write to db
Previous Message Andrew Jarcho 2007-04-20 17:47:54 can i call stored function using ecpg?