Example Querying a System View
This section includes an example querying a system view.
Querying a System View
You can query a system view using procedures.
This example queries the USER_SOURCE
system view to examine the source code of procedure query_emp
from the example in Using IN and OUT Parameters. You must create that procedure before completing this example.
Command> SELECT SUBSTR (text, 1, LENGTH(text)-1)
FROM user_source
WHERE name = 'QUERY_EMP' AND type = 'PROCEDURE';
This produces the following output:
< PROCEDURE query_emp >
< (p_id IN employees.employee_id%TYPE, >
< p_name OUT employees.last_name%TYPE, >
< p_salary OUT employees.salary%TYPE) IS >
< BEGIN >
< SELECT last_name, salary INTO p_name, p_salary >
< FROM employees >
< WHERE employee_id = p_id; >
< END query_emp; >
9 rows found.
Note:
As with other USER_*
system views, all users have SELECT
privilege for the USER_SOURCE
system view.