I’m working on a pl sql stored procedure.
What I need is to do a select, use a cursor and for every record build a string using values.
At the end I need to write this into a file.
I try to use dbms_output.put_line(“toto”) but the buffer size is to small because I have about 14 millions lines.
I call my procedure from a unix ksh.
I’m thinking at something like using “spool on” (on the ksh side) to dump the result of my procedure, but I don’ know how to do it (if this is possible)
Anyone has any idea?
Unless it is really necessary, I would not use a procedure.
If you call the script using SQLPlus, just put the following into your
test.sql(theSETs are from SQLPlus FAQ to remove noise):and redirect output to a file (
test.txt):If you really need to do stuff in PL/SQL, consider putting that into a function and call it per record:
Call:
Performance could suffer, but it should work. Make sure, that what you try can’t be done in pure
SQL, though.Reading your comment I think that Analytic Function
Lagis what you need.This example appends
*in case the value ofvalhas changed:Returns