Home » SQL & PL/SQL » SQL & PL/SQL » is this possible
is this possible [message #37942] Thu, 07 March 2002 10:38 Go to next message
Suresh
Messages: 189
Registered: December 1998
Senior Member
Hi,
iam reading a value from a file into a string
and iam trying to execute a select statement appending
the string to the select statment.

Ex: reading hostname from a file
select * from remotetable@hostname where remoteid = 1;
Is this rightway to do?
appreciate any sample code.

Thanks
suresh
Re: is this possible [message #37944 is a reply to message #37942] Thu, 07 March 2002 10:54 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
1) read string using utl_file package

2) use dynamic sql

declare
f UTL_FILE.FILE_TYPE;
l_str varchar2(30);
type r is refcursor;
r1 r;
begin

f := UTL_FILE.FOPEN('c:myutildir', 'x.txt', 'r');
utl_file.get_line(f,l_str);
utl_file.fclose(f);

open r1 for 'select * from remotetable@'||l_str||' where remoteid = 1'
...
...
close r1;
end;
Previous Topic: Getting Values from a Record Variable into a Cursor Variable
Next Topic: Getting Values in a Record Variable into a cursor
Goto Forum:
  


Current Time: Fri Apr 19 03:20:37 CDT 2024