 |
INFORMIX-ESQL/C Programmer's Manual ESQL/C Function Library |
|
rtypname()
The rtypname() function returns a null-terminated string that contains the name of the specified SQL data type.
Syntax
The rtypname() function converts a constant for an Informix SQL data type (which sqltypes.h defines) to a character string.
Return Codes
The rtypname function returns a pointer to a string that contains the name of the data type specified sqltype. If sqltype is an invalid value, rtypname() returns a null string (" ")
Example
This sample program is in the rtypname.ec file in the demo directory.
if (argc == 2)
strcpy(db_name, argv[1]);
EXEC SQL connect to :db_name;
sprintf(db_stmnt, "CONNECT TO %s", argv[1]);
exp_chk(db_stmnt, NOWARNNOTIFY);
printf("Connected to '%s' database.", db_name);
EXEC SQL prepare query_1 from 'select * from orders'; /* prepare select */
if(exp_chk("Prepare", WARNNOTIFY) == 1)
exit(1);
EXEC SQL describe query_1 into sql_desc; /* initialize sqlda */
if(exp_chk("Describe", WARNNOTIFY) == 1)
exit(1);
printf("\n\tColumn Name \t\tSQL type\n\n");
/*
* For each column in the orders table display the column name and
* the name of the SQL data type
*/
for (i = 0, col = sql_desc->sqlvar; i < sql_desc->sqld; i++, col++)
printf("\t%-15s\t\t%s\n", col->sqlname, rtypname(col->sqltype));
printf("\nRTYPNAME Sample Program over.\n\n");
}
/*
* The exp_chk() file contains the exception handling functions to
* check the SQLSTATE status variable to see if an error has occurred
* following an SQL statement. If a warning or an error has
* occurred, exp_chk() executes the GET DIAGNOSTICS statement and
* prints the detail for each exception that is returned.
*/
EXEC SQL include exp_chk.ec
For a complete listing of the exp_chk() function, see Guide to the exp_chk.ec File or refer to the exp_chk.ec file for a listing of this exception-handling function.
Output
INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved