A script-enabled browser is required for this page to function properly.

EXEC_SQL.LAST_SQL_FUNCTION_CODE built-in function

This procedure returns the last SQL function code, indicating the type of SQL statement. For a list of valid function codes, see your Programmer's Guide to the Oracle Call Interface.

Syntax


 FUNCTION EXEC_SQL.LAST_SQL_FUNCTION_CODE
 [connid IN CONNTYPE]
 RETURN PLS_INTEGER;

Parameter

Description

connid

Is the handle to the connection you want to use. If you do not specify a connection, EXEC_SQL.DEFAULT_CONNECTION retrieves the primary connection handle from the cache.

Returns

An integer.

Usage notes

Use this function immediately after parsing the SQL statement.

Example


/*
** In this procedure, a statement is passed in and executed. If the statement 
 is a select statement, then further processing is initiated to determine 
 the column characteristics.
*/

PROCEDURE eslastfunccode(sqlstr VARCHAR2) IS
connection_id EXEC_SQL.CONNTYPE;
cursor_number EXEC_SQL.CURSTYPE;
-- 
-- The values for the function codes is dependent on the RDBMS version.
--
 SELECTFUNCCODE PLS_INTEGER := 3;
 sql_str VARCHAR2(256);
 nColumns PLS_INTEGER := 0;
 nFunc PLS_INTEGER := 0;
 colName VARCHAR2(30);
 colLen PLS_INTEGER;
 colType PLS_INTEGER;
BEGIN
  connection_id := EXEC_SQL.OPEN_CONNECTION('connection_str');
  cursor_number := EXEC_SQL.OPEN_CURSOR(connection_id);
  EXEC_SQL.PARSE(connection_id, cursor_number, sql_str, exec_sql.V7);
  nIgnore := EXEC_SQL.EXECUTE(connection_id, cursor_number);
--
-- check what kind of function it is
--
  nFunc := EXEC_SQL.LAST_SQL_FUNCTION_CODE(connection_id);
IF (nFunc != SELECTFUNCCODE) THEN
 RETURN;
END IF;
-- 
-- proceed to obtain the column characteristics
--
LOOP
 nColumns := nColumns + 1;
BEGIN
  EXEC_SQL.DESCRIBE_COLUMN(connection_id, cursor_number, nColumns, colName, colLen, colType);
  TEXT_IO.PUT_LINE(' col= ' || nColumns || ' name ' || colName || ' len= ' || colLen || ' type ' || colType );
 EXCEPTION
  WHEN EXEC_SQL.INVALID_COLUMN_NUMBER THEN
 EXIT;
END;
END LOOP;
  EXEC_SQL.CLOSE_CURSOR(connection_id, cursor_number);
  EXEC_SQL.LCOSE_CONNECTION(connection_id); 
END;

See also

About the EXEC_SQL built-in package

EXEC_SQL built-in package