I don’t run forums any more, but there is a place on this website where technical questions can be asked:
One question managed to get asked here before I made that clear: please go to that Q&A page instead if you want to ask anything new.
I don’t run forums any more, but there is a place on this website where technical questions can be asked:
One question managed to get asked here before I made that clear: please go to that Q&A page instead if you want to ask anything new.
need ur help
I have generate a dynamic sql query in unix and i want to run that generated sql query on unix
box.But when i have tried to run this its shows error because ther is a space in the generated
sql…Please assist
for example:
code_list=`sqlplus -s Test/test123 <<EOF
set heading off
set pagesize 0
set tab off
set feedback off
select decode(rownum, 1, ' ', 'union ') ||'select distinct '''||trial_name||''' as Schema_Name,
viewname from '||trial_name||'.CA_DATA a where view
name not in(select distinct object_name from dba_objects a
where a.owner='''||trial_name ||''' and (a.object_name like ''CV%''))'
from (
select distinct owner as trial_name from dba_objects
where owner like 'MK%'
or OWNER like 'V%')
/
exit
EOF`
sqlplus -s Test/test123 <<EOF
$code_list ;
exit
EOF`
in this query we first connect with DB and put the sql value in the variable.
and then i want to run that variable(code_list).this variable contain the sql query.I just want to
run the quey in code_list variable .but its not runing due to spce issue in the genearated dynamic
query.
Please assist.it's a very critical request.
Thanks for you help in advance.I am waiting for ur responce.
Regards,
Vikas
It’s a “very critical request”… for you. Not for anyone else here. None of us are paid to assist. So please keep the “this is very urgent and I’m waiting for a response” stuff out of it.
That said, I have some difficulty trying to understand what you are trying to do and your example seems on the complicated side. So forgive me if I’ve misunderstood, but I think all you are trying to do is 1) assign a SQL query to an environment variable and then 2) get SQL*Plus to execute the contents of that variable. Right? If so, can I simplify a little.
Basically, you want this:
…to do the actual assignment of the code to a variable.
Then you want this:
…to have your code run.
Now, if you want to run your more complex example:
…and when I run that like so:
…I get this output:
…which looks OK to me, though I can’t be sure it’s what you wanted.
I think my generic point is: don’t put back-ticks around the bit where you assign a value to the “code_list” variable, because that actually causes sqlplus to run and assign the results of your query to the variable, rather than merely the text of the query. In other words, if I did this:
…then when you try to echo the value of $code_list, you’ll see this sort of thing:
…meaning that the shell has actually tried to evaluate your back-ticked expression by running SQL*Plus and executing the query. I don’t *think* that’s what you want. I think you want to be able to assign a SQL statement to the variable and have SQL*Plus run whatever it finds in that variable, as though it were executing a SQL script, for example.
If I’ve misunderstood your request, then please feel free to clarify. But maybe make your example simpler, and please don’t expect answers to a schedule that’s significant to you.
Finally, though I don’t want to sound like a grumpy old man, and I perfectly understand why you’d ask your question on a post named ‘forum’, we actually don’t run a forum here any more and instead have a ‘Q & A’ page (which I’ve now made clear in the post text). So if you need to clarify your question, or post something new to better explain what you’re after, please use that Q&A page.