DBE_SQL
Data Types
- DBE_SQL.DESC_REC
This type is a composite type and is used to store the description of the SQL_DESCRIBE_COLUMNS API.
The prototype of the DBE_SQL.DESC_REC type is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13
CREATE TYPE DBE_SQL.DESC_REC AS ( col_type int, col_max_len int, col_name VARCHAR2(32), col_name_len int, col_schema_name VARCHAR2(32), col_schema_name_len int, col_precision int, col_scale int, col_charsetid int, col_charsetform int, col_null_ok BOOLEAN );
- DBE_SQL.DESC_TAB
This type is the TABLE type of DESC_REC and is implemented through the TABLE OF syntax.
The prototype of the DBE_SQL.DESC_TAB type is as follows:
1
CREATE TYPE DBE_SQL.DESC_TAB AS TABLE OF DBE_SQL.DESC_REC INDEX BY INTEGER;
- DBE_SQL.DATE_TABLE
This type is the TABLE type of DATE and is implemented through the TABLE OF syntax.
The prototype of the DBE_SQL.DATE_TABLE type is as follows:
1
CREATE TYPE DBE_SQL.DATE_TABLE AS TABLE OF DATE INDEX BY INTEGER;
- DBE_SQL.NUMBER_TABLE
This type is the TABLE type of NUMBER and is implemented through the TABLE OF syntax.
The prototype of the DBE_SQL.NUMBER_TABLE type is as follows:
1
CREATE TYPE DBE_SQL.NUMBER_TABLE AS TABLE OF NUMBER INDEX BY INTEGER;
- DBE_SQL.VARCHAR2_TABLE
This type is the TABLE type of VARCHAR2 and is implemented through the TABLE OF syntax.
The prototype of the DBE_SQL.VARCHAR2_TABLE type is as follows:
1
CREATE TYPE DBE_SQL.VARCHAR2_TABLE AS TABLE OF VARCHAR2(32767) INDEX BY INTEGER;
- DBE_SQL.BLOB_TABLE
This type is the TABLE type of BLOB and is implemented through the TABLE OF syntax.
The prototype of the DBE_SQL.BLOB_TABLE type is as follows:
1
CREATE TYPE DBE_SQL.BLOB_TABLE AS TABLE OF BLOB INDEX BY INTEGER;
API Description
Table 1 lists APIs supported by the DBE_SQL package.
API |
Description |
---|---|
Opens a cursor. |
|
Closes an open cursor. |
|
Passes a set of SQL statements or anonymous blocks to a cursor. |
|
Executes SQL statements or anonymous blocks in a given cursor. |
|
Reads a row of cursor data. |
|
Dynamically defines a column. |
|
Dynamically defines a column of the CHAR type. |
|
Dynamically defines a column of the INT type. |
|
Dynamically defines a column of the LONG type. |
|
Dynamically defines a column of the RAW type. |
|
Dynamically defines a column of the BYTEA type. |
|
Dynamically defines a column of the TEXT type. |
|
Dynamically defines a column of an unknown type. |
|
Reads a dynamically defined column value. |
|
Reads a dynamically defined column value of the CHAR type. |
|
Reads a dynamically defined column value of the INT type. |
|
Reads a dynamically defined column value of the LONG type. |
|
Reads a dynamically defined column value of the RAW type. |
|
Reads a dynamically defined column value of the BYTEA type. |
|
Reads a dynamically defined column value of the TEXT type. |
|
Reads a dynamically defined column value of an unknown type. |
|
Reads a dynamically defined column value of the CHAR type. |
|
Reads a dynamically defined column value of the LONG type. |
|
Reads a dynamically defined column value of the RAW type. |
|
Checks whether a cursor is opened. |
|
Returns the cumulative count of obtained rows. |
|
Reads data of a cursor after a set of dynamically defined operations are performed on the cursor. |
|
Binds a value to a variable in a statement. |
|
Binds a group of values to a variable in a statement. |
|
Dynamically defines a column of the INT array type. |
|
Dynamically defines a column of the TEXT array type. |
|
Dynamically defines a column of the RAW array type. |
|
Dynamically defines a column of the BYTEA array type. |
|
Dynamically defines a column of the CHAR array type. |
|
Dynamically defines a column of the array type. |
|
Reads a dynamically defined column value of the INT array type. |
|
Reads a dynamically defined column value of the TEXT array type. |
|
Reads a dynamically defined column value of the RAW array type. |
|
Reads a dynamically defined column value of the BYTEA array type. |
|
Reads a dynamically defined column value of the CHAR array type. |
|
Reads a dynamically defined column value. |
|
Describes the column information read by the cursor. |
|
Describes the column information read by the cursor. |
|
Binds parameters. |
|
Dynamically defines a column of the array type. |
|
Reads a dynamically defined column value. |
|
Reads the return value of an SQL statement. |
|
Reads the return value (of the CHAR type) of an SQL statement. |
|
Reads the return value (of the RAW type) of an SQL statement. |
|
Reads the return value (of the TEXT type) of an SQL statement. |
|
Reads the return value (of the INT type) of an SQL statement. |
|
Reads the return value (of the TEXT array type) of an SQL statement. |
|
Reads the return value (of the RAW array type) of an SQL statement. |
|
Reads the return value (of the CHAR array type) of an SQL statement. |
|
Reads the return value (of the INT array type) of an SQL statement. |
|
Dynamically defines a column of the tableof type. |
|
Reads a dynamically defined column value of the tableof type. |
- You are advised to use dbe_sql.set_result_type and dbe_sql.get_result to define columns.
- If the size of the result set is greater than the value of work_mem, the result set will be spilled to a disk temporarily. The value of work_mem must be no greater than 512 MB.
- DBE_SQL.REGISTER_CONTEXT
This function opens a cursor, which is the prerequisite for the subsequent dbe_sql operations. This function does not transfer any parameter. It automatically generates cursor IDs in an ascending order and returns values to integer variables.
Cursors opened by DBE_SQL are session-level variables. Cross-session calling of opened cursors (such as autonomous transactions) is not supported. If a cross-session cursor is called, the behavior is unpredictable.
The prototype of the DBE_SQL.REGISTER_CONTEXT function is as follows:
1 2 3
DBE_SQL.REGISTER_CONTEXT( ) RETURN INTEGER;
- DBE_SQL.SQL_UNREGISTER_CONTEXT
This function closes a cursor, which is the end of each dbe_sql operation. If this function is not called when the stored procedure ends, the memory is still occupied by the cursor. Therefore, remember to close a cursor when you do not need to use it. If an exception occurs, the stored procedure exits but the cursor is not closed. Therefore, you are advised to include this API in the exception handling of the stored procedure.
The prototype of the DBE_SQL.SQL_UNREGISTER_CONTEXT function is as follows:
1 2 3 4
DBE_SQL.SQL_UNREGISTER_CONTEXT( context_id IN INTEGER ) RETURN INTEGER;
Table 2 DBE_SQL.SQL_UNREGISTER_CONTEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be closed
- DBE_SQL.SQL_SET_SQL
Parses SQL statements or anonymous blocks in a given cursor. The statement parameters can be transferred only through the text type. The length cannot exceed 1 GB.
The prototype of the DBE_SQL.SQL_SET_SQL function is as follows:1 2 3 4 5 6
DBE_SQL.SQL_SET_SQL( context_id IN INTEGER, query_string IN TEXT, language_flag IN INTEGER ) RETURN BOOLEAN;
Table 3 DBE_SQL.SQL_SET_SQL parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor whose query statement is to be parsed
query_string
TEXT
IN
No
Query statement to be executed for parsing
language_flag
INTEGER
IN
No
Version language. The value 1 indicates an incompatible version, and the value 2 indicates a compatible version.
- DBE_SQL.SQL_RUN
This function executes a given cursor. This function receives a cursor ID and executes SQL statements or anonymous blocks in a given cursor.
The prototype of the DBE_SQL.SQL_RUN function is as follows:1 2 3 4
DBE_SQL.SQL_RUN( context_id IN INTEGER, ) RETURN INTEGER;
Table 4 DBE_SQL.SQL_RUN parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor whose query statement is to be parsed
- DBE_SQL.NEXT_ROW
This function returns the number of data rows that meet query conditions. Each time the API is executed, the system obtains a set of new rows until all data is read.
The prototype of the DBE_SQL.NEXT_ROW function is as follows:1 2 3 4
DBE_SQL.NEXT_ROW( context_id IN INTEGER, ) RETURN INTEGER;
Table 5 DBE_SQL.NEXT_ROW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
- DBE_SQL.SET_RESULT_TYPE
This function defines columns returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE function is as follows:1 2 3 4 5 6 7
DBE_SQL.SET_RESULT_TYPE( context_id IN INTEGER, pos IN INTEGER, column_ref IN ANYELEMENT, maxsize IN INTEGER default 1024 ) RETURN INTEGER;
Table 6 DBE_SQL.SET_RESULT_TYPE parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Relative position of the queried columns in the returned result. The value starts from 1.
column_ref
ANYELEMENT
IN
No
Variable of any type. You can select an appropriate API to dynamically define columns based on variable types.
maxsize
INTEGER
IN
Yes
Length of the defined column return type.
- DBE_SQL.SET_RESULT_TYPE_CHAR
This function defines columns of the CHAR type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_CHAR function is as follows:1 2 3 4 5 6 7
DBE_SQL.SET_RESULT_TYPE_CHAR( context_id IN INTEGER, pos IN INTEGER, column_ref IN TEXT, column_size IN INTEGER ) RETURN INTEGER;
Table 7 DBE_SQL.SET_RESULT_TYPE_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
column_ref
TEXT
IN
No
Parameter to be defined
column_size
INTEGER
IN
No
Length of a dynamically defined column
- DBE_SQL.SET_RESULT_TYPE_INT
This function defines columns of the INT type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_INT function is as follows:1 2 3 4 5
DBE_SQL.SET_RESULT_TYPE_INT( context_id IN INTEGER, pos IN INTEGER ) RETURN INTEGER;
Table 8 DBE_SQL.SET_RESULT_TYPE_INT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.SET_RESULT_TYPE_LONG
This function defines columns of a long type (not LONG) returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type. The maximum size of a long column is 1 GB.
The prototype of the DBE_SQL.SET_RESULT_TYPE_LONG function is as follows:1 2 3 4 5
DBE_SQL.SET_RESULT_TYPE_LONG( context_id IN INTEGER, pos IN INTEGER ) RETURN INTEGER;
Table 9 DBE_SQL.SET_RESULT_TYPE_LONG parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.SET_RESULT_TYPE_RAW
This function defines columns of the RAW type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_RAW function is as follows:1 2 3 4 5 6 7
DBE_SQL.SET_RESULT_TYPE_RAW( context_id IN INTEGER, pos IN INTEGER, column_ref IN RAW, column_size IN INTEGER ) RETURN INTEGER;
Table 10 DBE_SQL.SET_RESULT_TYPE_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
column_ref
RAW
IN
No
RAW variable
column_size
INTEGER
IN
No
Column length
- DBE_SQL.SET_RESULT_TYPE_BYTEA
Defines columns of the BYTEA type returned from a given cursor and can be used only for cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_BYTEA function is as follows:1 2 3 4 5 6 7
DBE_SQL.SET_RESULT_TYPE_BYTEA( context_id IN INTEGER, pos IN INTEGER, column_ref IN BYTEA, column_size IN INTEGER ) RETURN INTEGER;
Table 11 DBE_SQL.SET_RESULT_TYPE_BYTEA parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
column_ref
BYTEA
IN
No
BYTEA variable
column_size
INTEGER
IN
No
Column length
- DBE_SQL.SET_RESULT_TYPE_TEXT
This function defines columns of the TEXT type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_TEXT function is as follows:1 2 3 4 5 6
DBE_SQL.DEFINE_COLUMN_CHAR( context_id IN INTEGER, pos IN INTEGER, maxsize IN INTEGER ) RETURN INTEGER;
Table 12 DBE_SQL.SET_RESULT_TYPE_TEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
maxsize
INTEGER
IN
No
Maximum length of the defined TEXT type
- DBE_SQL.SET_RESULT_TYPE_UNKNOWN
This function processes columns of unknown data types returned from a given cursor. It is used only for the system to report an error and exist when the type cannot be identified.
The prototype of the DBE_SQL.SET_RESULT_TYPE_UNKNOWN function is as follows:1 2 3 4 5 6
DBE_SQL.SET_RESULT_TYPE_UNKNOWN( context_id IN INTEGER, pos IN INTEGER, col_type IN TEXT ) RETURN INTEGER;
Table 13 DBE_SQL.SET_RESULT_TYPE_UNKNOWN parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
col_type
TEXT
IN
No
Dynamically defined parameter
- DBE_SQL.GET_RESULT
This function returns the cursor element value in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT function is as follows:1 2 3 4 5 6
DBE_SQL.GET_RESULT( context_id IN INTEGER, pos IN INTEGER, column_value INOUT ANYELEMENT ) RETURN ANYELEMENT;
Table 14 DBE_SQL.GET_RESULT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Relative position of the queried columns in the returned result. The value starts from 1.
column_value
ANYELEMENT
INOUT
No
Return value of the query result of a specified column
- DBE_SQL.GET_RESULT_CHAR
This stored procedure returns the value of the CHAR type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT_CHAR stored procedure is as follows:1 2 3 4 5 6 7
DBE_SQL.GET_RESULT_CHAR( context_id IN INTEGER, pos IN INTEGER, tr INOUT CHAR, err INOUT NUMERIC, actual_length INOUT INTEGER );
Table 15 DBE_SQL.GET_RESULT_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Relative position of the queried columns in the returned result. The value starts from 1.
tr
CHAR
INOUT
No
Return value
err
NUMERIC
INOUT
No
Error No. It is an output parameter. The input parameter must be a variable. Currently, the output value is –1 regardless of the input parameter.
actual_length
INTEGER
INOUT
No
Length of a return value
- The overloading of the DBE_SQL.GET_RESULT_CHAR stored procedure is as follows:
1 2 3 4 5
DBE_SQL.GET_RESULT_CHAR( context_id IN INTEGER, pos IN INTEGER, tr INOUT CHAR );
Table 16 DBE_SQL.GET_RESULT_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
tr
CHAR
INOUT
No
Return value
- DBE_SQL.GET_RESULT_INT
This function returns the value of the INT type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW. The prototype of the DBE_SQL.GET_RESULT_INT function is as follows:
1 2 3 4 5
DBE_SQL.GET_RESULT_INT( context_id IN INTEGER, pos IN INTEGER ) RETURN INTEGER;
Table 17 DBE_SQL.GET_RESULT_INT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.GET_RESULT_LONG
This function returns the value of a long type (not LONG or BIGINT) in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT_LONG function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.GET_RESULT_LONG( context_id IN INTEGER, pos IN INTEGER, lgth IN INTEGER, off_set IN INTEGER, vl INOUT TEXT, vl_length INOUT INTEGER ) RETURN RECORD;
Table 18 DBE_SQL.GET_RESULT_LONG parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
lgth
INTEGER
IN
No
Length of a return value
off_set
INTEGER
IN
No
Start position of a return value
vl
TEXT
INOUT
No
Return value
vl_length
INTEGER
INOUT
No
Length of a return value
- DBE_SQL.GET_RESULT_RAW
Returns the value of the RAW type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT_RAW stored procedure is as follows:1 2 3 4 5 6 7
DBE_SQL.GET_RESULT_RAW( context_id IN INTEGER, pos IN INTEGER, tr INOUT RAW, err INOUT NUMERIC, actual_length INOUT INTEGER );
Table 19 DBE_SQL.GET_RESULT_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
tr
RAW
INOUT
No
Returned column value
err
NUMERIC
INOUT
No
Error No. It is an output parameter. The input parameter must be a variable. Currently, the output value is –1 regardless of the input parameter.
actual_length
INTEGER
INOUT
No
Length of a return value. The value longer than this length will be truncated.
- The overloading of the DBE_SQL.GET_RESULT_RAW stored procedure is as follows:
1 2 3 4 5
DBE_SQL.GET_RESULT_RAW( context_id IN INTEGER, pos IN INTEGER, tr INOUT RAW );
Table 20 DBE_SQL.GET_RESULT_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
tr
RAW
INOUT
No
Returned column value
- DBE_SQL.GET_RESULT_BYTEA
Returns the value of the BYTEA type in a specified position of a cursor that is obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT_BYTEA stored procedure is as follows:1 2 3 4 5
DBE_SQL.GET_RESULT_BYTEA( context_id IN INTEGER, pos IN INTEGER ) RETURN BYTEA;
Table 21 DBE_SQL.GET_RESULT_BYTEA parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.GET_RESULT_TEXT
This function returns the value of the TEXT type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULT_TEXT function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULT_TEXT( context_id IN INTEGER, pos IN INTEGER ) RETURN TEXT;
Table 22 DBE_SQL.GET_RESULT_TEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.GET_RESULT_UNKNOWN
This function returns the value of an unknown type in a specified position of a cursor. It serves as an error handling API when the type is not unknown.
The prototype of the DBE_SQL.GET_RESULT_UNKNOWN function is as follows:1 2 3 4 5 6
DBE_SQL.GET_RESULT_UNKNOWN( context_id IN INTEGER, pos IN INTEGER, col_type IN TEXT ) RETURN TEXT;
Table 23 DBE_SQL.GET_RESULT_UNKNOWN parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
col_type
TEXT
IN
No
Returned parameter type
- DBE_SQL.DBE_SQL_GET_RESULT_CHAR
This function returns the value of the CHAR type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW. Different from DBE_SQL.GET_RESULT_CHAR, the length of the return value is not set and the entire string is returned.
The prototype of the DBE_SQL.DBE_SQL_GET_RESULT_CHAR function is as follows:1 2 3 4 5
DBE_SQL.DBE_SQL_GET_RESULT_CHAR( context_id IN INTEGER, pos IN INTEGER ) RETURN CHARACTER;
Table 24 DBE_SQL.DBE_SQL_GET_RESULT_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.DBE_SQL_GET_RESULT_LONG
This function returns the value of a long type (not LONG or BIGINT) in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
Different from DBE_SQL.GET_RESULT_LONG, the length of the return value is not set and the entire BIGINT value is returned.
The prototype of the DBE_SQL.DBE_SQL_GET_RESULT_LONG function is as follows:1 2 3 4 5
DBE_SQL.DBE_SQL_GET_RESULT_LONG( context_id IN INTEGER, pos IN INTEGER ) RETURN BIGINT;
Table 25 DBE_SQL.DBE_SQL_GET_RESULT_LONG parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
- DBE_SQL.DBE_SQL_GET_RESULT_RAW
This function returns the value of the RAW type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
Different from DBE_SQL.GET_RESULT_RAW, the length of the return value is not set and the entire string is returned.
The prototype of the DBE_SQL.DBE_SQL_GET_RESULT_RAW function is as follows:1 2 3 4 5 6
DBE_SQL.GET_RESULT_RAW( context_id IN INTEGER, pos IN INTEGER, tr INOUT RAW ) RETURN RAW;
Table 26 DBE_SQL.GET_RESULT_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be executed
pos
INTEGER
IN
No
Position of a dynamically defined column in the query
tr
RAW
INOUT
No
Returned column value
- DBE_SQL.IS_ACTIVE
This function returns the status of a cursor. When a cursor is opened, parsed, executed, or defined, the value is TRUE. When a cursor is closed, the value is FALSE. If the status is unknown, an error is reported. In other cases, the cursor is closed by default.
The prototype of the DBE_SQL.IS_ACTIVE function is as follows:1 2 3 4
DBE_SQL.IS_ACTIVE( context_id IN INTEGER ) RETURN BOOLEAN;
Table 27 DBE_SQL.IS_ACTIVE parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor to be queried
- DBE_SQL.LAST_ROW_COUNT
Returns the accumulated count of data rows obtained after the latest NEXT_ROW execution.
The prototype of the DBE_SQL.LAST_ROW_COUNT function is as follows:
1 2 3
DBE_SQL.LAST_ROW_COUNT( ) RETURN INTEGER;
- DBE_SQL.RUN_AND_NEXT
Equivalent to calling SQL_RUN and NEXT_ROW in sequence.
The prototype of the DBE_SQL.RUN_AND_NEXT function is as follows:1 2 3 4
DBE_SQL.RUN_AND_NEXT( context_id IN INTEGER ) RETURNS INTEGER;
Table 28 DBE_SQL.RUN_AND_NEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INTEGER
IN
No
ID of the cursor whose query statement is to be parsed
- DBE_SQL.SQL_BIND_VARIABLE
This function is used to bind a parameter to an SQL statement. When an SQL statement is executed, the SQL statement is executed based on the bound value.
The prototype of the DBE_SQL.SQL_BIND_VARIABLE function is as follows:1 2 3 4 5 6 7
DBE_SQL.SQL_BIND_VARIABLE( context_id IN int, query_string IN text, language_flag IN anyelement, out_value_size IN int default null ) RETURNS void;
Table 29 DBE_SQL.SQL_BIND_VARIABLE parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
query_string
TEXT
IN
No
Name of the bound variable
language_flag
ANYELEMENT
IN
No
Bound value
out_value_size
INT
IN
Yes
Size of the return value. Default value: NULL. In A-compatible mode, the parameter behavior is the same as that of database A only when the parameter type of the value is VARCHAR or CHAR.
- DBE_SQL.SQL_BIND_ARRAY
This function is used to bind a set of parameters to an SQL statement. When an SQL statement is executed, the SQL statement is executed based on the bound array.
The prototype of the DBE_SQL.SQL_BIND_ARRAY function is as follows:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
DBE_SQL.SQL_BIND_ARRAY( context_id IN int, query_string IN text, value IN anyarray ) RETURNS void; DBE_SQL.SQL_BIND_ARRAY( context_id IN int, query_string IN text, value IN anyarray, lower_index IN int, higher_index IN int ) RETURNS void; DBE_SQL.SQL_BIND_ARRAY( context_id IN int, query_string IN text, value IN anyindexbytable ) RETURNS void; DBE_SQL.SQL_BIND_ARRAY( context_id IN int, query_string IN text, value IN anyindexbytable, lower_index IN int, higher_index IN int ) RETURNS void;
Table 30 DBE_SQL.SQL_BIND_ARRAY parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried.
query_string
TEXT
IN
No
Name of the bound variable.
value
ANYINDEXBYTABLE
IN
No
Bound array.
lower_index
INT
IN
No
Minimum index of the bound array.
higher_index
INT
IN
No
Maximum index of the bound array.
DBE_SQL.SQL_BIND_ARRAY does not support user-defined table types. Use the table types provided in Data Types.
- DBE_SQL.SET_RESULT_TYPE_INTS
This function defines columns of the INT array type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_INTS function is as follows:
1 2 3 4 5 6 7 8
DBE_SQL.SET_RESULT_TYPE_INTS( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int ) RETURNS integer;
Table 31 DBE_SQL.SET_RESULT_TYPE_INTS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
- DBE_SQL.SET_RESULT_TYPE_TEXTS
This function defines columns of the TEXT array type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_TEXTS function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.SET_RESULT_TYPE_TEXTS( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, maxsize IN int ) RETURNS integer;
Table 32 DBE_SQL.SET_RESULT_TYPE_TEXTS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
maxsize
INT
IN
No
Maximum length of the defined TEXT type
- DBE_SQL.SET_RESULT_TYPE_RAWS
This function defines columns of the RAW array type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_RAWS function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.set_result_type_raws( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, column_size IN int ) RETURNS integer;
Table 33 DBE_SQL.SET_RESULT_TYPE_RAWS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
column_size
INT
IN
No
Column length
- DBE_SQL.SET_RESULT_TYPE_BYTEAS
This function defines columns of the BYTEA array type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_BYTEAS function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.set_result_type_byteas( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, column_size IN int ) RETURNS integer;
Table 34 DBE_SQL.SET_RESULT_TYPE_BYTEAS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
column_size
INT
IN
No
Column length
- DBE_SQL.SET_RESULT_TYPE_CHARS
This function defines columns of the CHAR array type returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULT_TYPE_CHARS function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.SET_RESULT_TYPE_CHARS( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, column_size IN int ) RETURNS integer;
Table 35 DBE_SQL.SET_RESULT_TYPE_CHARS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
column_size
INT
IN
No
Column length
- DBE_SQL.SET_RESULTS_TYPE
This function defines columns returned from a given cursor and can be used only for the cursors defined by SELECT. The defined columns are identified by the relative positions in the query list. The data type of an input variable determines the corresponding column type.
The prototype of the DBE_SQL.SET_RESULTS_TYPE function is as follows:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
DBE_SQL.SET_RESULTS_TYPE( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, maxsize IN int DEFAULT 1024 ) returns void; DBE_SQL.SET_RESULTS_TYPE( context_id IN int, pos IN int, column_ref IN dbe_sql.number_table, cnt IN int, lower_bnd IN int, maxsize IN int DEFAULT 1024 ); DBE_SQL.SET_RESULTS_TYPE( context_id IN int, pos IN int, column_ref IN dbe_sql.varchar2_table, cnt IN int, lower_bnd IN int, maxsize IN int DEFAULT 32767 ); DBE_SQL.SET_RESULTS_TYPE( context_id IN int, pos IN int, column_ref IN dbe_sql.date_table, cnt IN int, lower_bnd IN int, maxsize IN int DEFAULT 1024 ); DBE_SQL.SET_RESULTS_TYPE( context_id IN int, pos IN int, column_ref IN dbe_sql.blob_table, cnt IN int, lower_bnd IN int, maxsize IN int DEFAULT 32767 );
Table 36 DBE_SQL.SET_RESULTS_TYPE parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
DBE_SQL.BLOB_TABLE
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
maxsize
INT
IN
Yes
Maximum length of the defined type
DBE_SQL.SET_RESULTS_TYPE does not support user-defined table types. Use the table types provided in "Data Types".
- DBE_SQL.GET_RESULTS_INT
This function returns the value of the INT array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULTS_INT function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULTS_INT( context_id IN int, pos IN int, column_value INOUT anyarray );
Table 37 DBE_SQL.GET_RESULTS_INT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_RESULTS_TEXT
This function returns the value of the TEXT array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULTS_TEXT function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULTS_TEXT( context_id IN int, pos IN int, column_value INOUT anyarray );
Table 38 DBE_SQL.GET_RESULTS_TEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_RESULTS_RAW
This function returns the value of the RAW array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULTS_RAW function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULTS_RAW( context_id IN int, pos IN int, column_value INOUT anyarray );
Table 39 DBE_SQL.GET_RESULTS_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_RESULTS_BYTEA
This function returns the value of the BYTEA array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULTS_BYTEA function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULTS_BYTEA( context_id IN int, pos IN int, column_value INOUT anyarray );
Table 40 DBE_SQL.GET_RESULTS_BYTEA parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_RESULTS_CHAR
This function returns the value of the CHAR array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The prototype of the DBE_SQL.GET_RESULTS_CHAR function is as follows:1 2 3 4 5
DBE_SQL.GET_RESULTS_CHAR( context_id IN int, pos IN int, column_value INOUT anyarray );
Table 41 DBE_SQL.GET_RESULTS_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_RESULTS
This function returns the value of the array type in a specified position of a cursor and accesses the data obtained by DBE_SQL.NEXT_ROW.
The bottom-layer mechanism of DBE_SQL.GET_RESULTS is implemented through arrays. When different arrays are used to obtain the return value of the same column, NULL values are filled in the array due to discontinuous internal indexes to ensure the continuity of array indexes. As a result, the length of the returned result array is different from that of the Oracle database.
The prototype of the DBE_SQL.GET_RESULTS function is as follows:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
DBE_SQL.GET_RESULTS( context_id IN int, pos IN int, column_value INOUT anyarray ); DBE_SQL.GET_RESULTS( context_id IN int, pos IN int, column_value INOUT dbe_sql.varchar2_table ); DBE_SQL.GET_RESULTS( context_id IN int, pos IN int, column_value INOUT dbe_sql.number_table ); DBE_SQL.GET_RESULTS( context_id IN int, pos IN int, column_value INOUT dbe_sql.date_table ); DBE_SQL.GET_RESULTS( context_id IN int, pos IN int, column_value INOUT dbe_sql.blob_table );
Table 42 DBE_SQL.GET_RESULTS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_value
ANYARRAY
INOUT
No
Return value
DBE_SQL.GET_RESULTS does not support user-defined table types. Use the table types provided in Data Types.
- DBE_SQL.SQL_DESCRIBE_COLUMNS
This function is used to describe column information and can be used only for cursors defined by SELECT.
The prototype of the DBE_SQL.SQL_DESCRIBE_COLUMNS function is as follows:1 2 3 4 5
DBE_SQL.SQL_DESCRIBE_COLUMNS( context_id IN int, col_cnt INOUT int, desc_t INOUT dbe_sql.desc_tab )RETURNS record ;
Table 43 DBE_SQL.SQL_DESCRIBE_COLUMNS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
col_cnt
INT
INOUT
No
Number of columns returned
desc_t
DBE_SQL.DESC_TAB
INOUT
No
Description of the returned column
- DBE_SQL.DESCRIBE_COLUMNS
Describes column information and can be used only for cursors defined by SELECT. This API is developed for compatibility purposes.
The prototype of the DBE_SQL.DESCRIBE_COLUMNS function is as follows:
1 2 3 4 5
DBE_SQL.DESCRIBE_COLUMNS( context_id IN int, col_cnt OUT int, desc_t OUT dbe_sql.desc_tab )
Table 44 DBE_SQL.DESCRIBE_COLUMNS parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
col_cnt
INT
OUT
No
Number of columns returned
desc_t
DBE_SQL.DESC_TAB
OUT
No
Description of the returned column
- DBE_SQL.BIND_VARIABLE
This function is used to bind parameters. You are advised to use DBE_SQL.SQL_BIND_VARIABLE.
- DBE_SQL.SQL_SET_RESULTS_TYPE_C
This function is used to dynamically define a column of the array type. You are advised not to use it.
The prototype of the DBE_SQL.SQL_SET_RESULTS_TYPE_C function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.sql_set_results_type_c( context_id IN int, pos IN int, column_ref IN anyarray, cnt IN int, lower_bnd IN int, col_type IN anyelement, maxsize IN int )return integer;
Table 45 DBE_SQL.SQL_SET_RESULTS_TYPE_C parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYARRAY
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
col_type
ANYELEMENT
IN
No
Variable type corresponding to the returned array type
maxsize
INT
IN
No
Maximum length of the defined type
- DBE_SQL.SQL_GET_VALUES_C
This function is used to read a dynamically defined column value. You are advised not to use it.
The prototype of the DBE_SQL.SQL_GET_VALUES_C function is as follows:1 2 3 4 5 6
DBE_SQL.sql_get_values_c( context_id IN int, pos IN int, results_type INOUT anyarray, result_type IN anyelement )return anyarray;
Table 46 DBE_SQL.SQL_GET_VALUES_C parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Parameter position
results_type
ANYARRAY
INOUT
No
Obtained result
result_type
ANYELEMENT
IN
No
Type of the obtained result
- DBE_SQL.GET_VARIABLE_RESULT
This function is used to return the value of the bound OUT parameter and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_VARIABLE_RESULT function is as follows:1 2 3 4 5
DBE_SQL.get_variable_result( context_id IN int, pos IN VARCHAR2, column_value INOUT anyelement );
Table 47 DBE_SQL.GET_VARIABLE_RESULT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
column_value
ANYELEMENT
INOUT
No
Return value
- DBE_SQL.GET_VARIABLE_RESULT_CHAR
This function is used to return the value of the bound OUT parameter of the CHAR type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_VARIABLE_RESULT_CHAR function is as follows:1 2 3 4 5
DBE_SQL.get_variable_result_char( context_id IN int, pos IN VARCHAR2 ) RETURNS char
Table 48 DBE_SQL.GET_VARIABLE_RESULT_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
- DBE_SQL.GET_VARIABLE_RESULT_RAW
This function is used to return the value of the bound OUT parameter of the RAW type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_VARIABLE_RESULT_RAW function is as follows:1 2 3 4 5 6
CREATE OR REPLACE FUNCTION DBE_SQL.get_variable_result_raw( context_id IN int, pos IN VARCHAR2, value INOUT anyelement ) RETURNS anyelement
Table 49 DBE_SQL.GET_VARIABLE_RESULT_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
value
ANYELEMENT
INOUT
No
Return value
- DBE_SQL.GET_VARIABLE_RESULT_TEXT
This function is used to return the value of the bound OUT parameter of the TEXT type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_VARIABLE_RESULT_TEXT function is as follows:1 2 3 4 5
CREATE OR REPLACE FUNCTION DBE_SQL.get_variable_result_text( context_id IN int, pos IN VARCHAR2 ) RETURNS text
Table 50 DBE_SQL.GET_VARIABLE_RESULT_TEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
- DBE_SQL.GET_VARIABLE_RESULT_INT
This function is used to return the value of the bound OUT parameter of the INT type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_VARIABLE_RESULT_INT function is as follows:1 2 3 4 5 6
DBE_SQL.get_variable_result_int( context_id IN int, pos IN VARCHAR2, value INOUT anyelement ) RETURNS anyelement
Table 51 DBE_SQL.GET_VARIABLE_RESULT_INT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
value
ANYELEMENT
INOUT
No
Return value
- DBE_SQL.GET_ARRAY_RESULT_TEXT
This function is used to return the value of the bound OUT parameter of the TEXT array type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_ARRAY_RESULT_TEXT function is as follows:1 2 3 4 5
DBE_SQL.get_array_result_text( context_id IN int, pos IN VARCHAR2, column_value INOUT anyarray )
Table 52 DBE_SQL.GET_ARRAY_RESULT_TEXT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_ARRAY_RESULT_RAW
This function is used to return the value of the bound OUT parameter of the RAW array type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_ARRAY_RESULT_RAW function is as follows:1 2 3 4 5
DBE_SQL.get_array_result_raw( context_id IN int, pos IN VARCHAR2, column_value INOUT anyarray )
Table 53 DBE_SQL.GET_ARRAY_RESULT_RAW parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_ARRAY_RESULT_CHAR
This function is used to return the value of the bound OUT parameter of the CHAR array type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_ARRAY_RESULT_CHAR function is as follows:1 2 3 4 5
DBE_SQL.get_array_result_char( context_id IN int, pos IN VARCHAR2, column_value INOUT anyarray )
Table 54 DBE_SQL.GET_ARRAY_RESULT_CHAR parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.GET_ARRAY_RESULT_INT
This function is used to return the value of the bound OUT parameter of the INT array type and obtain the OUT parameter in a stored procedure.
The prototype of the DBE_SQL.GET_ARRAY_RESULT_INT function is as follows:1 2 3 4 5
DBE_SQL.get_array_result_int( context_id IN int, pos IN VARCHAR2, column_value INOUT anyarray )
Table 55 DBE_SQL.GET_ARRAY_RESULT_INT parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
VARCHAR2
IN
No
Name of the bound parameter
column_value
ANYARRAY
INOUT
No
Return value
- DBE_SQL.SQL_SET_TABLEOF_RESULTS_TYPE_C
Dynamically defines a column of the tableof type. You are advised not to use it.
The prototype of the DBE_SQL.SQL_SET_TABLEOF_RESULTS_TYPE_C function is as follows:1 2 3 4 5 6 7 8 9
DBE_SQL.SQL_SET_TABLEOF_RESULTS_TYPE_C( context_id IN int, pos IN int, column_ref IN anyindexbytable, cnt IN int, lower_bnd IN int, col_type IN anyelement, maxsize IN int )return integer;
Table 56 DBE_SQL.SQL_SET_TABLEOF_RESULTS_TYPE_C parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Position of a dynamically defined column in the query
column_ref
ANYINDEXBYTABLE
IN
No
Type of the returned array
cnt
INT
IN
No
Number of values obtained at a time
lower_bnd
INT
IN
No
Start index when an array is returned.
col_type
ANYELEMENT
IN
No
Variable type corresponding to the returned array type
maxsize
INT
IN
No
Maximum length of the defined type
- DBE_SQL.SQL_GET_TABLEOF_VALUES_C
Reads a dynamically defined column value of the tableof type. You are advised not to use it.
The function prototype of DBE_SQL.SQL_GET_TABLEOF_VALUES_C is as follows:1 2 3 4 5 6
DBE_SQL.SQL_GET_TABLEOF_VALUES_C( context_id IN int, pos IN int, results_type INOUT anyindexbytable, result_type IN anyelement )return anyindexbytable;
Table 57 DBE_SQL.SQL_GET_TABLEOF_VALUES_C parameters Parameter
Type
Input/Output Parameter
Can Be Empty
Description
context_id
INT
IN
No
ID of the cursor to be queried
pos
INT
IN
No
Parameter position
results_type
ANYINDEXBYTABLE
INOUT
No
Obtained result
result_type
ANYELEMENT
IN
No
Type of the obtained result
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
-- Example 1 -- Create a table and insert data into the table. CREATE TABLE test_desc_cols( id NUMBER, name VARCHAR2(50) ); INSERT INTO test_desc_cols(id, name) VALUES (1, 'xiaoming'); INSERT INTO test_desc_cols(id, name) VALUES (2, 'xiaohong'); INSERT INTO test_desc_cols(id, name) VALUES (3, 'xiaolan'); DECLARE context_id INTEGER; col_cnt INTEGER; v_id int; v_name varchar2; execute_ret INTEGER; BEGIN -- Open a cursor. context_id := DBE_SQL.REGISTER_CONTEXT(); -- Compile the cursor. DBE_SQL.SQL_SET_SQL(context_id, 'SELECT * FROM test_desc_cols', 2); -- Set the return value type of a column. DBE_SQL.SET_RESULT_TYPE(context_id, 1, v_id); DBE_SQL.SET_RESULT_TYPE(context_id, 2, v_name); execute_ret := DBE_SQL.SQL_RUN(context_id); loop exit when (DBE_SQL.NEXT_ROW(context_id) <= 0); -- Obtain values. DBE_SQL.GET_RESULT(context_id, 1, v_id); DBE_SQL.GET_RESULT(context_id, 2, v_name); -- Output the result. dbe_output.print_line('id:'|| v_id || ' name:' || v_name); end loop; DBE_SQL.SQL_UNREGISTER_CONTEXT(context_id); END; / -- Expected result: id:1 name:xiaoming id:2 name:xiaohong id:3 name:xiaolan ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table if exists test_desc_cols; DROP TABLE -- Example 2 CREATE OR REPLACE PROCEDURE test_square(n NUMBER, square OUT NUMBER) IS BEGIN square := n * n; END; / CREATE PROCEDURE DECLARE cur NUMBER; query varchar(2000); ret integer; n NUMBER; square Integer; BEGIN n := 2; cur := DBE_SQL.REGISTER_CONTEXT(); query := 'BEGIN test_square(:n_bnd, :square_bnd); END;'; DBE_SQL.SQL_SET_SQL(cur, query, 2); DBE_SQL.SQL_BIND_VARIABLE(cur, 'n_bnd', n); DBE_SQL.SQL_BIND_VARIABLE(cur, 'square_bnd', square); ret := DBE_SQL.SQL_RUN(cur); DBE_SQL.GET_VARIABLE_RESULT(cur, 'square_bnd', square); DBE_OUTPUT.PRINT_LINE('square = ' || square); DBE_SQL.SQL_UNREGISTER_CONTEXT(cur); END; / -- Expected result: square = 4 ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop PROCEDURE test_square; DROP PROCEDURE -- Example 3 -- Examples of executing DESCRIBE_COLUMNS, RUN_AND_NEXT, and LAST_ROW_COUNT -- Create a table and insert data into the table. CREATE TABLE test_desc_cols( id NUMBER, name VARCHAR2(50) ); INSERT INTO test_desc_cols(id, name) VALUES (1, 'xiaoming'); INSERT INTO test_desc_cols(id, name) VALUES (2, 'xiaohong'); INSERT INTO test_desc_cols(id, name) VALUES (3, 'xiaolan'); -- Create a stored procedure for printing column description information. CREATE OR REPLACE PROCEDURE print_rec( rec in DBE_SQL.DESC_REC )package AS BEGIN raise INFO 'col_type = %', rec.col_type; raise INFO 'col_name = %', rec.col_name; raise INFO 'col_name_len = %', rec.col_name_len; END; / CREATE PROCEDURE -- Verify functions. DECLARE context_id INTEGER; col_cnt INTEGER; rec_tab DBE_SQL.DESC_TAB; excute_ret INTEGER; nextrow_ret INTEGER; last_row_count INTEGER; BEGIN -- Open a cursor. context_id := DBE_SQL.REGISTER_CONTEXT(); -- Compile the cursor. DBE_SQL.SQL_SET_SQL(context_id, 'SELECT * FROM test_desc_cols', 2); -- Print the column description information. DBE_SQL.DESCRIBE_COLUMNS(context_id, col_cnt, rec_tab); FOR var IN 1..col_cnt LOOP print_rec(rec_tab(var)); END LOOP; -- Execute and obtain a row of data. excute_ret := DBE_SQL.RUN_AND_NEXT(context_id); -- Obtain a row of data. nextrow_ret := DBE_SQL.NEXT_ROW(context_id); -- Obtain the number of obtained data rows. last_row_count := DBE_SQL.LAST_ROW_COUNT; DBE_OUTPUT.PRINT_LINE('last_row_count = '|| last_row_count); DBE_SQL.SQL_UNREGISTER_CONTEXT(context_id); END; / -- Expected result: INFO: col_type = 1700 CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM INFO: col_name = id CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM INFO: col_name_len = 2 CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM INFO: col_type = 1043 CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM INFO: col_name = name CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM INFO: col_name_len = 4 CONTEXT: SQL statement "CALL print_rec(rec_tab[var])" PL/pgSQL function inline_code_block line 16 at PERFORM last_row_count = 2 ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table test_desc_cols; DROP TABLE -- Example 4 DROP TABLE if exists dbe_sql_tab; create table dbe_sql_tab(a char(30), b int, c text, d raw, e bytea, f text, g bool); insert into dbe_sql_tab values('aaa', 10, 'abcdefghijklmn', HEXTORAW('DEADBEEF'), 'a', 'abcdefghijklmn', true); DECLARE cursorid int; execute_ret int; query varchar(2000); err numeric; v_char char(30); v_int int; v_long text; v_long_len int; v_raw raw; v_raw_len int; v_bytea bytea; v_text text; BEGIN query := 'select * from dbe_sql_tab'; cursorid := DBE_SQL.register_context(); DBE_SQL.sql_set_sql(cursorid, query, 1); DBE_SQL.SET_RESULT_TYPE_CHAR(cursorid, 1, v_char, 30); DBE_SQL.SET_RESULT_TYPE_INT(cursorid, 2); DBE_SQL.SET_RESULT_TYPE_LONG(cursorid, 3); DBE_SQL.SET_RESULT_TYPE_RAW(cursorid, 4, v_raw, 68); DBE_SQL.SET_RESULT_TYPE_BYTEA(cursorid, 5, v_bytea, 68); DBE_SQL.SET_RESULT_TYPE_TEXT(cursorid, 6, 1024); execute_ret := DBE_SQL.sql_run(cursorid); loop exit when (DBE_SQL.next_row(cursorid) <= 0); DBE_SQL.GET_RESULT_CHAR(cursorid, 1, v_char); v_int := DBE_SQL.GET_RESULT_INT(cursorid, 2); DBE_SQL.GET_RESULT_LONG(cursorid, 3, 3, 3, v_long, v_long_len); DBE_SQL.GET_RESULT_RAW(cursorid, 4, v_raw, err, v_raw_len); v_bytea := DBE_SQL.GET_RESULT_BYTEA(cursorid, 5); v_text := DBE_SQL.GET_RESULT_TEXT(cursorid, 6); dbe_output.print_line('a:'|| v_char); dbe_output.print_line('b:'|| v_int); dbe_output.print_line('c:'|| v_long); dbe_output.print_line('d:'|| v_raw); raise info 'e:%', v_bytea; dbe_output.print_line('f:'|| v_text); end loop; DBE_SQL.sql_unregister_context(cursorid); END; / -- Expected result: a:aaa b:10 c:cde d:DEADBEEF INFO: e:\x61 f:abcdefghijklmn ANONYMOUS BLOCK EXECUTE DECLARE cursorid int; execute_ret int; query varchar(2000); BEGIN query := 'select * from dbe_sql_tab'; cursorid := DBE_SQL.register_context(); DBE_SQL.sql_set_sql(cursorid, query, 1); DBE_SQL.SET_RESULT_TYPE_UNKNOWN(cursorid, 7, 'boolean'); execute_ret := DBE_SQL.sql_run(cursorid); loop exit when (DBE_SQL.next_row(cursorid) <= 0); DBE_SQL.GET_RESULT_UNKNOWN(cursorid, 7, 'boolean'); end loop; DBE_SQL.sql_unregister_context(cursorid); END; / -- Expected result: ERROR: UnSupport data type for set_result_type(context: 8, pos: 7, 'boolean') CONTEXT: SQL statement "CALL pg_catalog.report_application_error('UnSupport data type for set_result_type(context: '||context_id||', pos: '||pos||', '||PG_CATALOG.QUOTE_LITERAL(col_type)||')')" PL/pgSQL function dbe_sql.set_result_type_unknown(integer,integer,text) line 8 at PERFORM SQL statement "CALL dbe_sql.set_result_type_unknown(cursorid,7,'boolean')" PL/pgSQL function inline_code_block line 10 at PERFORM -- Clean the environment. drop table dbe_sql_tab; DROP TABLE -- Example 5 drop table if exists dbe_sql_tab; create table dbe_sql_tab(a char(30), b raw); insert into dbe_sql_tab values('aaa', HEXTORAW('DEADBEEF')); DECLARE cursorid int; execute_ret int; query varchar(2000); v_char char(30); v_raw raw; BEGIN query := 'select * from dbe_sql_tab'; cursorid := DBE_SQL.register_context(); DBE_SQL.sql_set_sql(cursorid, query, 2); DBE_SQL.SET_RESULT_TYPE(cursorid, 1, v_char); DBE_SQL.SET_RESULT_TYPE_RAW(cursorid, 2, v_raw, 68); execute_ret := DBE_SQL.sql_run(cursorid); loop exit when (DBE_SQL.next_row(cursorid) <= 0); v_char := DBE_SQL.DBE_SQL_GET_RESULT_CHAR(cursorid, 1); v_raw := DBE_SQL.DBE_SQL_GET_RESULT_RAW(cursorid, 2); dbe_output.print_line('a:'|| v_char); dbe_output.print_line('b:'|| v_raw); end loop; DBE_SQL.sql_unregister_context(cursorid); END; / -- Expected result: a:aaa b:DEADBEEF ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table dbe_sql_tab; DROP TABLE -- Example 6 DECLARE cursorid int; execute_ret int; is_open boolean; BEGIN cursorid := DBE_SQL.register_context(); is_open := DBE_SQL.IS_ACTIVE(cursorid); dbe_output.print_line('is_open:' ||is_open); DBE_SQL.sql_unregister_context(cursorid); is_open := DBE_SQL.IS_ACTIVE(cursorid); dbe_output.print_line('is_open:' ||is_open); END; / -- Expected result: is_open:true is_open:false ANONYMOUS BLOCK EXECUTE -- Example 7 create table tbl(a integer ,b varchar(100)); CREATE TABLE DECLARE c integer; v1 integer[]; v2 varchar2[]; query varchar(2000); ret integer; begin c := dbe_sql.register_context(); query := 'insert into tbl(a,b) values(:v_1, :v_2);'; dbe_sql.sql_set_sql(c, query, 2); v1(1) := 1; v1(2) := 2; v2(1) := '1'; v2(2) := '2'; dbe_sql.sql_bind_array(c, 'v_1', v1); dbe_sql.sql_bind_array(c, 'v_2', v2); ret := dbe_sql.sql_run(c); dbe_sql.sql_unregister_context(c); end; / ANONYMOUS BLOCK EXECUTE select * from tbl order by a; -- Expected result: a | b ---+--- 1 | 1 2 | 2 (2 rows) -- Clean the environment. drop table tbl; DROP TABLE -- Example 8 -- Prerequisites drop table if exists dbe_sql_tab; create table dbe_sql_tab(a int, b text, c raw, d text, e char, f int); insert into dbe_sql_tab values(1, '9', '5', '13', 'a', 1); insert into dbe_sql_tab values(2, '9', '6', '14', 'b', 2); insert into dbe_sql_tab values(3, '7', '7', '15', 'c', 3); insert into dbe_sql_tab values(4, '6', '8', '16', 'd', 4); DECLARE query varchar(2000); context_id int; execute_ret int; v_id int; v_ints int[]; v_texts text[]; v_raws raw[]; v_byteas bytea[]; v_chars character[]; v_type int[]; BEGIN query := ' select * from dbe_sql_tab'; context_id := dbe_sql.register_context(); dbe_sql.sql_set_sql(context_id, query, 1); DBE_SQL.SET_RESULT_TYPE_INTS(context_id, 1, v_ints, 3, 1); DBE_SQL.SET_RESULT_TYPE_TEXTS(context_id, 2, v_texts, 3, 1, 1024); DBE_SQL.SET_RESULT_TYPE_RAWS(context_id, 3, v_raws, 3, 1, 1024); DBE_SQL.SET_RESULT_TYPE_BYTEAS(context_id, 4, v_byteas, 3, 1, 1024); DBE_SQL.SET_RESULT_TYPE_CHARS(context_id, 5, v_chars, 3, 1, 1024); DBE_SQL.SET_RESULTS_TYPE(context_id, 6, v_type, 3, 1); execute_ret := dbe_sql.sql_run(context_id); loop v_id := dbe_sql.next_row(context_id); v_ints := DBE_SQL.GET_RESULTS_INT(context_id, 1, v_ints); v_texts := DBE_SQL.GET_RESULTS_TEXT(context_id, 2, v_texts); v_raws := DBE_SQL.GET_RESULTS_RAW(context_id, 3, v_raws); v_byteas := DBE_SQL.GET_RESULTS_BYTEA(context_id, 4, v_byteas); v_chars := DBE_SQL.GET_RESULTS_CHAR(context_id, 5, v_chars); v_type := DBE_SQL.GET_RESULTS(context_id, 6, v_type); exit when(v_id != 3); end loop; FOR i IN v_ints.FIRST .. v_ints.LAST LOOP dbe_output.print_line('int' || i || ' = ' || v_ints[i]); END LOOP; FOR i IN v_texts.FIRST .. v_texts.LAST LOOP dbe_output.print_line('text' || i || ' = ' || v_texts[i]); END LOOP; FOR i IN v_raws.FIRST .. v_raws.LAST LOOP dbe_output.print_line('raw' || i || ' = ' || v_raws[i]); END LOOP; FOR i IN v_byteas.FIRST .. v_byteas.LAST LOOP dbe_output.print_line('bytea' || i || ' = ' || v_byteas[i]); END LOOP; FOR i IN v_chars.FIRST .. v_chars.LAST LOOP dbe_output.print_line('char' || i || ' = ' || v_chars[i]); END LOOP; FOR i IN v_type.FIRST .. v_type.LAST LOOP dbe_output.print_line('type' || i || ' = ' || v_type[i]); END LOOP; dbe_sql.sql_unregister_context(context_id); END; / -- Expected result: int1 = 1 int2 = 2 int3 = 3 int4 = 4 text1 = 9 text2 = 9 text3 = 7 text4 = 6 raw1 = 05 raw2 = 06 raw3 = 07 raw4 = 08 bytea1 = \x3133 bytea2 = \x3134 bytea3 = \x3135 bytea4 = \x3136 char1 = a char2 = b char3 = c char4 = d type1 = 1 type2 = 2 type3 = 3 type4 = 4 ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table if exists dbe_sql_tab; DROP TABLE -- Example 9 -- Prerequisites drop table if exists dbe_sql_tab; create table dbe_sql_tab(a int ,b int); insert into dbe_sql_tab values(1,3); DECLARE context_id int; type re_rssc is record (col_num int, desc_col dbe_sql.desc_tab); employer re_rssc; res re_rssc; d int; dd dbe_sql.desc_tab; query varchar(2000); BEGIN query := 'select * from dbe_sql_tab'; -- Open a cursor. context_id := dbe_sql.register_context(); -- Compile the cursor. dbe_sql.sql_set_sql(context_id, query, 1); -- Execute the cursor. res := dbe_sql.sql_describe_columns(context_id, d,dd); -- Output the result. dbe_output.print_line('col_num:' || res.col_num); dbe_output.print_line('col_type:' || res.desc_col[1].col_type); dbe_output.print_line('col_max_len:' || res.desc_col[1].col_max_len); dbe_output.print_line('col_name:' || res.desc_col[1].col_name); dbe_output.print_line('col_name_len:' || res.desc_col[1].col_name_len); dbe_output.print_line('col_schema_name:' || res.desc_col[1].col_schema_name); dbe_output.print_line('col_schema_name_len:' || res.desc_col[1].col_schema_name_len); dbe_output.print_line('col_precision:' || res.desc_col[1].col_precision); dbe_output.print_line('col_scale:' || res.desc_col[1].col_scale); dbe_output.print_line('col_charsetid:' || res.desc_col[1].col_charsetid); dbe_output.print_line('col_charsetform:' || res.desc_col[1].col_charsetform); dbe_output.print_line('col_null_ok:' || res.desc_col[1].col_null_ok); -- Close the cursor. dbe_sql.sql_unregister_context(context_id); END; / -- Expected result: col_num:2 col_type:23 col_max_len:4 col_name:a col_name_len:1 col_schema_name: col_schema_name_len:0 col_precision:0 col_scale:0 col_charsetid:0 col_charsetform:0 col_null_ok:true ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table if exists dbe_sql_tab; DROP TABLE -- Example 10 drop table if exists dbe_sql_tab; create table dbe_sql_tab(a int); insert into dbe_sql_tab values(1); insert into dbe_sql_tab values(2); insert into dbe_sql_tab values(3); DECLARE query varchar(2000); context_id int; execute_ret int; v_id int; v_ints int[]; i1 integer; BEGIN query := 'select * from dbe_sql_tab'; context_id := dbe_sql.register_context(); dbe_sql.sql_set_sql(context_id, query, 1); DBE_SQL.SQL_SET_RESULTS_TYPE_C(context_id, 1, v_ints, 3, 1, i1, 0); execute_ret := dbe_sql.sql_run(context_id); loop v_id := dbe_sql.next_row(context_id); v_ints := DBE_SQL.SQL_GET_VALUES_C(context_id, 1, v_ints, i1); exit when(v_id != 3); end loop; FOR i IN v_ints.FIRST .. v_ints.LAST LOOP dbe_output.print_line('int' || i || ' = ' || v_ints[i]); END LOOP; dbe_sql.sql_unregister_context(context_id); END; / -- Expected result: int1 = 1 int2 = 2 int3 = 3 ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop table if exists dbe_sql_tab; DROP TABLE -- Example 11 CREATE OR REPLACE PROCEDURE test_proc(out_int out Integer, out_char out char, out_raw out raw, out_text out text) IS BEGIN out_int := 1; out_char := 'a'; out_raw := 'b'; out_text := 'c'; END; / CREATE PROCEDURE DECLARE cur NUMBER; query varchar(2000); ret integer; v_int Integer; v_char char; v_raw raw; v_text text; BEGIN cur := DBE_SQL.REGISTER_CONTEXT(); query := 'BEGIN test_proc(:v_int, :v_char, :v_raw, :v_text); END;'; DBE_SQL.SQL_SET_SQL(cur, query, 2); DBE_SQL.SQL_BIND_VARIABLE(cur, 'v_int', v_int); DBE_SQL.SQL_BIND_VARIABLE(cur, 'v_char', v_char, 1024); DBE_SQL.SQL_BIND_VARIABLE(cur, 'v_raw', v_raw, 1024); DBE_SQL.SQL_BIND_VARIABLE(cur, 'v_text', v_text, 1024); ret := DBE_SQL.SQL_RUN(cur); DBE_SQL.GET_VARIABLE_RESULT_INT(cur, 'v_int', v_int); v_char := DBE_SQL.GET_VARIABLE_RESULT_CHAR(cur, 'v_char'); DBE_SQL.GET_VARIABLE_RESULT_RAW(cur, 'v_raw', v_raw); v_text := DBE_SQL.GET_VARIABLE_RESULT_TEXT(cur, 'v_text'); DBE_OUTPUT.PRINT_LINE('v_int = ' || v_int); DBE_OUTPUT.PRINT_LINE('v_char = ' || v_char); DBE_OUTPUT.PRINT_LINE('v_raw = ' || v_raw); DBE_OUTPUT.PRINT_LINE('v_text = ' || v_text); DBE_SQL.SQL_UNREGISTER_CONTEXT(cur); END; / -- Expected result: v_int = 1 v_char = a v_raw = 0B v_text = c ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop procedure test_proc; DROP PROCEDURE -- Example 12 CREATE OR REPLACE PROCEDURE test_proc(out_int out Integer[], out_char out char[], out_raw out raw[], out_text out text[]) IS BEGIN out_int(0) := 1; out_char(0) := 'a'; out_raw(0) := 'b'; out_text(0) := 'c'; END; / CREATE PROCEDURE DECLARE cur NUMBER; query varchar(2000); ret integer; v_int Integer[]; v_char char[]; v_raw raw[]; v_text text[]; BEGIN cur := DBE_SQL.REGISTER_CONTEXT(); query := 'call test_proc(:v_int, :v_char, :v_raw, :v_text);'; DBE_SQL.SQL_SET_SQL(cur, query, 1); DBE_SQL.SQL_BIND_ARRAY(cur, 'v_int', v_int); DBE_SQL.SQL_BIND_ARRAY(cur, 'v_char', v_char); DBE_SQL.SQL_BIND_ARRAY(cur, 'v_raw', v_raw); DBE_SQL.SQL_BIND_ARRAY(cur, 'v_text', v_text); ret := DBE_SQL.SQL_RUN(cur); DBE_SQL.GET_ARRAY_RESULT_INT(cur, 'v_int', v_int); DBE_SQL.GET_ARRAY_RESULT_CHAR(cur, 'v_char', v_char); DBE_SQL.GET_ARRAY_RESULT_RAW(cur, 'v_raw', v_raw); DBE_SQL.GET_ARRAY_RESULT_TEXT(cur, 'v_text', v_text); DBE_OUTPUT.PRINT_LINE('v_int = ' || v_int(0)); DBE_OUTPUT.PRINT_LINE('v_char = ' || v_char(0)); DBE_OUTPUT.PRINT_LINE('v_raw = ' || v_raw(0)); DBE_OUTPUT.PRINT_LINE('v_text = ' || v_text(0)); DBE_SQL.SQL_UNREGISTER_CONTEXT(cur); END; / -- Expected result: v_int = 1 v_char = a v_raw = 0B v_text = c ANONYMOUS BLOCK EXECUTE -- Clean the environment. drop PROCEDURE test_proc; DROP PROCEDURE |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot