Note
This view is available starting with V2.2.30.
Purpose
This view displays the text source of stored objects owned by the current user. The columns are the same as those in ALL_SOURCE, except the OWNER column.
Applicability
This view is applicable only to OceanBase Database in Oracle-compatible mode.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| NAME | VARCHAR2(30) | NO | The name of the object. |
| TYPE | VARCHAR2(12) | NO | The type of the object. |
| LINE | NUMBER | NO | The line number in the source code corresponding to the TEXT field. |
| TEXT | CLOB | NO | The source code of the current line. |
| ORIGIN_CON_ID | NUMBER(38) | NO | The tenant ID of the tenant to which the object belongs. If the object is a system package, the value is 0. |
Sample query
Query the text source of stored objects owned by the current user and display the first two records.
obclient [SYS]> SELECT * FROM SYS.USER_SOURCE WHERE ROWNUM<=2\G
The query result is as follows:
*************************** 1. row ***************************
NAME: DEPT_CTX_PKG
TYPE: PACKAGE BODY
LINE: 1
TEXT: PACKAGE BODY dept_ctx_pkg IS
PROCEDURE set_dept(dept_val VARCHAR2) IS
BEGIN
DBMS_SESSION.SET_CONTEXT('dept_ctx', 'CURRENT_DEPT', dept_val); -- The namespace and context name must be consistent<sup>1</sup>
END;
END;
ORIGIN_CON_ID: 1004
*************************** 2. row ***************************
NAME: DEPT_CTX_PKG
TYPE: PACKAGE
LINE: 1
TEXT: PACKAGE dept_ctx_pkg IS
PROCEDURE set_dept(dept_val VARCHAR2);
END;
ORIGIN_CON_ID: 1004
2 rows in set
References
Query the text source of all stored objects in the current tenant: DBA_SOURCE
Query the text source of all stored objects accessible by the current user: ALL_SOURCE