Kbase P94207: How to get schema information in ESQL/C
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/09/2004 |
|
Status: Unverified
GOAL:
How to get schema information in ESQL/C
FACT(s) (Environment):
Progress 8.x
FIX:
Below is a C program to print out table names & and their fields.
The database is called "test", and can be changed.
#include <stdio.h>
long SQLCODE;
main()
{
EXEC SQL BEGIN DECLARE SECTION;
char fieldname[30];
long recid;
char filename[30];
EXEC SQL END DECLARE SECTION;
sqllogin (0, (char **)0, "-1 test", "");
EXEC SQL declare file cursor for select _file\-name, RECID(_file)
from _file
where _file\-number > 0;
EXEC SQL declare field cursor for select _field\-name from _field
where _file\-recid = :recid;
EXEC SQL open file;
while (1) {
EXEC SQL fetch file into :filename, :recid;
if (SQLCODE !=0) break;
printf("\n%s \n", filename);
exec sql open field;
while (1) {
exec sql fetch field into :fieldname;
if (SQLCODE != 0) break;
printf (" %s \n", fieldname);
}
exec sql close field;
}
sqllogout();
exit(0);
}