Executes the SQL statement at a specified cursor.
FUNCTION EXEC_SQL.Execute
([Connid IN CONNTYPE],
Curs_Id IN CURSTYPE)
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 Oracle Developer connection handle from the cache. |
Curs_Id | Is the cursor handle to the SQL statement you want to execute. |
The return value is only valid for INSERT, UPDATE and DELETE statements. For other statements, including DDL, ignore the return value because it is undefined.
PROCEDURE getData IS
connection_id EXEC_SQL.CONNTYPE;
cursorID EXEC_SQL.CURSTYPE;
sqlstr VARCHAR2(1000);
loc_ename VARCHAR2(30);
loc_eno NUMBER;
loc_hiredate DATE;
nIgn PLS_INTEGER;
...
BEGIN
connection_id := EXEC_SQL.OPEN_CONNECTION(connect_str);
cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
sqlstr := 'select ename, empno, hiredate from emp ';
EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':bn', input_empno);
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, loc_ename, 30);
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, loc_eno);
EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 3, loc_hiredate);
--
-- after parsing, and calling BIND_VARIABLE and DEFINE_COLUMN, if necessary, you
-- are ready to execute the statement. Note that all information about the
-- statement and its result set is encapsulated in the cursor referenced as cursorID.
--
nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
...
END;