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)
sqlplus CIDB/CIDB1234@CIDB @input_file.sql PRE11221000001

And this is my Query (my report, because I'm adding more stuff)
&&1
is 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

No comments:

Post a Comment