ecpg-gets()

From: Tom Good <tomg(at)nrnet(dot)org>
To: PostgreSQL Interfaces List <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: ecpg-gets()
Date: 1998-04-09 20:03:03
Message-ID: Pine.LNX.3.95.980409160012.3290B-100000@mailhost.nrnet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi all...this code compiles but when you get to the gets()
function call it jumps ahead to the next printf()...it does not
pass go and it doesn't enter any values into the attribute...it
simply leaps ahead to the next stanza.

Anyone seen this before - or got a quick fix?

Thanks,
Tom
------------------------------------

#include <stdio.h>
#include <string.h>

EXEC SQL BEGIN DECLARE SECTION;
int ClientID; /* client_id */
char FirstName[16]; /* client_fname */
char LastName[16]; /* client_lname */
char AliasName[26]; /* a_lias */
char HomeStat[31]; /* home_stat */
int HomeLess; /* home_less */
char NameTag[16]; /* usr buffer */
char Hmm[80]; /* usr buffer */
EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE sqlca;

main() {
EXEC SQL CONNECT 'registry';

EXEC SQL WHENEVER sqlerror sqlprint;
EXEC SQL WHENEVER not found sqlprint;

system("tput clear");
printf("\n\tEnter Last Name of Client: ");
scanf("%s", &NameTag);

EXEC SQL SELECT client_id, client_lname, client_fname
INTO :ClientID, :LastName, :FirstName
FROM central
WHERE client_lname = :NameTag;

printf("\n\tClient ID Lastname Firstname");
printf("\n\t----------------------------------------------");
printf("\n\t%d %s %s\n", ClientID, LastName, FirstName);

EXEC SQL COMMIT;

printf("\n\tEnter Any Known Alias (or N/A): ");
scanf("%s", &AliasName);
EXEC SQL UPDATE central
SET a_lias = :AliasName
WHERE client_lname = :NameTag;
EXEC SQL COMMIT;

printf("\tEnter Homeless Status (i.e, `Not Homeless'): ");
fflush(stdout);
gets(Hmm);
EXEC SQL UPDATE central
SET home_stat = :Hmm
WHERE client_lname = :NameTag;
EXEC SQL COMMIT;

printf("\tEnter OMH Homeless Code: ");
scanf("%d", &HomeLess);
EXEC SQL UPDATE central
SET home_less = :HomeLess
WHERE client_lname = :NameTag;
EXEC SQL COMMIT;

return (0);
}

----------- Sisters of Charity Medical Center ----------
Department of Psychiatry
----
Thomas Good, System Administrator <tomg(at)q8(dot)nrnet(dot)org>
North Richmond CMHC/Residential Services Phone: 718-354-5528
75 Vanderbilt Ave, Quarters 8 Fax: 718-354-5056
Staten Island, NY 10305

Browse pgsql-interfaces by date

  From Date Subject
Next Message David Hartwig 1998-04-09 22:54:24 New pg_type for large object
Previous Message Constantin Teodorescu 1998-04-08 13:57:49 Re: libpgtcl instructions - undefined symbol crypt