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 SQL query question

Re: dynamic SQL query question

From: DA Morgan <damorgan_at_psoug.org>
Date: Wed, 18 May 2005 15:27:25 -0700
Message-ID: <1116454986.162811@yasure>


leileili_at_hotmail.com wrote:
> Hello,
> I'm new in dynamic SQL query and I have a problem need help.
>
> For example: I have a SQL query like this:
>
> select hw.family,hw.id where hw.id="1234567";
>
> and I have a txt file holding more than ten thousands id.
> I need feed the ids from the file to the SQL query, inside
> the "???", please let me know how can I do this?
>
> then I put the SQL query in a file and run it from another .csh
> file. Inside the .csh file, I have something like this:
>
> mysql -u usrname dataname< /directory/sqlfile
>

>>/directory/outputfile/id_???

>
>
> how can I have the output files created with different names according
> with the id inputs in the run time?
>
> Thanks a lot.

There is nothing dynamic about your SQL statement nor is there a need to dynamic SQL.

What you need to do is create an external table to the text file. Then just do an INSERT INTO ... SELECT FROM ....

You can find a demo of external table creation at: http://www.psoug.org
click on Morgan's Library
click on External Tables

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Wed May 18 2005 - 17:27:25 CDT

Original text of this message

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