Consultor Eletrônico



Kbase 13591: How to get schema information in ESQL/C (v6 & v7)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to get schema information in ESQL/C (v6 & v7)

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);
}

Progress Software Technical Support Note # 13591