Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Oracle/Apache pl/sql package modification
Hi oracle misc's. I could use a little advice.
I have a package (please see below) that is run to generate html based on table contents. The submitting page allows the user to select the a table (different package for each table), a search term, a search type ( =, like, etc). We would like to now add instance to that as well. Links have been created in the home instance to point to the same tables in like instances (instances reflecting the dev/qa/prod model). The task is to modify these packages to be able to incorporate a from and where so that the result will now indicate an instance as well as the origional information.
I was thinking of using an IN and possibily a temporary table. Is there
anyway
a Boolean can be set during the duplicate toss of a join?
This all seems like it's getting far more complicated than what it will
return
for us, is there a better all-around way to do this (package calling a sp,
maybe?)
Thanks
CREATE OR REPLACE PACKAGE dmcoluq AS
PROCEDURE showSQL
(qnwhere IN VARCHAR2);
PROCEDURE showSelect
(qnfrom IN VARCHAR2,
qnwhere IN VARCHAR2);
PROCEDURE runQuery
(qName IN VARCHAR2 DEFAULT NULL, matchType IN VARCHAR2 DEFAULT 'BEGINSWITH', showSQLTop IN BOOLEAN DEFAULT FALSE, showSQLBottom IN BOOLEAN DEFAULT TRUE, showStatsTop IN BOOLEAN DEFAULT TRUE, showStatsBottom IN BOOLEAN DEFAULT FALSE);
PROCEDURE runSQL
(theSQL IN VARCHAR2);
PROCEDURE exeSQL
(theSQL IN VARCHAR2);
END dmcoluq;
/
CREATE OR REPLACE PACKAGE BODY dmcoluq AS
/* *********************************************************** */ /* This procedure shows the SQL */ /* *********************************************************** */PROCEDURE showSQL
htp.centerOpen; htp.hr; htp.tableOpen('0');
qnfrom := 'sys.dba_tab_columns';
htp.tableClose; htp.br; htp.centerClose;
/* *********************************************************** */ /* This procedure shows the Select statement */ /* *********************************************************** */PROCEDURE showSelect
htp.tableData(htf.bold('SELECT'), 'RIGHT', cnowrap=>'NOWRAP'); htp.tableData('column_name');
dmobjs.makeColumn('','table_name'); dmobjs.makeColumn('','owner'); dmobjs.makeColumn('','dcl'); htp.tableRowOpen; htp.tableData(htf.bold('FROM'), 'RIGHT', cnowrap=>'NOWRAP'); htp.tableData(qnfrom);
htp.tableData(htf.bold('WHERE'), 'RIGHT', cnowrap=>'NOWRAP'); -- Get rid of the word WHERE qnw := REPLACE(qnwhere, 'WHERE', ''); htp.tableData(qnw);
/* *********************************************************** *//* This procedure is the main procedure. It runs the query. */
/* *********************************************************** */ PROCEDURE runQuery (qName IN VARCHAR2 DEFAULT NULL, matchType IN VARCHAR2 DEFAULT 'BEGINSWITH', showSQLTop IN BOOLEAN DEFAULT FALSE, showSQLBottom IN BOOLEAN DEFAULT TRUE, showStatsTop IN BOOLEAN DEFAULT TRUE, showStatsBottom IN BOOLEAN DEFAULT FALSE) IS err_msg VARCHAR2(200); qn VARCHAR2(255); qnselect VARCHAR2(255); qnfrom VARCHAR2(255); qnwhere VARCHAR2(255); qnob VARCHAR2(255); qnsql VARCHAR2(1000); HTITLE VARCHAR2(100); hheader VARCHAR2(100); glsql VARCHAR2(500);
qnselect := 'SELECT column_name' || ',table_name' || ',owner' || ',get_real(table_name, owner, column_id) dcl' ;
qnob := ' ORDER BY column_name, table_name, owner';
htp.tableClose;
htp.centerClose;
htp.tableClose;
htp.centerClose;
WHEN OTHERS THEN
htp.centerOpen; htp.fontOpen('#FF0000', csize=>'+2'); htp.bold('Error'); htp.fontClose; htp.br; htp.br; err_msg := SQLERRM; htp.print(err_msg); htp.br; htp.br; htp.print('Technical Difficulty executing the query--please note the'); htp.br; htp.print('error message and contact the Help Desk at X2525.'); htp.centerClose; htp.br; htp.br;
/* ********************************************************* */ /* This procedure runs the SQL passed in and displays it in */ /* an HTML table. */ /* ********************************************************* */PROCEDURE runSQL
cursor_name INTEGER; ret INTEGER; savSQL VARCHAR2(500); dtn VARCHAR2(20); ddt VARCHAR2(30); dow VARCHAR2(12); dcl VARCHAR2(30); newdcl VARCHAR2(30);
LOOP
IF ((ASCII(SUBSTR(ddt, 1, 1)) <= 32) OR (ddt IS NULL)) THEN ddt := '&'||'nbsp;'; END IF; IF dcl IS NULL THEN newdcl := '&'||'nbsp;'; ELSE dcl := UPPER(dcl); newdcl := ''; FOR num_char IN 1..LENGTH(dcl) LOOP IF ((ASCII(SUBSTR(dcl,num_char,1)) >= 65) AND (ASCII(SUBSTR(dcl,num_char,1)) <= 90)) OR ((ASCII(SUBSTR(dcl,num_char,1)) >= 48) AND (ASCII(SUBSTR(dcl,num_char,1)) <= 57)) OR (ASCII(SUBSTR(dcl,num_char,1)) = 95) THEN newdcl := newdcl||SUBSTR(dcl,num_char,1); END IF; END LOOP; IF LENGTH(newdcl) < 1 THEN newdcl := '&'||'nbsp;'; END IF; END IF; -- Print the row htp.tableRowOpen; htp.tableData('<A
|| dtn || '>' || dtn || '</A>', cattributes=>'VALIGN=TOP');
htp.tableData('<A
href=http:/www_dm/plsql/dm.dmrunqb.runQuery?querytype=dmdictq&' || 'qname='
|| ddt || '>' || ddt || '</A>', cattributes=>'VALIGN=TOP');
htp.tableData(dow, cattributes=>'VALIGN=TOP'); -- htp.tableData('<A
|| dow || '>' || dow || '</A>', cattributes=>'VALIGN=TOP');
htp.tableData('<A
href=http:/www_dm/plsql/dm.dmrunqb.runQuery?querytype=dmcoluq&' || 'qname='
|| newdcl || '>' || newdcl || '</A>',
cattributes=>'VALIGN=TOP');
htp.tableRowClose; ELSE -- No more rows EXIT; END IF;
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor_name) THEN DBMS_SQL.CLOSE_CURSOR(cursor_name); END IF; RAISE;
/* ********************************************************* */ /* This procedure runs the SQL to retrieve the glossary */ /* definition. */ /* new: rbyron */ /* ********************************************************* */PROCEDURE exeSQL
cursor_name INTEGER; ret INTEGER; savSQL VARCHAR2(500); dtn VARCHAR2(100); dsh VARCHAR2(100); ddt VARCHAR2(5000);
LOOP
IF ((ASCII(SUBSTR(ddt, 1, 1)) <= 32) OR (ddt IS NULL)) THEN ddt := '&'||'nbsp;'; END IF; -- Print the row htp.tableRowOpen; htp.tableData(dtn, cattributes=>'VALIGN=TOP'); htp.tableData(dsh, cattributes=>'VALIGN=TOP'); htp.tableData(ddt, cattributes=>'VALIGN=TOP'); htp.tableRowClose; ELSE -- No more rows EXIT; END IF;
EXCEPTION
WHEN OTHERS THEN
IF DBMS_SQL.IS_OPEN(cursor_name) THEN DBMS_SQL.CLOSE_CURSOR(cursor_name); END IF; RAISE;