From: | "Jasbinder Singh Bali" <jsbali(at)gmail(dot)com> |
---|---|
To: | "Andrew Jarcho" <ajarcho(at)nyc(dot)rr(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: ecpg code wont write to db |
Date: | 2007-04-21 05:25:57 |
Message-ID: | a47902760704202225h5146376ds443651266e3dc69@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
write to file using ECPGdebug
like
ECPGdebug(1, f);
where f is your file pointer.
Include this right in the beginning of your code and then check this
file to see where is your ECPG throwing error.
~Jas
On 4/21/07, Andrew Jarcho <ajarcho(at)nyc(dot)rr(dot)com> wrote:
>
> 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' */
> }
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Cook | 2007-04-21 07:22:59 | Clustered index? |
Previous Message | Andrew Jarcho | 2007-04-21 05:01:53 | ecpg code wont write to db |