23: rc number; -- return code
24: found number;
25: begin
26: found := 0;
27: stmt_cursor := dbms_sql.open_cursor;
28: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
29: 'begin
30: select 1
31: into :found
34: and owner = upper(:item_owner);
35: exception
36: when others then
37: :found := 0;
38: end;', dbms_sql.v7);
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
35: exception
36: when others then
37: :found := 0;
38: end;', dbms_sql.v7);
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
36: when others then
37: :found := 0;
38: end;', dbms_sql.v7);
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
44: dbms_sql.close_cursor(stmt_cursor);
37: :found := 0;
38: end;', dbms_sql.v7);
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
44: dbms_sql.close_cursor(stmt_cursor);
45: return(found <> 0);
38: end;', dbms_sql.v7);
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
44: dbms_sql.close_cursor(stmt_cursor);
45: return(found <> 0);
46: end is_table;
39: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
44: dbms_sql.close_cursor(stmt_cursor);
45: return(found <> 0);
46: end is_table;
47:
40: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
41: dbms_sql.bind_variable(stmt_cursor, ':found', found);
42: rc := dbms_sql.execute(stmt_cursor);
43: dbms_sql.variable_value(stmt_cursor, ':found', found);
44: dbms_sql.close_cursor(stmt_cursor);
45: return(found <> 0);
46: end is_table;
47:
48: /********************************************************************/
56: rc number; -- return code
57: found number;
58: begin
59: found := 0;
60: stmt_cursor := dbms_sql.open_cursor;
61: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
62: 'begin
63: select 1
64: into :found
67: and owner = upper(:item_owner);
68: exception
69: when others then
70: :found := 0;
71: end;', dbms_sql.v7);
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
68: exception
69: when others then
70: :found := 0;
71: end;', dbms_sql.v7);
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
69: when others then
70: :found := 0;
71: end;', dbms_sql.v7);
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
77: dbms_sql.close_cursor(stmt_cursor);
70: :found := 0;
71: end;', dbms_sql.v7);
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
77: dbms_sql.close_cursor(stmt_cursor);
78: return(found <> 0);
71: end;', dbms_sql.v7);
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
77: dbms_sql.close_cursor(stmt_cursor);
78: return(found <> 0);
79: end is_view;
72: dbms_sql.bind_variable(stmt_cursor, ':item_owner', item_owner);
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
77: dbms_sql.close_cursor(stmt_cursor);
78: return(found <> 0);
79: end is_view;
80:
73: dbms_sql.bind_variable(stmt_cursor, ':item_name', item_name);
74: dbms_sql.bind_variable(stmt_cursor, ':found', found);
75: rc := dbms_sql.execute(stmt_cursor);
76: dbms_sql.variable_value(stmt_cursor, ':found', found);
77: dbms_sql.close_cursor(stmt_cursor);
78: return(found <> 0);
79: end is_view;
80:
81: /**************************************/
93: name all_synonyms.table_name%type;
94: owner all_synonyms.table_owner%type;
95: db_link all_synonyms.db_link%type;
96: begin
97: stmt_cursor := dbms_sql.open_cursor;
98: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
99: 'begin
100: select table_name, table_owner, db_link
101: into :name, :owner, :db_link
106: when others then
107: :name := NULL;
108: :owner := NULL;
109: :db_link := NULL;
110: end;', dbms_sql.v7);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
107: :name := NULL;
108: :owner := NULL;
109: :db_link := NULL;
110: end;', dbms_sql.v7);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
108: :owner := NULL;
109: :db_link := NULL;
110: end;', dbms_sql.v7);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
109: :db_link := NULL;
110: end;', dbms_sql.v7);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
110: end;', dbms_sql.v7);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
111: dbms_sql.bind_variable(stmt_cursor, ':csynonym', csynonym);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
119: dbms_sql.variable_value(stmt_cursor, ':db_link', db_link);
112: dbms_sql.bind_variable(stmt_cursor, ':cschema', cschema);
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
119: dbms_sql.variable_value(stmt_cursor, ':db_link', db_link);
120: o_name := name;
113: dbms_sql.bind_variable(stmt_cursor, ':name', name, 2000);
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
119: dbms_sql.variable_value(stmt_cursor, ':db_link', db_link);
120: o_name := name;
121: o_owner := owner;
114: dbms_sql.bind_variable(stmt_cursor, ':owner', owner, 2000);
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
119: dbms_sql.variable_value(stmt_cursor, ':db_link', db_link);
120: o_name := name;
121: o_owner := owner;
122: o_db_link := db_link;
115: dbms_sql.bind_variable(stmt_cursor, ':db_link', db_link, 2000);
116: rc := dbms_sql.execute(stmt_cursor);
117: dbms_sql.variable_value(stmt_cursor, ':name', name);
118: dbms_sql.variable_value(stmt_cursor, ':owner', owner);
119: dbms_sql.variable_value(stmt_cursor, ':db_link', db_link);
120: o_name := name;
121: o_owner := owner;
122: o_db_link := db_link;
123: return(name is NOT NULL or owner is NOT NULL or db_link is NOT NULL);
137: procowner varchar2(255);
138: procnamel constant number := 255;
139: procname varchar2(255);
140: begin
141: stmt_cursor := dbms_sql.open_cursor;
142: /* resolve name and compose the real package.procedure */
143: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
144: 'declare
145: part1 varchar2(255);
164: exception
165: when others then
166: :procowner := NULL;
167: :procname := NULL;
168: end;', dbms_sql.v7
169: );
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
166: :procowner := NULL;
167: :procname := NULL;
168: end;', dbms_sql.v7
169: );
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
167: :procname := NULL;
168: end;', dbms_sql.v7
169: );
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
168: end;', dbms_sql.v7
169: );
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
176: dbms_sql.close_cursor(stmt_cursor);
169: );
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
176: dbms_sql.close_cursor(stmt_cursor);
177: o_procowner := procowner;
170: dbms_sql.bind_variable(stmt_cursor, ':cname', cname);
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
176: dbms_sql.close_cursor(stmt_cursor);
177: o_procowner := procowner;
178: o_procname := procname;
171: dbms_sql.bind_variable(stmt_cursor, ':procowner', procowner, procownerl);
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
176: dbms_sql.close_cursor(stmt_cursor);
177: o_procowner := procowner;
178: o_procname := procname;
179: end name_resolve;
172: dbms_sql.bind_variable(stmt_cursor, ':procname', procname, procnamel);
173: rc := dbms_sql.execute(stmt_cursor);
174: dbms_sql.variable_value(stmt_cursor, ':procowner', procowner);
175: dbms_sql.variable_value(stmt_cursor, ':procname', procname);
176: dbms_sql.close_cursor(stmt_cursor);
177: o_procowner := procowner;
178: o_procname := procname;
179: end name_resolve;
180:
197: nm := substr(n, 1, (rc - 1));
198: else
199: nm := n;
200: end if;
201: stmt_cursor := dbms_sql.open_cursor;
202: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
203: 'select line, text
204: from all_source
205: where name = upper(:n)
203: 'select line, text
204: from all_source
205: where name = upper(:n)
206: and owner = upper(:o)
207: order by type, line', dbms_sql.v7);
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
204: from all_source
205: where name = upper(:n)
206: and owner = upper(:o)
207: order by type, line', dbms_sql.v7);
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
212: rc := dbms_sql.execute(stmt_cursor);
205: where name = upper(:n)
206: and owner = upper(:o)
207: order by type, line', dbms_sql.v7);
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
212: rc := dbms_sql.execute(stmt_cursor);
213: return(stmt_cursor);
206: and owner = upper(:o)
207: order by type, line', dbms_sql.v7);
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
212: rc := dbms_sql.execute(stmt_cursor);
213: return(stmt_cursor);
214: end open_source_cursor;
207: order by type, line', dbms_sql.v7);
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
212: rc := dbms_sql.execute(stmt_cursor);
213: return(stmt_cursor);
214: end open_source_cursor;
215:
208: dbms_sql.bind_variable(stmt_cursor, ':o', o);
209: dbms_sql.bind_variable(stmt_cursor, ':n', nm);
210: dbms_sql.define_column(stmt_cursor, 1, line);
211: dbms_sql.define_column(stmt_cursor, 2, text, 2000);
212: rc := dbms_sql.execute(stmt_cursor);
213: return(stmt_cursor);
214: end open_source_cursor;
215:
216: /************************************************************************/
221: line out number,
222: text out varchar2
223: ) return number is
224: begin
225: if (stmt_cursor >= 0 and dbms_sql.fetch_rows(stmt_cursor) > 0)
226: then
227: dbms_sql.column_value(stmt_cursor, 1, line);
228: dbms_sql.column_value(stmt_cursor, 2, text);
229: return(0);
223: ) return number is
224: begin
225: if (stmt_cursor >= 0 and dbms_sql.fetch_rows(stmt_cursor) > 0)
226: then
227: dbms_sql.column_value(stmt_cursor, 1, line);
228: dbms_sql.column_value(stmt_cursor, 2, text);
229: return(0);
230: else
231: return(-1);
224: begin
225: if (stmt_cursor >= 0 and dbms_sql.fetch_rows(stmt_cursor) > 0)
226: then
227: dbms_sql.column_value(stmt_cursor, 1, line);
228: dbms_sql.column_value(stmt_cursor, 2, text);
229: return(0);
230: else
231: return(-1);
232: end if;
236: /* Function to close cursor for all_source */
237: /*******************************************/
238: procedure close_source_cursor(stmt_cursor in out number) is
239: begin
240: dbms_sql.close_cursor(stmt_cursor);
241: end close_source_cursor;
242:
243: /******************************************************************/
244: /* Procedure to link back to the PL/SQL source for your procedure */
552: item_owner varchar2(255);
553:
554: dummy char(1);
555: begin
556: stmt_cursor := dbms_sql.open_cursor;
557: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
558: 'begin
559: dbms_utility.name_tokenize(:cobject,
560: :a, :b, :c, :dblink, :next_pos);
557: sys.dbms_sys_sql.parse_as_user(stmt_cursor,
558: 'begin
559: dbms_utility.name_tokenize(:cobject,
560: :a, :b, :c, :dblink, :next_pos);
561: end;', dbms_sql.v7);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
558: 'begin
559: dbms_utility.name_tokenize(:cobject,
560: :a, :b, :c, :dblink, :next_pos);
561: end;', dbms_sql.v7);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
559: dbms_utility.name_tokenize(:cobject,
560: :a, :b, :c, :dblink, :next_pos);
561: end;', dbms_sql.v7);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
560: :a, :b, :c, :dblink, :next_pos);
561: end;', dbms_sql.v7);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
561: end;', dbms_sql.v7);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
562: dbms_sql.bind_variable(stmt_cursor, ':cobject', cobject);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
563: dbms_sql.bind_variable(stmt_cursor, ':a', a, al);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
564: dbms_sql.bind_variable(stmt_cursor, ':b', b, bl);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
565: dbms_sql.bind_variable(stmt_cursor, ':c', c, cl);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
566: dbms_sql.bind_variable(stmt_cursor, ':dblink', dblink, dblinkl);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
574: dbms_sql.close_cursor(stmt_cursor);
567: dbms_sql.bind_variable(stmt_cursor, ':next_pos', next_pos);
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
574: dbms_sql.close_cursor(stmt_cursor);
575:
568: rc := dbms_sql.execute(stmt_cursor);
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
574: dbms_sql.close_cursor(stmt_cursor);
575:
576: if (c is not null)
569: dbms_sql.variable_value(stmt_cursor, ':a', a);
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
574: dbms_sql.close_cursor(stmt_cursor);
575:
576: if (c is not null)
577: then
570: dbms_sql.variable_value(stmt_cursor, ':b', b);
571: dbms_sql.variable_value(stmt_cursor, ':c', c);
572: dbms_sql.variable_value(stmt_cursor, ':dblink', dblink);
573: dbms_sql.variable_value(stmt_cursor, ':next_pos', next_pos);
574: dbms_sql.close_cursor(stmt_cursor);
575:
576: if (c is not null)
577: then
578: /* For a table, we should see AT MOST owner.table */
664:
665: col_counter := 0;
666: if (ccolumns = '*')
667: then
668: col_cursor := dbms_sql.open_cursor;
669: sys.dbms_sys_sql.parse_as_user(col_cursor,
670: 'select column_name, data_type '||
671: 'from all_tab_columns '||
672: 'where table_name = '''||upper(table_resolved)||''' '||
671: 'from all_tab_columns '||
672: 'where table_name = '''||upper(table_resolved)||''' '||
673: ' and owner = '''||upper(owner_resolved)||''' '||
674: 'order by column_id',
675: dbms_sql.v7);
676:
677: dbms_sql.define_column(col_cursor, 1, col_name, 255);
678: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
679:
673: ' and owner = '''||upper(owner_resolved)||''' '||
674: 'order by column_id',
675: dbms_sql.v7);
676:
677: dbms_sql.define_column(col_cursor, 1, col_name, 255);
678: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
679:
680: ignore := dbms_sql.execute(col_cursor);
681:
674: 'order by column_id',
675: dbms_sql.v7);
676:
677: dbms_sql.define_column(col_cursor, 1, col_name, 255);
678: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
679:
680: ignore := dbms_sql.execute(col_cursor);
681:
682: loop
676:
677: dbms_sql.define_column(col_cursor, 1, col_name, 255);
678: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
679:
680: ignore := dbms_sql.execute(col_cursor);
681:
682: loop
683: if (dbms_sql.fetch_rows(col_cursor) > 0)
684: then
679:
680: ignore := dbms_sql.execute(col_cursor);
681:
682: loop
683: if (dbms_sql.fetch_rows(col_cursor) > 0)
684: then
685: dbms_sql.column_value(col_cursor, 2, col_dtype);
686: dbms_sql.column_value(col_cursor, 1, col_name);
687:
681:
682: loop
683: if (dbms_sql.fetch_rows(col_cursor) > 0)
684: then
685: dbms_sql.column_value(col_cursor, 2, col_dtype);
686: dbms_sql.column_value(col_cursor, 1, col_name);
687:
688: col_counter := col_counter + 1;
689: col_dtypes(col_counter) := col_dtype;
682: loop
683: if (dbms_sql.fetch_rows(col_cursor) > 0)
684: then
685: dbms_sql.column_value(col_cursor, 2, col_dtype);
686: dbms_sql.column_value(col_cursor, 1, col_name);
687:
688: col_counter := col_counter + 1;
689: col_dtypes(col_counter) := col_dtype;
690: col_names(col_counter) := col_name;
691: else
692: exit;
693: end if;
694: end loop;
695: dbms_sql.close_cursor(col_cursor);
696: else
697: col_decode := '';
698: col_in_clause := '';
699: col_loc_out := 0;
719: else
720: -- remove trailing ',' from col_in_clause
721: col_in_clause := substr(col_in_clause, 1, length(col_in_clause)-1);
722:
723: col_cursor := dbms_sql.open_cursor;
724: sys.dbms_sys_sql.parse_as_user(col_cursor,
725: 'select column_name, data_type, '||
726: 'decode(column_name'||col_decode||') '||
727: 'from all_tab_columns '||
728: 'where table_name = '''||upper(table_resolved)||''' '||
729: ' and owner = '''||upper(owner_resolved)||''' '||
730: ' and column_name in ('||col_in_clause||') '||
731: 'order by 3',
732: dbms_sql.v7);
733:
734: dbms_sql.define_column(col_cursor, 1, col_name, 255);
735: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
730: ' and column_name in ('||col_in_clause||') '||
731: 'order by 3',
732: dbms_sql.v7);
733:
734: dbms_sql.define_column(col_cursor, 1, col_name, 255);
735: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
737:
738: ignore := dbms_sql.execute(col_cursor);
731: 'order by 3',
732: dbms_sql.v7);
733:
734: dbms_sql.define_column(col_cursor, 1, col_name, 255);
735: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
737:
738: ignore := dbms_sql.execute(col_cursor);
739:
732: dbms_sql.v7);
733:
734: dbms_sql.define_column(col_cursor, 1, col_name, 255);
735: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
737:
738: ignore := dbms_sql.execute(col_cursor);
739:
740: new_row := (dbms_sql.fetch_rows(col_cursor) > 0);
734: dbms_sql.define_column(col_cursor, 1, col_name, 255);
735: dbms_sql.define_column(col_cursor, 2, col_dtype, 9);
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
737:
738: ignore := dbms_sql.execute(col_cursor);
739:
740: new_row := (dbms_sql.fetch_rows(col_cursor) > 0);
741: for i in 1..col_counter
742: loop
736: dbms_sql.define_column(col_cursor, 3, col_num, 9);
737:
738: ignore := dbms_sql.execute(col_cursor);
739:
740: new_row := (dbms_sql.fetch_rows(col_cursor) > 0);
741: for i in 1..col_counter
742: loop
743: if (new_row) AND (i = col_num)
744: then
741: for i in 1..col_counter
742: loop
743: if (new_row) AND (i = col_num)
744: then
745: dbms_sql.column_value(col_cursor, 2, col_dtype);
746: col_dtypes(i) := col_dtype;
747: new_row := (dbms_sql.fetch_rows(col_cursor) > 0);
748: else
749: col_dtypes(i) := 'VARCHAR2';
743: if (new_row) AND (i = col_num)
744: then
745: dbms_sql.column_value(col_cursor, 2, col_dtype);
746: col_dtypes(i) := col_dtype;
747: new_row := (dbms_sql.fetch_rows(col_cursor) > 0);
748: else
749: col_dtypes(i) := 'VARCHAR2';
750: end if;
751: end loop;
748: else
749: col_dtypes(i) := 'VARCHAR2';
750: end if;
751: end loop;
752: dbms_sql.close_cursor(col_cursor);
753: end if;
754: end if;
755:
756: nnum_cols := col_counter;
844: loop
845: col_sizes(i) := NULL;
846: end loop;
847: else
848: crsr := dbms_sql.open_cursor;
849: sys.dbms_sys_sql.parse_as_user(crsr,
850: 'select '||ccolumns||' from '||ctable||' '||cclauses,
851: dbms_sql.v7);
852:
847: else
848: crsr := dbms_sql.open_cursor;
849: sys.dbms_sys_sql.parse_as_user(crsr,
850: 'select '||ccolumns||' from '||ctable||' '||cclauses,
851: dbms_sql.v7);
852:
853: for col_counter in 1..nnum_cols
854: loop
855: if (col_counter <= num_aliases)
861:
862: col_dtype := col_dtypes(col_counter);
863: if (col_dtype = 'VARCHAR2' OR col_dtype = 'CHAR')
864: then
865: dbms_sql.define_column(crsr, col_counter, vc_var, 2000);
866: else if (col_dtype = 'NUMBER')
867: then
868: dbms_sql.define_column(crsr,
869: col_counter, number_var);
864: then
865: dbms_sql.define_column(crsr, col_counter, vc_var, 2000);
866: else if (col_dtype = 'NUMBER')
867: then
868: dbms_sql.define_column(crsr,
869: col_counter, number_var);
870: else if (col_dtype = 'DATE')
871: then
872: dbms_sql.define_column(crsr,
868: dbms_sql.define_column(crsr,
869: col_counter, number_var);
870: else if (col_dtype = 'DATE')
871: then
872: dbms_sql.define_column(crsr,
873: col_counter, date_var);
874: else if (col_dtype = 'LONG')
875: then
876: dbms_sql.define_column(crsr, col_counter,
872: dbms_sql.define_column(crsr,
873: col_counter, date_var);
874: else if (col_dtype = 'LONG')
875: then
876: dbms_sql.define_column(crsr, col_counter,
877: long_var, 32767);
878: else if (col_dtype = 'RAW')
879: then
880: dbms_sql.define_column_raw(crsr, col_counter,
876: dbms_sql.define_column(crsr, col_counter,
877: long_var, 32767);
878: else if (col_dtype = 'RAW')
879: then
880: dbms_sql.define_column_raw(crsr, col_counter,
881: raw_var, 255);
882: end if;
883: end if;
884: end if;
885: end if;
886: end if;
887: end loop;
888:
889: ignore := dbms_sql.execute(crsr);
890:
891: row_count := 0;
892: if (nrow_min is NOT NULL)
893: then
892: if (nrow_min is NOT NULL)
893: then
894: while (row_count < nrow_min - 1)
895: loop
896: if (dbms_sql.fetch_rows(crsr) > 0)
897: then row_count := row_count+1;
898: else exit;
899: end if;
900: end loop;
902:
903: while (nrow_max is NULL) or (row_count < nrow_max)
904: loop
905:
906: if dbms_sql.fetch_rows(crsr) > 0
907: then
908: row_count := row_count+1;
909:
910: for col_counter in 1..nnum_cols
911: loop
912: col_dtype := col_dtypes(col_counter);
913: if (col_dtype = 'VARCHAR2' OR col_dtype = 'CHAR')
914: then
915: dbms_sql.column_value(crsr, col_counter, vc_var);
916: col_size := nvl(lengthb(vc_var),0);
917: else if (col_dtype = 'NUMBER')
918: then
919: dbms_sql.column_value(crsr, col_counter,
915: dbms_sql.column_value(crsr, col_counter, vc_var);
916: col_size := nvl(lengthb(vc_var),0);
917: else if (col_dtype = 'NUMBER')
918: then
919: dbms_sql.column_value(crsr, col_counter,
920: number_var);
921: col_size := nvl(lengthb(number_var),0);
922: else if (col_dtype = 'DATE')
923: then
920: number_var);
921: col_size := nvl(lengthb(number_var),0);
922: else if (col_dtype = 'DATE')
923: then
924: dbms_sql.column_value(crsr, col_counter,
925: date_var);
926: col_size := nvl(lengthb(date_var),0);
927: else if (col_dtype = 'LONG')
928: then
925: date_var);
926: col_size := nvl(lengthb(date_var),0);
927: else if (col_dtype = 'LONG')
928: then
929: dbms_sql.column_value(crsr, col_counter,
930: long_var);
931: col_size := nvl(lengthb(long_var),0);
932: else if (col_dtype = 'RAW')
933: then
930: long_var);
931: col_size := nvl(lengthb(long_var),0);
932: else if (col_dtype = 'RAW')
933: then
934: dbms_sql.column_value_raw(crsr,
935: col_counter,
936: raw_var);
937: col_size := nvl(lengthb(raw_var),0);
938: else
960: exit;
961: end if;
962: end loop;
963:
964: dbms_sql.close_cursor(crsr);
965: end if;
966: end;
967:
968: /* PRINT_HEADINGS will print the column headings for a table. */
1033:
1034: row_count number;
1035: more_rows boolean := TRUE;
1036: begin
1037: table_cursor := dbms_sql.open_cursor;
1038: sys.dbms_sys_sql.parse_as_user(table_cursor,
1039: 'select '||ccolumns||' from '||ctable||' '||cclauses,
1040: dbms_sql.v7);
1041:
1036: begin
1037: table_cursor := dbms_sql.open_cursor;
1038: sys.dbms_sys_sql.parse_as_user(table_cursor,
1039: 'select '||ccolumns||' from '||ctable||' '||cclauses,
1040: dbms_sql.v7);
1041:
1042: for col_counter in 1..nnum_cols
1043: loop
1044: col_dtype := col_dtypes(col_counter);
1043: loop
1044: col_dtype := col_dtypes(col_counter);
1045: if (col_dtype = 'VARCHAR2' OR col_dtype = 'CHAR')
1046: then
1047: dbms_sql.define_column(table_cursor, col_counter, vc_var, 2000);
1048: elsif (col_dtype = 'NUMBER') then
1049: dbms_sql.define_column(table_cursor, col_counter, number_var);
1050: elsif (col_dtype = 'DATE') then
1051: dbms_sql.define_column(table_cursor, col_counter, date_var);
1045: if (col_dtype = 'VARCHAR2' OR col_dtype = 'CHAR')
1046: then
1047: dbms_sql.define_column(table_cursor, col_counter, vc_var, 2000);
1048: elsif (col_dtype = 'NUMBER') then
1049: dbms_sql.define_column(table_cursor, col_counter, number_var);
1050: elsif (col_dtype = 'DATE') then
1051: dbms_sql.define_column(table_cursor, col_counter, date_var);
1052: elsif (col_dtype = 'LONG') then
1053: dbms_sql.define_column(table_cursor, col_counter, long_var, 32767); /* Kelly: not sure over 2000 is valid */
1047: dbms_sql.define_column(table_cursor, col_counter, vc_var, 2000);
1048: elsif (col_dtype = 'NUMBER') then
1049: dbms_sql.define_column(table_cursor, col_counter, number_var);
1050: elsif (col_dtype = 'DATE') then
1051: dbms_sql.define_column(table_cursor, col_counter, date_var);
1052: elsif (col_dtype = 'LONG') then
1053: dbms_sql.define_column(table_cursor, col_counter, long_var, 32767); /* Kelly: not sure over 2000 is valid */
1054: elsif (col_dtype = 'RAW') then
1055: dbms_sql.define_column_raw(table_cursor, col_counter, raw_var, 32767);
1049: dbms_sql.define_column(table_cursor, col_counter, number_var);
1050: elsif (col_dtype = 'DATE') then
1051: dbms_sql.define_column(table_cursor, col_counter, date_var);
1052: elsif (col_dtype = 'LONG') then
1053: dbms_sql.define_column(table_cursor, col_counter, long_var, 32767); /* Kelly: not sure over 2000 is valid */
1054: elsif (col_dtype = 'RAW') then
1055: dbms_sql.define_column_raw(table_cursor, col_counter, raw_var, 32767);
1056: end if;
1057: end loop;
1051: dbms_sql.define_column(table_cursor, col_counter, date_var);
1052: elsif (col_dtype = 'LONG') then
1053: dbms_sql.define_column(table_cursor, col_counter, long_var, 32767); /* Kelly: not sure over 2000 is valid */
1054: elsif (col_dtype = 'RAW') then
1055: dbms_sql.define_column_raw(table_cursor, col_counter, raw_var, 32767);
1056: end if;
1057: end loop;
1058:
1059: ignore := dbms_sql.execute(table_cursor);
1055: dbms_sql.define_column_raw(table_cursor, col_counter, raw_var, 32767);
1056: end if;
1057: end loop;
1058:
1059: ignore := dbms_sql.execute(table_cursor);
1060:
1061: row_count := 0;
1062: if (nrow_min is NOT NULL)
1063: then
1062: if (nrow_min is NOT NULL)
1063: then
1064: while (row_count < nrow_min - 1)
1065: loop
1066: if (dbms_sql.fetch_rows(table_cursor) > 0)
1067: then row_count := row_count+1;
1068: else exit;
1069: end if;
1070: end loop;
1072:
1073: while (nrow_max is NULL) or (row_count < nrow_max)
1074: loop
1075:
1076: if dbms_sql.fetch_rows(table_cursor) > 0
1077: then
1078: row_count := row_count+1;
1079:
1080: tableRowOpen(row_string, ntable_type);
1083: loop
1084: col_dtype := col_dtypes(col_counter);
1085: if (col_dtype = 'VARCHAR2' OR col_dtype = 'CHAR')
1086: then
1087: dbms_sql.column_value(table_cursor, col_counter, vc_var);
1088: tableData(vc_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1089: elsif (col_dtype = 'NUMBER') then
1090: dbms_sql.column_value(table_cursor, col_counter,number_var);
1091: tableData(number_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1086: then
1087: dbms_sql.column_value(table_cursor, col_counter, vc_var);
1088: tableData(vc_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1089: elsif (col_dtype = 'NUMBER') then
1090: dbms_sql.column_value(table_cursor, col_counter,number_var);
1091: tableData(number_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1092: elsif (col_dtype = 'DATE') then
1093: dbms_sql.column_value(table_cursor, col_counter, date_var);
1094: tableData(date_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1089: elsif (col_dtype = 'NUMBER') then
1090: dbms_sql.column_value(table_cursor, col_counter,number_var);
1091: tableData(number_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1092: elsif (col_dtype = 'DATE') then
1093: dbms_sql.column_value(table_cursor, col_counter, date_var);
1094: tableData(date_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1095: elsif (col_dtype = 'LONG') then
1096: dbms_sql.column_value(table_cursor, col_counter,long_var);
1097: tableData(long_var, col_sizes(col_counter),'LEFT', row_string, ntable_type);
1092: elsif (col_dtype = 'DATE') then
1093: dbms_sql.column_value(table_cursor, col_counter, date_var);
1094: tableData(date_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1095: elsif (col_dtype = 'LONG') then
1096: dbms_sql.column_value(table_cursor, col_counter,long_var);
1097: tableData(long_var, col_sizes(col_counter),'LEFT', row_string, ntable_type);
1098: elsif (col_dtype = 'RAW') then
1099: dbms_sql.column_value_raw(table_cursor, col_counter, raw_var);
1100: tableData(raw_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1095: elsif (col_dtype = 'LONG') then
1096: dbms_sql.column_value(table_cursor, col_counter,long_var);
1097: tableData(long_var, col_sizes(col_counter),'LEFT', row_string, ntable_type);
1098: elsif (col_dtype = 'RAW') then
1099: dbms_sql.column_value_raw(table_cursor, col_counter, raw_var);
1100: tableData(raw_var, col_sizes(col_counter), 'LEFT', row_string, ntable_type);
1101: else
1102: tableData('Not Printable', col_sizes(col_counter),'LEFT', row_string, ntable_type);
1103: end if;
1117: tableNoData('LEFT', row_string, nnum_cols, ntable_width, ntable_type);
1118: tableRowClose(row_string, ntable_type);
1119: else
1120: if (more_rows)
1121: then more_rows := dbms_sql.fetch_rows(table_cursor) > 0;
1122: end if;
1123: end if;
1124:
1125: dbms_sql.close_cursor(table_cursor);
1121: then more_rows := dbms_sql.fetch_rows(table_cursor) > 0;
1122: end if;
1123: end if;
1124:
1125: dbms_sql.close_cursor(table_cursor);
1126:
1127: return more_rows;
1128: end;
1129:
1142:
1143: htp.formHidden('ctable', ctable);
1144: htp.formHidden('COLS', 'DUMMY');
1145:
1146: cols_cursor := dbms_sql.open_cursor;
1147: sys.dbms_sys_sql.parse_as_user(cols_cursor,
1148: 'select column_name from all_tab_columns where table_name = upper(:t)
1149: and owner = upper(:o)',
1150: dbms_sql.v7);
1146: cols_cursor := dbms_sql.open_cursor;
1147: sys.dbms_sys_sql.parse_as_user(cols_cursor,
1148: 'select column_name from all_tab_columns where table_name = upper(:t)
1149: and owner = upper(:o)',
1150: dbms_sql.v7);
1151: dbms_sql.bind_variable(cols_cursor, ':t', table_resolved);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1147: sys.dbms_sys_sql.parse_as_user(cols_cursor,
1148: 'select column_name from all_tab_columns where table_name = upper(:t)
1149: and owner = upper(:o)',
1150: dbms_sql.v7);
1151: dbms_sql.bind_variable(cols_cursor, ':t', table_resolved);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1148: 'select column_name from all_tab_columns where table_name = upper(:t)
1149: and owner = upper(:o)',
1150: dbms_sql.v7);
1151: dbms_sql.bind_variable(cols_cursor, ':t', table_resolved);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1156: if (dbms_sql.fetch_rows(cols_cursor) > 0)
1149: and owner = upper(:o)',
1150: dbms_sql.v7);
1151: dbms_sql.bind_variable(cols_cursor, ':t', table_resolved);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1156: if (dbms_sql.fetch_rows(cols_cursor) > 0)
1157: then
1150: dbms_sql.v7);
1151: dbms_sql.bind_variable(cols_cursor, ':t', table_resolved);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1156: if (dbms_sql.fetch_rows(cols_cursor) > 0)
1157: then
1158: dbms_sql.column_value(cols_cursor, 1, col_name);
1152: dbms_sql.bind_variable(cols_cursor, ':o', owner_resolved);
1153: dbms_sql.define_column(cols_cursor, 1, col_name, 2000);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1156: if (dbms_sql.fetch_rows(cols_cursor) > 0)
1157: then
1158: dbms_sql.column_value(cols_cursor, 1, col_name);
1159: htp.formCheckbox('COLS', col_name);
1160: htp.print(col_name);
1154: ignore := dbms_sql.execute(cols_cursor);
1155: loop
1156: if (dbms_sql.fetch_rows(cols_cursor) > 0)
1157: then
1158: dbms_sql.column_value(cols_cursor, 1, col_name);
1159: htp.formCheckbox('COLS', col_name);
1160: htp.print(col_name);
1161: htp.nl;
1162: else
1162: else
1163: exit;
1164: end if;
1165: end loop;
1166: dbms_sql.close_cursor(cols_cursor);
1167: htp.formSubmit(NULL,'Execute Query');
1168: end;
1169:
1170: function tablePrint(ctable in varchar2,
1481: procedure bv( c in integer, n in varchar2, v in varchar2 )
1482: is
1483: begin
1484: if ( n is NOT NULL ) then
1485: dbms_sql.bind_variable( c, n, v );
1486: end if;
1487: end bv;
1488:
1489:
1509: status integer;
1510: begin
1511: for i in 1 .. 255 loop
1512: begin
1513: dbms_sql.define_column( p_theCursor, i, columnValue, 2000 );
1514: colCnt := colCnt + 1;
1515: exception
1516: when others then
1517: if ( sqlcode = -1007 ) then
1520: raise;
1521: end if;
1522: end;
1523: end loop;
1524: status := dbms_sql.execute(p_theCursor);
1525: return colCnt;
1526: end bind_outputs;
1527:
1528:
1649: if ( upper( substr( ltrim( theQuery ), 1, 6 ) ) <> 'SELECT' ) then
1650: raise INVALID_QUERY;
1651: end if;
1652: --
1653: theCursor := dbms_sql.open_cursor;
1654: sys.dbms_sys_sql.parse_as_user( theCursor, theQuery, dbms_sql.native );
1655: --
1656: bv( theCursor, bv1Name, bv1Value );
1657: bv( theCursor, bv2Name, bv2Value );
1650: raise INVALID_QUERY;
1651: end if;
1652: --
1653: theCursor := dbms_sql.open_cursor;
1654: sys.dbms_sys_sql.parse_as_user( theCursor, theQuery, dbms_sql.native );
1655: --
1656: bv( theCursor, bv1Name, bv1Value );
1657: bv( theCursor, bv2Name, bv2Value );
1658: bv( theCursor, bv3Name, bv3Value );
1703: colCnt := bind_outputs(p_theCursor);
1704: --
1705: while (recCnt < p_max_rows)
1706: loop
1707: exit when (dbms_sql.fetch_rows(p_theCursor) <= 0);
1708: recIx := recIx + 1;
1709: if (recIx > p_skip_rec)
1710: then
1711: recCnt := recCnt + 1;
1711: recCnt := recCnt + 1;
1712: htp.tableRowOpen;
1713: for i in 1..colCnt
1714: loop
1715: dbms_sql.column_value(p_theCursor, i, columnValue);
1716: format_cell(columnValue, p_format_numbers);
1717: end loop;
1718: htp.tableRowClose;
1719: end if;
1717: end loop;
1718: htp.tableRowClose;
1719: end if;
1720: end loop;
1721: dbms_sql.close_cursor(tmpCursor);
1722: p_reccnt := recCnt;
1723: return(recCnt >= p_max_rows);
1724: exception
1725: when others then
1722: p_reccnt := recCnt;
1723: return(recCnt >= p_max_rows);
1724: exception
1725: when others then
1726: if dbms_sql.is_open(p_theCursor) then
1727: dbms_sql.close_cursor(tmpCursor);
1728: end if;
1729: raise;
1730: end cellsprint_fn;
1723: return(recCnt >= p_max_rows);
1724: exception
1725: when others then
1726: if dbms_sql.is_open(p_theCursor) then
1727: dbms_sql.close_cursor(tmpCursor);
1728: end if;
1729: raise;
1730: end cellsprint_fn;
1731:
1877: htp.formSelectOpen( cname => p_cname,
1878: nsize => p_nsize,
1879: cattributes => ite( p_multiple,'multiple',NULL) );
1880: loop
1881: exit when ( dbms_sql.fetch_rows(p_theCursor) <= 0 );
1882: dbms_sql.column_value( p_theCursor, 1, value );
1883: dbms_sql.column_value( p_theCursor, 2, visible );
1884: dbms_sql.column_value( p_theCursor, 3, selected );
1885: htp.formSelectOption( cvalue => visible,
1878: nsize => p_nsize,
1879: cattributes => ite( p_multiple,'multiple',NULL) );
1880: loop
1881: exit when ( dbms_sql.fetch_rows(p_theCursor) <= 0 );
1882: dbms_sql.column_value( p_theCursor, 1, value );
1883: dbms_sql.column_value( p_theCursor, 2, visible );
1884: dbms_sql.column_value( p_theCursor, 3, selected );
1885: htp.formSelectOption( cvalue => visible,
1886: cselected => ite( selected IS NULL, NULL, 'SELECTED' ),
1879: cattributes => ite( p_multiple,'multiple',NULL) );
1880: loop
1881: exit when ( dbms_sql.fetch_rows(p_theCursor) <= 0 );
1882: dbms_sql.column_value( p_theCursor, 1, value );
1883: dbms_sql.column_value( p_theCursor, 2, visible );
1884: dbms_sql.column_value( p_theCursor, 3, selected );
1885: htp.formSelectOption( cvalue => visible,
1886: cselected => ite( selected IS NULL, NULL, 'SELECTED' ),
1887: cattributes => 'value="' || value || '"' );
1880: loop
1881: exit when ( dbms_sql.fetch_rows(p_theCursor) <= 0 );
1882: dbms_sql.column_value( p_theCursor, 1, value );
1883: dbms_sql.column_value( p_theCursor, 2, visible );
1884: dbms_sql.column_value( p_theCursor, 3, selected );
1885: htp.formSelectOption( cvalue => visible,
1886: cselected => ite( selected IS NULL, NULL, 'SELECTED' ),
1887: cattributes => 'value="' || value || '"' );
1888: end loop;
2080: l_dates(0) := NULL;
2081: l_text(0) := NULL;
2082: l_link(0) := NULL;
2083:
2084: dbms_sql.define_column( p_cursor, 1, l_dates(0) );
2085: dbms_sql.define_column( p_cursor, 2, l_text(0), 2000 );
2086: dbms_sql.define_column( p_cursor, 3, l_link(0), 2000 );
2087:
2088: l_cnt := dbms_sql.execute( p_cursor );
2081: l_text(0) := NULL;
2082: l_link(0) := NULL;
2083:
2084: dbms_sql.define_column( p_cursor, 1, l_dates(0) );
2085: dbms_sql.define_column( p_cursor, 2, l_text(0), 2000 );
2086: dbms_sql.define_column( p_cursor, 3, l_link(0), 2000 );
2087:
2088: l_cnt := dbms_sql.execute( p_cursor );
2089: l_cnt := 0;
2082: l_link(0) := NULL;
2083:
2084: dbms_sql.define_column( p_cursor, 1, l_dates(0) );
2085: dbms_sql.define_column( p_cursor, 2, l_text(0), 2000 );
2086: dbms_sql.define_column( p_cursor, 3, l_link(0), 2000 );
2087:
2088: l_cnt := dbms_sql.execute( p_cursor );
2089: l_cnt := 0;
2090:
2084: dbms_sql.define_column( p_cursor, 1, l_dates(0) );
2085: dbms_sql.define_column( p_cursor, 2, l_text(0), 2000 );
2086: dbms_sql.define_column( p_cursor, 3, l_link(0), 2000 );
2087:
2088: l_cnt := dbms_sql.execute( p_cursor );
2089: l_cnt := 0;
2090:
2091: loop
2092: exit when ( dbms_sql.fetch_rows( p_cursor ) <= 0 );
2088: l_cnt := dbms_sql.execute( p_cursor );
2089: l_cnt := 0;
2090:
2091: loop
2092: exit when ( dbms_sql.fetch_rows( p_cursor ) <= 0 );
2093: dbms_sql.column_value( p_cursor, 1, l_curr_date );
2094: if (l_yyyymon is null)
2095: then
2096: l_yyyymon := to_char(l_curr_date, 'YYYYMON');
2089: l_cnt := 0;
2090:
2091: loop
2092: exit when ( dbms_sql.fetch_rows( p_cursor ) <= 0 );
2093: dbms_sql.column_value( p_cursor, 1, l_curr_date );
2094: if (l_yyyymon is null)
2095: then
2096: l_yyyymon := to_char(l_curr_date, 'YYYYMON');
2097: end if;
2103: l_cnt := 0;
2104: l_yyyymon := to_char(l_curr_date, 'YYYYMON');
2105: end if;
2106: l_dates(l_cnt) := l_curr_date;
2107: dbms_sql.column_value( p_cursor, 2, l_text(l_cnt) );
2108: dbms_sql.column_value( p_cursor, 3, l_link(l_cnt) );
2109: l_cnt := l_cnt+1;
2110: end loop;
2111:
2104: l_yyyymon := to_char(l_curr_date, 'YYYYMON');
2105: end if;
2106: l_dates(l_cnt) := l_curr_date;
2107: dbms_sql.column_value( p_cursor, 2, l_text(l_cnt) );
2108: dbms_sql.column_value( p_cursor, 3, l_link(l_cnt) );
2109: l_cnt := l_cnt+1;
2110: end loop;
2111:
2112: if (l_cnt > 0)