OCISimpleSqlNameCheck()

The OCISimpleSqlChedck() API is a C callable equivalent to the DBMS_ASSERT function DBMS_ASSERT.SIMPLE_SQL_NAME

Purpose

OCISimpleSqlNameCheck() verifies that the input is a simple SQL name (a single identifier). The input value must meet the following criteria:
  • The name must begin with an alphabetic character, and may contain alphanumeric as well as the characters including _, $, and # in the second and subsequent character positions.
  • Quoted SQL names are allowed.
  • Quoted names must be enclosed in double quotes.
  • Quoted names can contain any characters between the quotes.
  • Quotes inside the name are represented by two quote characters in a row, for example, "a name with "" inside" is a valid quoted name.
  • The input parameter may have any number of leading and/or trailing white space characters.
  • The length of the name is not checked

Note:

This function only performs validation and does not modify the input.

Syntax

sword OCISimpleSqlNameCheck(
    OCIEnv   *envhp,
    OCIError *errhp,
    oratext  *in_str,
    ub4       in_str_len,
    ub4       mode
);

Parameters

envhp (IN)

OCI environment handle.

errhp (IN/OUT)

OCI error handle.

in_str (IN)

Input string buffer.

in_str_len (IN)

Input string length.

mode (IN)

Mode of operation. (implementation-defined)

Returns

Returns one of the following:
  • OCI_SUCCESS - Verification succeeded; input string is a simple SQL name.
  • OCI_ERROR - ORA-44003; input string is not a simple SQL name.

Usage

Use OCISimpleSqlNameCheck() to validate the input is a simple SQL name before constructing SQL strings, especially when you need to accept names but not necessarily quote/transform them.

Comments

  • input string does not need to be null-terminated.
  • Input may be ASCII or UTF-16 depending on the environment (envhp) configuration.
  • For UTF-16, the environment must be created using the OCI_UTF16 mode. (for example, with OCIEnvCreate(..., OCI_UTF16, ...)).