I have a HUGE pl/sql block defined within a *.sql file, I cannot possibly move it to the shell script, nor can I pass so many variables as argument. Surely there must be a way ?
The method that I use for passing external data into PL/SQL is by getting the data into a flat file (in Unix you can pipe the contents of the system variables into a file), then read the flat file using PL/SQL flat-file-handling capabilities. Are you familiar with flat-file-handling mechanisms in PL/SQL?
Dave, I suppose that in many cases some extra sql*plus capabilities, such as formatting queries, bind/lexical variables, at last spooling are in use, so sql*plus script in fact is something more than sql script and it can not be invoked via dynamic sql.
Muskaan, I suppose you may easily add a couple of lines to any sql*plus script to get executable from it. But can you clarify your task a bit? Do you need to invoke this script from client machine to read server side environment variables? Or both sql*plus and database work within the same environment?
Hi Dima,
The task I need to perform involves invoking a pl/sql script on server side to read server(same) side environment variables. What I need to implement is quite complex but the simplified form of the problem is:
there is an environment variable age_in_months. I need to use the value of this variable inside a pl/sql block.
Dave, I know how to parse a file using the utl_file package. Maybe that is what I will eventually have to do. You were also suggesting utl_file, weren't you ?
Parbhani, I know your suggested code does not have any command line parameters, but your sql block is written in a ksh script, which I cannot do.
Thanks,
Muskaan
Yes, Muskaan, My suggestion (if applicable for you) is to store in a flat file, the environment-variable value(s) you need, then use utl_file functionality to read the flat-file values into your program.
Thanks everyone, for your time and suggestions. I am implementing the utl_file solution. We do not have the 9i yet, but when that happens I will look at the solution that carp suggested.
thanks again
Muskaan
Hi dsanchez2, I could do that, only one would have to maintain the env table up to date. These env variables are anyway maintained for other shell scripts, they will now be parsed by pl/sql block from a flat file. Values for the flat file will be picked from env during every run, so there is no botheration of maintaining these values at two places. Thoughts ?
Thanks,
Muskaan
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.