Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic FROM clause using SQLPLUS
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
>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
![]() |
![]() |