demonstrates the use of DBMS_SQL to execute an ALTER SESSION statement.
SQL>
SQL> CREATE OR REPLACE PROCEDURE AlterSession(
2 p_SessionString IN VARCHAR2) AS
3
4 v_CursorID INTEGER;
5 v_Dummy INTEGER;
6 BEGIN
7 v_CursorID := DBMS_SQL.OPEN_CURSOR;
8
9 DBMS_SQL.PARSE(v_CursorID, p_SessionString, DBMS_SQL.NATIVE);
10 v_Dummy := DBMS_SQL.EXECUTE(v_CursorID);
11 END AlterSession;
12 /
Procedure created.
SQL>
SQL> column sysdate format a30
SQL> SELECT SYSDATE FROM dual;
SYSDATE
------------------------------
Jun 19, 2008 20:38:44
1 row selected.
SQL>
SQL> DECLARE
2 sqlString VARCHAR2(100);
3 BEGIN
4 sqlString := 'ALTER SESSION SET NLS_DATE_FORMAT = ' ||
5 '''Mon DD, YYYY HH24:MI:SS''';
6 AlterSession(sqlString);
7 END;
8 /
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT SYSDATE FROM dual;
SYSDATE
------------------------------
Jun 19, 2008 20:38:44
1 row selected.
SQL>
Related examples in the same category