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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic FROM clause using SQLPLUS

Re: Dynamic FROM clause using SQLPLUS

From: Michael Serbanescu <mserban_at_postoffice.worldnet.att.net>
Date: 1997/11/12
Message-ID: <64bj58$dtm@bgtnsc03.worldnet.att.net>#1/1

Create the following SQL*Plus script:

SET PAGESIZE 0
SET VERIFY OFF
SET ECHO OFF
SET FEEDBACK OFF
SET TERMOUT OFF SPOOL doctitle.sql

SELECT 'SELECT doc_num, title FROM '||table_name||' WHERE doc_num='||''''||doc_num||''';'
FROM Table1;

SPOOL OFF Next, edit the doctitle.sql script to remove any line(s) other than the 'SELECT doc_num, title...' statements (the original query and the SPOOL OFF command will be in there). Then run the cleaned-up doctitle.sql script in SQL*Plus.

Hope this helps.

Michael Serbanescu



On Tue, 11 Nov 1997 10:01:18 -0600, arielk_at_exlibris.co.il wrote:

>Hi there,
>
>I have asked this question before about REPORTS 2.5,
>but now I need an answer concerning SQLPLUS :
>
>How can I select data from a table, whose name
>appears as a field in the master table of a master/detail report.
>
>i.e.
>if Table1 includes :
>TABLE_NAME CHAR(5)
>DOC_NUM NUMBER(9)
>
>and tables MAIN_LIB and SECONDARY_LIB include :
>DOC_NUM NUMBER(9)
>TITLE VARCHAR2(100)
>
>What SQLPLUS code would I use to retrieve the titles of
>all the documents in Table1 from their relevant tables ?
>
> Sincerely,
>
> Ariel Kirson
> Ex Libris.
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Received on Wed Nov 12 1997 - 00:00:00 CST

Original text of this message

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