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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Dynamic sql help needed

RE: Dynamic sql help needed

From: Thapliyal, Deepak <DThapliyal_at_ea.com>
Date: Tue, 29 Aug 2000 11:55:55 -0700
Message-Id: <10603.115770@fatcity.com>


see if this helps ..

declare

	nval number;
	<define ur other vars ..>

begin
str := 'SELECT COUNT(*) into ||nval ||'FROM '||table_name ||'WHERE '||col1 ||'='||' field1 '||'AND' ||'col2'||' = '||field2; execute immediate(str);
dbms_output.put_line(nval);
end;
/

deepAk

PS: will work with 8i

-----Original Message-----
From: Cale, Rick T (Richard) [mailto:RICHARD.T.CALE_at_saic.com] Sent: Tuesday, August 29, 2000 10:24 AM
To: Multiple recipients of list ORACLE-L Subject: Dynamic sql help needed

Hi All,

In my PL SQL script I have 2 cursors. The first one gets a table_name and the 2nd one get 2
fields(field1 and field2). What I would like to do is build dynamic sql using these variables. What I need
is to build a 3rd cursor using the table_name,field1 and field2 from the first 2 cursors.

For example SELECT COUNT(*)

                    FROM table_name
                    WHERE col1 = field1
                    AND       col2 = field2;

I cannot seem to find an example where the table_name is dynamic.

Thanks
Rick

-- 
Author: Cale, Rick T (Richard)
  INET: RICHARD.T.CALE_at_saic.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Aug 29 2000 - 13:55:55 CDT

Original text of this message

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