Consultor Eletrônico



Kbase 13449: How to make a CURSOR updatable in ESQL/C
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to make a CURSOR updatable in ESQL/C

If you receive the following error:
"** Cursor <name> is not updatable. (1207)"
you have declated the cursor incorrectly.
Below is an example how to define the curser correctly.
(Also, please refer to Programming Handbook, Appendix A, in
version 7.2 for further information on this topic, in conjunction
with "PROGRESS Embedded SQL Guide and Reference.")


#include <stdio.h>
main(argc,argv)
int argc; /* Command line arguments to Progress */
char *argv[]; /* must include at least the db name. */
{
long SQLCODE;
char *msg;
EXEC SQL BEGIN DECLARE SECTION;
char xname[32];
EXEC SQL END DECLARE SECTION;

if (sqllogin(argc-1, &argv[1], "", "") == -1) {
printf(" Could not login to Progress HLI.\n " );
exit(0);
}

EXEC SQL WHENEVER SQLERROR GOTO err;
EXEC SQL DECLARE XCUR CURSOR FOR
SELECT State\-Name FROM State WHERE State="MA" FOR UPDATE;
EXEC SQL OPEN XCUR.
EXEC SQL WHENEVER NOT FOUND GOTO done1;

EXEC SQL fetch XCUR INTO :xname;
printf(" Name: %s \n", xname);
strcpy(xname, "Mass");
EXEC SQL update State
SET State\-Name = :xname WHERE CURRENT OF XCUR;
goto done1;

err:
printf("Error occured.\n");
while ((msg = (char *) sqlgetmsg()) != (char *) 0)
printf("%s\n",msg);
printf("\nRolling back all work...\n");
EXEC SQL ROLLBACK WORK;
sqllogout(0);
exit(0);

done1:
EXEC SQL CLOSE XCUR;
EXEC SQL COMMIT WORK;

sqllogout(0);
return 0;
}

Progress Software Technical Support Note # 13449