In my previous entry, I was trying to process a text files (a CSV), using each line of that file as input for my SQL*Plus call.
But, what happens if you don't have a UNIX box where you can execute it??? :(
Let's write my shell script into a batch file (oh man!), and this is the result:
Where %%a is the first token, %%b the second one, and so on (until we'd reached the fourth token - as specified on tokens=1,2,3,4)
At the end, it was simple :D
Showing posts with label SQL*Plus. Show all posts
Showing posts with label SQL*Plus. Show all posts
Tuesday, February 8, 2011
Friday, February 4, 2011
Report in SQLPlus using spool to write a file
On my previous entry I'm reading a file and using each line as input to make an external call (call SQL*Plus for example)
Well, this is my SQL (script) to be executed using SQL*Plus, in other words, I will execute this query for each line of a given file (shell script), each time that I call SQLPlus I'll append to the spool (output file) the result of my query (I'll pass as parameter to my query the parameter given on command call)
And this is my Query (my report, because I'm adding more stuff)
My output will be a file named: output_file_2011-02-04.LST
For more information and references please see the official Oracle web site for SQL*Plus:
Ref 1
Ref 2
Ref 3
Ref 4
sqlplus CIDB/CIDB1234@CIDB @input_file.sql PRE11221000001
And this is my Query (my report, because I'm adding more stuff)
&&1is the first parameter after the script namde in command line, then the second param will be &&2 then the third one &&3 and so on
My output will be a file named: output_file_2011-02-04.LST
For more information and references please see the official Oracle web site for SQL*Plus:
Ref 1
Ref 2
Ref 3
Ref 4
Run a SQLPlus script and pass a parameter as input
Simple:
Then your script:
begin dbms_output.put_line(&&1);
dbms_output.put_line(&&2);
end;
/
Then your script:
begin dbms_output.put_line(&&1);
dbms_output.put_line(&&2);
end;
/
Subscribe to:
Posts (Atom)