SE_connection_get_sql_info

Retrieves a database management syste (DBMS)–specific function name

Usage syntax

LONG SE_connection_get_sql_info (SE_CONNECTION connection, LONG sql_id, CHAR *sql_name);

Parameters
connection The connection handle
sql_id The function ID
sql_name A pointer to the function name
Description

SE_connection_get_dbms_function returns a DBMS-specific function name. Sometimes database management systems use different names for the same function. This function allows you to write DBMS-independent code and allows the ArcSDE server to call the correct DBMS function. For example, if the function_id is SE_DBMS_FUNCTION_UPPERCASE, Oracle servers return “UPPER” while DB2 servers return “UCASE”. Allocate at least SE_MAX_FUNCTION_LEN bytes to the function_name argument.

The string function values are:

typedef enum {

SE_DBMS_FUNCTION_UPPERCASE,     /* Returns char in upper case */

SE_DBMS_FUNCTION_LOWERCASE,     /* Returns char in lower case */

SE_DBMS_FUNCTION_CONCAT,        /* Returns char1 concatenated with char2 */

SE_DBMS_FUNCTION_ASCII,         /* Returns decimal representation of char c */

SE_DBMS_FUNCTION_LENGTH,        /* Returns length in CHAR */

SE_DBMS_FUNCTION_LENGTHB,       /* Returns length in bytes */

SE_DBMS_FUNCTION_CHR,           /* Returns the character of the binary equivalent */

SE_DBMS_FUNCTION_LTRIM,         /* Removes spaces from the left */

SE_DBMS_FUNCTION_RTRIM,         /* Removes trailing from the right */

SE_DBMS_FUNCTION_SUBSTR,        /* Returns a portion of char at M and N c long */

SE_DBMS_FUNCTION_SUBSTRB,       /* Returns a portion of bytes at m and n bytes long */

SE_DBMS_FUNCTION_SOUNDEX,       /* Returns a char containing the phonetic representation of char2 */

SE_DBMS_FUNCTION_TRANSLATE,     /* Returns char with each "from" char replaced by its corresponding "to" char */

SE_DMBS_FUNCTION_TRIM           /* Strips the leading, trailing, *, or both from the string. */

The numeric functions are:

SE_DBMS_FUNCTION_CEIL,          /* Returns smallest integer >= n */

SE_DBMS_FUNCTION_FLOOR,         /* Returns largest integer <= n */

SE_DBMS_FUNCTION_ROUND,         /* Returns n rounded to m place of n */

SE_DBMS_FUNCTION_LN,            /* Returns natural logarithm of n */

SE_DBMS_FUNCTION_LOG10,         /* Returns logarithm of base 10 */

SE_DBMS_FUNCTION_LOG,           /* Returns logarithm of base n */

SE_DBMS_FUNCTION_MOD,           /* Returns the reminder of m divided by n */

SE_DBMS_FUNCTION_POWER,         /* Returns the n power of m */

SE_DBMS_FUNCTION_SIGN,          /* Returns -1 for negative, 0 for zero and 1 for positive */

SE_DBMS_FUNCTION_TRUNC,         /* Returns n truncated to m decimal places */

SE_DBMS_FUNCTION_SINH,          /* Returns hyperbolic sine of x */

SE_DBMS_FUNCTION_COSH,          /* Returns hyperbolic cosine of x */

SE_DBMS_FUNCTION_TANH,          /* Returns hyperbolic tangent of x */

SE_DBMS_FUNCTION_ASIN,          /* Returns the arcsine of x */

SE_DBMS_FUNCTION_ACOS,          /* Returns the arccosine of x */

SE_DBMS_FUNCTION_ATAN,          /* Returns the arctangent of x */

SE_DBMS_FUNCTION_HEX,           /* Returns the hexadecimal representation */

SE_DBMS_FUNCTION_SIN,           /* Returns sine of x */

SE_DBMS_FUNCTION_COS,           /* Returns cosine of x */

SE_DBMS_FUNCTION_TAN,           /* Returns tangent of x */

SE_DBMS_FUNCTION_EXTRACT        /* Returns the numeric value of a date */

SE_DBMS_FUNCTION_BITLENGTH      /* Returns the string length in bits */

SE_DBMS_FUNCTION_POSITION       /* Returns the numeric value that indicates the position of a search string within the source string */

SE_DBMS_FUNCTION_VARIANCE,      /* Returns the variance of x */

SE_DBMS_FUNCTION_STDDEV,        /* Returns the standard deviation */

SE_DBMS_FUNCTION_AVG,           /* Returns the average value of n */

SE_DBMS_FUNCTION_COUNT,         /* Returns the number of rows in the query */

SE_DBMS_FUNCTION_MAX,           /* Returns the maxnimum value of expression */

SE_DBMS_FUNCTION_MIN,           /* Returns the minimum value of expression */

SE_DBMS_FUNCTION_SUM,           /* Returns the sum of values of n */

SE_DBMS_FUNCTION_COALSCE,       /* Returns the first NOT_NULL value */

SE_DBMS_FUNCTION_CONVERT,       /* The convert function  */

SE_DBMS_FUNCTION_CAST,          /* Converts one data type to another one */

SE_DBMS_FUNCTION_USER           /* Returns the current user name */

} SE_SQL_FUNCTION;

 

typedef enum {

SE_SQL_WILDCARD_MANYMATCH_CHAR, /* always start from the total number of the function constants */

SE_SQL_WILDCARD_SINGLEMATCH_CHAR,

SE_SQL_DELIMITED_CHAR_PREFIX,

SE_SQL_DELIMITED_CHAR_SUFFIX,

SE_SQL_DEFAULT_ESCAPE_CHAR_PREFIX,

SE_SQL_DEFAULT_ESCAPE_CHAR_SUFFIX,

SE_SQL_ESCAPE_CLAUSE_PREFIX,

SE_SQL_ESCAPE_CLAUSE_SUFFIX

} SE_SQL_SPECIAL_CHARACTER;

Here is an example.

LONG test_dbms_get_sql_info(SE_CONNECTION handle)

{

   SE_STREAM stream;

   long rc;

   char func_name[SE_MAX_FUNCTION_LEN];

   char sql_stmt[255];

   long numoftables=1;

   char table[SE_MAX_TABLE_LEN], column[SE_MAX_COLUMN_LEN];

 

   strcpy(table, "KENTUCKY5BOUNDARIES");

   strcpy(column, "NAME");

 

   rc = SE_connection_get_sql_info (handle, SE_DBMS_FUNCTION_UPPERCASE, func_name);

   QA_returncode_check(NULL, stream, rc, " SE_connection_get_sql_info ");

 

   sprintf(sql_stmt, "select * from %s where %s(%s) like 'CLAY%' ", table, func_name, column);

 

   rc = SE_stream_create (handle, &stream);

   QA_returncode_check(NULL, stream, rc, " SE_stream_create ");

 

   rc = SE_stream_prepare_sql (stream, sql_stmt);

   QA_returncode_check(NULL, stream, rc, " SE_stream_prepare_sql ");

 

   rc = SE_stream_execute (stream);

   QA_returncode_check(NULL, stream, rc, " SE_stream_execute ");

 

   /* . . .   */

 

   return (rc);

}

Returns

SE_SUCCESS
SE_FAILURE

SE_DBMS_DOES_NOT_SUPPORT

SE_INVALID_FUNCTION_ID

SE_INVALID_POINTER

SE_NET_FAILURE

SE_SDE_NOT_STARTED