Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 1f8aebe

Browse files
committed
Added Oracle describe function feature
1 parent a695509 commit 1f8aebe

File tree

1 file changed

+68
-97
lines changed

1 file changed

+68
-97
lines changed

SQLTools.sublime-settings

Lines changed: 68 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,51 @@
7777
"execute": {
7878
"options": []
7979
},
80-
"desc": {
81-
"query": "select '|' || quote_ident(table_schema)||'.'||quote_ident(table_name) ||'|' as tblname from information_schema.tables where table_schema not in ('pg_catalog', 'information_schema') order by table_schema = current_schema() desc, table_schema, table_name",
82-
"options": ["--tuples-only", "--no-psqlrc"]
80+
"show records": {
81+
"query": "select * from {0} limit {1};",
82+
"options": []
8383
},
8484
"desc table": {
8585
"query": "\\d+ {0}",
8686
"options": []
8787
},
88-
"show records": {
89-
"query": "select * from {0} limit {1}",
88+
"desc function": {
89+
"query": "\\sf {0}",
90+
"options": []
91+
},
92+
"explain plan": {
93+
"query": "explain analyze {0};",
9094
"options": []
9195
},
96+
"desc": {
97+
"query": "select '|' || quote_ident(table_schema)||'.'||quote_ident(table_name) ||'|' as tblname from information_schema.tables where table_schema not in ('pg_catalog', 'information_schema') order by table_schema = current_schema() desc, table_schema, table_name;",
98+
"options": ["--tuples-only", "--no-psqlrc"]
99+
},
92100
"columns": {
93-
"query": "select '|' || quote_ident(table_name) || '.' || quote_ident(column_name) || '|' from information_schema.columns where table_schema not in ('pg_catalog', 'information_schema') order by table_name, ordinal_position",
101+
"query": "select '|' || quote_ident(table_name) || '.' || quote_ident(column_name) || '|' from information_schema.columns where table_schema not in ('pg_catalog', 'information_schema') order by table_name, ordinal_position;",
94102
"options": ["--tuples-only", "--no-psqlrc"]
95103
},
96104
"functions": {
97-
"query": "select '|' || quote_ident(n.nspname)||'.'||quote_ident(f.proname) || '(' || pg_get_function_identity_arguments(f.oid) || ')' || '|' as funname from pg_catalog.pg_proc as f inner join pg_catalog.pg_namespace as n on n.oid = f.pronamespace where f.proisagg = false and n.nspname not in ('pg_catalog', 'information_schema')",
105+
"query": "select '|' || quote_ident(n.nspname)||'.'||quote_ident(f.proname) || '(' || pg_get_function_identity_arguments(f.oid) || ')' || '|' as funname from pg_catalog.pg_proc as f inner join pg_catalog.pg_namespace as n on n.oid = f.pronamespace where f.proisagg = false and n.nspname not in ('pg_catalog', 'information_schema');",
98106
"options": ["--tuples-only", "--no-psqlrc"]
99-
},
100-
"desc function": {
101-
"query": "\\sf {0}",
102-
"options": []
103-
},
104-
"explain plan": {
105-
"query": "explain {0};",
106-
"options": []
107107
}
108108
}
109109
},
110110
"oracle": {
111111
"options": ["-S"],
112-
"before": [],
112+
"before": [
113+
"SET LINESIZE 32767",
114+
"SET WRAP OFF",
115+
"SET PAGESIZE 0",
116+
"SET EMBEDDED ON",
117+
"SET TRIMOUT ON",
118+
"SET TRIMSPOOL ON",
119+
"SET TAB OFF",
120+
"SET SERVEROUT ON",
121+
"SET NULL '@'",
122+
"SET COLSEP '|'",
123+
"SET SQLBLANKLINES ON"
124+
],
113125
"after": [],
114126
"env_optional": {
115127
"NLS_LANG": "{nls_lang}"
@@ -120,111 +132,70 @@
120132
"options": [],
121133
"before": [
122134
// "SET TIMING ON",
123-
"SET LINESIZE 32767",
124-
"SET PAGESIZE 0",
125-
"SET EMBEDDED ON",
126-
"SET WRAP OFF",
127-
"SET TAB OFF",
128-
"SET TRIMOUT ON",
129-
"SET TRIMSPOOL ON",
130-
"SET NULL '@'",
131-
"SET COLSEP '|'",
132-
"SET FEEDBACK ON",
133-
"SET SERVEROUT ON",
134-
"SET SQLBLANKLINES ON"
135+
"SET FEEDBACK ON"
135136
]
136137
},
137-
"desc" : {
138-
"query": "select owner || '.' || name as obj from (select owner, table_name as name from all_tables union all select owner, view_name as name from all_views) o where owner not in ('ANONYMOUS','APPQOSSYS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 'MDSYS','MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST','WKSYS', 'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM','SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'XS$NULL','PUBLIC');",
138+
"show records": {
139+
"query": "select * from {0} where rownum <= {1};",
139140
"options": [],
140141
"before": [
141-
"SET LINESIZE 32767",
142-
"SET PAGESIZE 0",
143-
"SET EMBEDDED ON",
144-
"SET WRAP OFF",
145-
"SET HEADING OFF",
146-
"SET FEEDBACK OFF",
147-
"SET TRIMOUT ON"
142+
"SET FEEDBACK ON"
148143
]
149144
},
150-
"columns": {
151-
"query": "select table_name || '.' || column_name as obj from (select c.table_name, c.column_name, t.owner from all_tab_columns c inner join all_tables t on c.owner = t.owner and c.table_name = t.table_name union all select c.table_name, c.column_name, t.owner from all_tab_columns c inner join all_views t on c.owner = t.owner and c.table_name = t.view_name) o where owner not in ('ANONYMOUS','APPQOSSYS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 'MDSYS','MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST','WKSYS', 'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM','SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'XS$NULL','PUBLIC');",
145+
"desc table": {
146+
"query": "desc {0};",
152147
"options": [],
153148
"before": [
154-
"SET LINESIZE 32767",
155-
"SET PAGESIZE 0",
156-
"SET EMBEDDED ON",
157-
"SET WRAP OFF",
158-
"SET HEADING OFF",
159-
"SET FEEDBACK OFF",
160-
"SET TRIMOUT ON"
149+
"SET LINESIZE 80", // override for readability
150+
"SET WRAP ON", // override for readability
151+
"SET FEEDBACK ON"
161152
]
162153
},
163-
"functions": {
164-
"query": "select case when object_type = 'PACKAGE' then object_name||'.'||procedure_name else owner || '.' || object_name end || '()' as obj from all_procedures where object_type in ('FUNCTION','PROCEDURE','PACKAGE') and owner = sys_context('USERENV', 'CURRENT_SCHEMA');",
154+
"explain plan": {
155+
"query": "explain plan for {0};\nselect plan_table_output from table(dbms_xplan.display());",
165156
"options": [],
166157
"before": [
167-
"SET LINESIZE 32767",
168-
"SET PAGESIZE 0",
169-
"SET EMBEDDED ON",
170-
"SET WRAP OFF",
171-
"SET HEADING OFF",
172-
"SET FEEDBACK OFF",
173-
"SET TRIMOUT ON"
158+
"SET FEEDBACK ON"
174159
]
175160
},
176-
"desc table": {
177-
"query": "desc {0};",
161+
"desc function": {
162+
"query": "select text from all_source where type in ('FUNCTION', 'PROCEDURE', 'PACKAGE', 'PACKAGE BODY') and name = nvl(substr(ltrim('{0}', sys_context('USERENV', 'CURRENT_SCHEMA') || '.' ), 0, instr(ltrim('{0}', sys_context('USERENV', 'CURRENT_SCHEMA') || '.' ), '.')-1), ltrim('{0}', sys_context('USERENV', 'CURRENT_SCHEMA') || '.' )) and owner = sys_context('USERENV', 'CURRENT_SCHEMA') order by type, line;",
178163
"options": [],
179164
"before": [
180-
"SET LINESIZE 80", // altered for readability
181-
"SET PAGESIZE 0",
182-
"SET EMBEDDED ON",
183-
"SET WRAP OFF",
184-
"SET TAB OFF",
185-
"SET TRIMOUT ON",
186-
"SET TRIMSPOOL ON",
187-
"SET NULL '@'",
188-
"SET COLSEP '|'",
189-
"SET FEEDBACK ON",
190-
"SET SERVEROUT ON",
191-
"SET SQLBLANKLINES ON"
165+
"SET SERVEROUT OFF", // override
166+
"SET NULL ''", // override
167+
"SET HEADING OFF",
168+
"SET FEEDBACK OFF"
192169
]
193170
},
194-
"show records": {
195-
"query": "select * from {0} WHERE ROWNUM <= {1};",
171+
"desc" : {
172+
"query": "select owner || '.' || name as obj from (select owner, table_name as name from all_tables union all select owner, view_name as name from all_views) o where owner not in ('ANONYMOUS','APPQOSSYS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 'MDSYS','MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST','WKSYS', 'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM','SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'XS$NULL','PUBLIC');",
196173
"options": [],
197174
"before": [
198-
"SET LINESIZE 32767",
199-
"SET PAGESIZE 0",
200-
"SET EMBEDDED ON",
201-
"SET WRAP OFF",
202-
"SET TAB OFF",
203-
"SET TRIMOUT ON",
204-
"SET TRIMSPOOL ON",
205-
"SET NULL '@'",
206-
"SET COLSEP '|'",
207-
"SET FEEDBACK ON",
208-
"SET SERVEROUT ON",
209-
"SET SQLBLANKLINES ON"
175+
"SET SERVEROUT OFF", // override
176+
"SET NULL ''", // override
177+
"SET HEADING OFF",
178+
"SET FEEDBACK OFF"
210179
]
211180
},
212-
"explain plan": {
213-
"query": "explain plan for {0};\nselect plan_table_output from table(dbms_xplan.display());",
181+
"columns": {
182+
"query": "select table_name || '.' || column_name as obj from (select c.table_name, c.column_name, t.owner from all_tab_columns c inner join all_tables t on c.owner = t.owner and c.table_name = t.table_name union all select c.table_name, c.column_name, t.owner from all_tab_columns c inner join all_views t on c.owner = t.owner and c.table_name = t.view_name) o where owner not in ('ANONYMOUS','APPQOSSYS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 'MDSYS','MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST','WKSYS', 'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM','SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'XS$NULL','PUBLIC');",
183+
"options": [],
184+
"before": [
185+
"SET SERVEROUT OFF", // override
186+
"SET NULL ''", // override
187+
"SET HEADING OFF",
188+
"SET FEEDBACK OFF"
189+
]
190+
},
191+
"functions": {
192+
"query": "select case when object_type = 'PACKAGE' then object_name||'.'||procedure_name else owner || '.' || object_name end || '()' as obj from all_procedures where object_type in ('FUNCTION','PROCEDURE','PACKAGE') and not (object_type = 'PACKAGE' and procedure_name is null) and owner = sys_context('USERENV', 'CURRENT_SCHEMA');",
214193
"options": [],
215194
"before": [
216-
"SET LINESIZE 32767",
217-
"SET PAGESIZE 0",
218-
"SET EMBEDDED ON",
219-
"SET WRAP OFF",
220-
"SET TAB OFF",
221-
"SET TRIMOUT ON",
222-
"SET TRIMSPOOL ON",
223-
"SET NULL '@'",
224-
"SET COLSEP '|'",
225-
"SET FEEDBACK ON",
226-
"SET SERVEROUT ON",
227-
"SET SQLBLANKLINES ON"
195+
"SET SERVEROUT OFF", // override
196+
"SET NULL ''", // override
197+
"SET HEADING OFF",
198+
"SET FEEDBACK OFF"
228199
]
229200
}
230201
}

0 commit comments

Comments
 (0)