forked from awslabs/amazon-redshift-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_get_stored_proc_params.sql
32 lines (32 loc) · 1.33 KB
/
v_get_stored_proc_params.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**********************************************************************************************
Purpose: List all stored procedures with their input parameters
History:
2020-04-15 joeharris76 Created
**********************************************************************************************/
CREATE OR REPLACE VIEW admin.v_get_stored_proc_params
AS
WITH arguments
AS (SELECT oid, arg_num
, arg_names[arg_num] AS arg_name
, arg_types[arg_num - 1] AS arg_type
FROM (SELECT GENERATE_SERIES(1, arg_count) AS arg_num
, arg_names, arg_types, oid
FROM (SELECT oid
, proargnames AS arg_names
, proargtypes AS arg_types
, pronargs AS arg_count
FROM pg_proc
WHERE proowner != 1
AND prolang = 100356 ) t) t)
SELECT n.nspname AS schema_name
, p.proname AS proc_name
, p.oid::INT AS proc_id
, a.arg_num AS order
, NVL(a.arg_name, '') AS parameter
, FORMAT_TYPE(a.arg_type, NULL) AS data_type
FROM pg_proc p
LEFT JOIN pg_namespace n ON n.oid = p.pronamespace
LEFT JOIN arguments a ON a.oid = p.oid
WHERE p.proowner != 1
AND p.prolang = 100356
ORDER BY 1,2,3,4;