Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Oracle / Apache webserver package modification question

Oracle / Apache webserver package modification question

From: Travis Paakki <trp9_at_MailAndNews.com>
Date: Mon, 12 Mar 2001 15:36:47 -0500
Message-ID: <3ABE6A69@MailAndNews.com>

I have the following Oracle web server package designed to let developers not
need to log into the instance to retrieve column and table structure information, just use a browser:
...package definition...
CREATE OR REPLACE PACKAGE BODY dmcoluq AS

 /* This procedure shows the SQL                                */
PROCEDURE showSQL

    (qnwhere IN VARCHAR2)
    IS
     qnfrom VARCHAR2(255);
  BEGIN

    htp.centerOpen;
    htp.hr;
    htp.tableOpen('0');

    qnfrom := 'sys.dba_tab_columns';

    htp.tableClose;
    htp.br;
    htp.centerClose;
  END showSQL;
  /* This procedure shows the Select statement                   */
  /* *********************************************************** */
  PROCEDURE showSelect
    (qnfrom IN VARCHAR2,
     qnwhere IN VARCHAR2)
    IS
     qnw VARCHAR2(255);
  BEGIN
    htp.tableRowOpen;
      htp.tableData(htf.bold('SELECT'), 'RIGHT', cnowrap=>'NOWRAP');
      htp.tableData('column_name');

    htp.tableRowClose;
    dmobjs.makeColumn('','table_name');
    dmobjs.makeColumn('','owner');
    dmobjs.makeColumn('','dcl');

    htp.tableRowOpen;
      htp.tableData(htf.bold('FROM'), 'RIGHT', cnowrap=>'NOWRAP');
      htp.tableData(qnfrom);

    htp.tableRowClose;
    htp.tableRowOpen;
      htp.tableData(htf.bold('WHERE'), 'RIGHT', cnowrap=>'NOWRAP');
      -- Get rid of the word WHERE
      qnw := REPLACE(qnwhere, 'WHERE', '');
      htp.tableData(qnw);

    htp.tableRowClose;
  END showSelect;
  /* 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);

  BEGIN
    qn := UPPER(qName);

    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 

href=http:/www_dm/plsql/dm.dmrunqb.runQuery?querytype=dmcoluq&' || 'qname=' || 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 

href=http:/www_dm/plsql/dm.dmrunqb.runQuery?querytype=dmcoluq&' || 'qname=' || 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;

    END LOOP;

  EXCEPTION
    WHEN OTHERS THEN

      IF DBMS_SQL.IS_OPEN(cursor_name) THEN
        DBMS_SQL.CLOSE_CURSOR(cursor_name);
      END IF;
      RAISE;

  END runSQL;
  /* ********************************************************* */
  /* This procedure runs the SQL to retrieve the glossary definition */   PROCEDURE exeSQL
    (theSQL IN VARCHAR2)
    IS
      cursor_name  INTEGER;
      ret          INTEGER;
      savSQL       VARCHAR2(500);
      dtn          VARCHAR2(100);
      dsh          VARCHAR2(100);
      ddt          VARCHAR2(5000);

  BEGIN

  EXCEPTION
    WHEN OTHERS THEN

      IF DBMS_SQL.IS_OPEN(cursor_name) THEN
        DBMS_SQL.CLOSE_CURSOR(cursor_name);
      END IF;
      RAISE;

  END exeSQL;
END dmcoluq;
/
GRANT EXECUTE ON dmcoluq TO www_blah;
/

We have grown into a dev/qa/prod environment, with instances for each. The package is homed in dev and I am establishing links to the other instances. The submitting web page allows the user to request definitions for prod, qa, or dev, all three, and the requirements state that I indicate the row's home instance. Origionally I thought of using an outter join but I still didn't see how I would get the instance indicators present. Has anyone tried something like this? Is it really as many new lines of code to the from statements as I'm thinking? Any suggestions?



 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or  POP3 mailbox from anywhere with just a web browser.


Received on Mon Mar 12 2001 - 14:36:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US