DBMS_LOCK Package
Execution
Execute DBMS_LOCK.sql as follows to use DBMS_LOCK package.
% gsql sys gliese --as sysdba --import $GOLDILOCKS_HOME/admin/packages/DBMS_LOCK.sql
Package Routines
SLEEP Procedure
It is a procedure which pauses the session for the specified time.
Procedure Definition
PROCEDURE SLEEP( seconds IN NATIVE_INTEGER )
Parameters
Parameter | Description |
|---|---|
seconds | It is the time of pausing a session. (Seconds) The value of seconds should be 0 or bigger. |
Example
gSQL> DECLARE V1 VARCHAR(20); BEGIN SELECT TO_CHAR( SYSTIME, 'HH24:MI:SS' ) INTO V1 FROM DUAL; DBMS_OUTPUT.PUT_LINE( 'CURRENT TIME = ' || V1 ); DBMS_LOCK.SLEEP( 3 ); DBMS_OUTPUT.PUT_LINE( 'DBMS_LOCK.SLEEP( 3 ) '); SELECT TO_CHAR( SYSTIME, 'HH24:MI:SS' ) INTO V1 FROM DUAL; DBMS_OUTPUT.PUT_LINE( 'CURRENT TIME = ' || V1 ); END; / CURRENT TIME = 11:53:09 DBMS_LOCK.SLEEP( 3 ) CURRENT TIME = 11:53:12 Anonymous PL block executed.
DBMS_OUTPUT Package
Execution
Execute DBMS_OUTPUT.sql as follows to use DBMS_OUTPUT Package.
% gsql sys gliese --as sysdba --import $GOLDILOCKS_HOME/admin/packages/DBMS_OUTPUT.sql
Package Routines
DISABLE Procedure
It disables the message logging feature. All previously logged messages are disposed.
Procedure Definition
PROCEDURE DISABLE
Example
gSQL> BEGIN DBMS_OUTPUT.DISABLE; DBMS_OUTPUT.PUT_LINE( 'DBMS_OUTPUT() Message' ); END; / Anonymous PL block executed.
ENABLE Procedure
It is a procedure which enables the message logging feature with a given buffer size. If it is already enabled, all messages are disposed and a new buffer is created.
Procedure Definition
PROCEDURE ENABLE( buffer_size IN NATIVE_INTEGER := 20000 )
Parameters
Parameter | Description |
|---|---|
buffer_size | It is a buffer size and the default size is 20000 bytes. If buffer_size is not specified or is NULL, then the buffer size is 20000 bytes. |
Example
gSQL> BEGIN DBMS_OUTPUT.ENABLE; DBMS_OUTPUT.PUT_LINE( 'DBMS_OUTPUT() Message' ); END; / DBMS_OUTPUT() Message Anonymous PL block executed.
GET_LINE Procedure
It returns a oldest message line which has not been read among the messages stored in the buffer.
Procedure Definition
PROCEDURE GET_LINE( line OUT VARCHAR(4000),
status OUT NATIVE_INTEGER )Parameters
Parameter | Description |
|---|---|
line | It reads a line excluding newline character from a buffer, and returns it. |
status | If the message exists, then it returns 0. If it does not exist, then it returns 1. |
Example
gSQL> var msg VARCHAR(100);
gSQL> var status INTEGER;
gSQL> BEGIN
DBMS_OUTPUT.PUT_LINE( 'DBMS_OUTPUT() Message' );
DBMS_OUTPUT.GET_LINE( :msg, :status );
END;
/
Anonymous PL block executed.
gSQL> \print msg
MSG
----------------------
DBMS_OUTPUT() Message
gSQL> \print status
STATUS
------
0NEW_LINE Procedure
It stores a newline character in the buffer.
Procedure Definition
PROCEDURE NEW_LINE
Example
gSQL> BEGIN DBMS_OUTPUT.PUT( 'DBMS_OUTPUT()' ); DBMS_OUTPUT.PUT( ' Message' ); DBMS_OUTPUT.NEW_LINE; END; / DBMS_OUTPUT() Message Anonymous PL block executed.
PUT Procedure
It stores the message which is created with the given expression in the buffer.
Procedure Definition
PROCEDURE PUT( item IN VARCHAR(4000) )
Parameters
Parameter | Description |
|---|---|
item | It is an expression to be stored in the buffer without a newline character. |
Example
gSQL> var msg VARCHAR(100);
gSQL> var status INTEGER;
gSQL> BEGIN
DBMS_OUTPUT.PUT( 'DBMS_OUTPUT()' );
DBMS_OUTPUT.PUT( ' Message' );
DBMS_OUTPUT.NEW_LINE;
DBMS_OUTPUT.GET_LINE( :msg, :status );
END;
/
Anonymous PL block executed.
gSQL> \print msg
MSG
---------------------
DBMS_OUTPUT() Message
gSQL> \print status
STATUS
------
0PUT_LINE Procedure
It adds the last newline character to the message created with the given expression, and stores it in the buffer.
Procedure Definition
PROCEDURE PUT_LINE( item IN VARCHAR(4000) )
Parameters
Parameter | Description |
|---|---|
item | It is an expression to be stored in the buffer including a newline character. |
Example
gSQL> BEGIN DBMS_OUTPUT.PUT_LINE( 'DBMS_OUTPUT()' ); DBMS_OUTPUT.PUT_LINE( ' Message' ); END; / DBMS_OUTPUT() Message Anonymous PL block executed.
SET_LOG Procedure
It is simultaneously output on the file in the given path when logging the message.
Procedure Definition
PROCEDURE SET_LOG( file_path IN VARCHAR(4000),
permission IN NATIVE_INTEGER := 600 )Parameters
Parameter | Description |
|---|---|
file_path | It is the file path where the message will be logged. If the file path is a relative path, then it looks for the target file under the directory corresponding to <SYSTEM_LOGGER DIR> property. |
permission | The default permission is 600. It specifies the permission of the file. |
Example
gSQL> BEGIN
DBMS_OUTPUT.SET_LOG('output.log', 600);
DBMS_OUTPUT.PUT_LINE( 'DBMS_OUTPUT() Message' );
END;
/
DBMS_OUTPUT() Message
Anonymous PL block executed.
gSQL> !cat $GOLDILOCKS_DATA/trc/output.log
DBMS_OUTPUT() MessageDBMS_SQL Package
Execution
Execute DBMS_SQL.sql as follows to use DBMS_SQL package.
% gsql sys gliese --as sysdba --import $GOLDILOCKS_HOME/admin/packages/DBMS_SQL.sql
Package Routines
RETURN_RESULT Procedure
It returns the query result which was executed through the ref cursor to the client application.
Procedure Definition
PROCEDURE RETURN_RESULT( rc IN SYS_REFCURSOR )
Parameters
Parameter | Description |
|---|---|
rc | It is the reference cursor for the query result. |
Example
gSQL> DECLARE
rc1 SYS_REFCURSOR;
BEGIN
OPEN rc1 FOR SELECT SESSION_ID(), SESSION_SERIAL(), SESSION_USER() FROM DUAL;
DBMS_SQL.RETURN_RESULT( rc1 );
END;
/
Anonymous PL block executed.
ResultSet #1
SESSION_ID() SESSION_SERIAL() SESSION_USER()
------------ ---------------- --------------
31 13 TESTDBMS_STANDARD Package
Execution
Execute DBMS_STANDARD.sql as follows to use DBMS_STANDARD package.
% gsql sys gliese --as sysdba --import $GOLDILOCKS_HOME/admin/packages/DBMS_STANDARD.sql
Package Routines
RAISE_APPLICATION_ERROR Procedure
It raises an arbitrary user exception.
Procedure Definition
PROCEDURE RAISE_APPLICATION_ERROR( error_code IN NATIVE_INTEGER,
error_message IN VARCHAR(4000),
stack_flag IN BOOLEAN := FALSE )Parameters
Parameter | Description |
|---|---|
error_code | It is an arbitrary error code specified by a user. The value between -20000 ~ -20999 is allowed. |
error_message | It is the error message corresponding the user-specified error code. |
stack_flag | The default value is FALSE. It the parameter is TRUE, then the error is accumulated on the existing error stack. If it is FALSE, then it substitutes the existing error. |
Example
gSQL> DECLARE
V1 INTEGER;
BEGIN
V1 := 100/0;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20000, 'custom error message', TRUE);
END;
/
ERR-2F000(20000): custom error message
ERR-22012(12122): divisor is equal to zero :
V1 := 100/0;
*
ERROR at line 4: