Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: dynamic SQL query question
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_???
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