From: | Tom Good <tomg(at)nrnet(dot)org> |
---|---|
To: | PostgreSQL Interfaces List <pgsql-interfaces(at)postgreSQL(dot)org> |
Subject: | ecpg - `exec sql delete' failing |
Date: | 1998-04-03 21:46:10 |
Message-ID: | Pine.LNX.3.95.980403164223.2163A-100000@mailhost.nrnet.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi. Can't fathom why this code precompiles, compiles, links and
seems to execute - but won't delete records.
As always - any assistance greatly appreciated!
Tom
--- pgc code follows ---
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
int ClientID; /* client_id */
char FirstName[16]; /* client_fname */
char LastName[16]; /* client_lname */
char NameTag[16]; /* usr buffer */
char reply; /* usr buffer */
int delete_num; /* usr buffer */
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
main()
{
EXEC SQL CONNECT 'registry';
if(sqlca.sqlcode) {
printf("Error connecting to database server.\n");
exit(0);
}
system("tput clear");
printf("\n\n");
printf("\t\t\tConnected to database server...\n");
printf("\t\t\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");
printf("\t\tID: %d Lastname: %s Firstname: %s\n", ClientID, LastName, FirstName);
printf("\t\t-------------------------------------------------------\n");
printf("\t\tRemove this record (y/n): ");
scanf("%s", &reply);
if(reply == 'y') {
printf("\t\tEnter Client ID Number: ");
scanf("%d", &delete_num);
EXEC SQL DELETE FROM central WHERE client_id = delete_num;
}
else printf("Exiting...record not removed.\n");
exit(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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Good | 1998-04-04 11:27:21 | |
Previous Message | Tom Good | 1998-04-03 13:19:33 | RE: [INTERFACES] ecpg libraries |