<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Execute a SQL script WITH PARAMETERS using an execute script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820751#M829970</link>
    <description>Sander,&lt;BR /&gt;&lt;BR /&gt;It's time to learn perl:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.linuxjournal.com/article.php?sid=3958" target="_blank"&gt;http://www.linuxjournal.com/article.php?sid=3958&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.stormloader.com/yonghuang/computer/OracleAndPerl.html" target="_blank"&gt;http://www.stormloader.com/yonghuang/computer/OracleAndPerl.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://thomas.eibner.dk/oracle/dbi/" target="_blank"&gt;http://thomas.eibner.dk/oracle/dbi/&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://tlowery.hypermart.net/perl_dbi_dbd_faq.html" target="_blank"&gt;http://tlowery.hypermart.net/perl_dbi_dbd_faq.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Tue, 08 Oct 2002 11:48:33 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2002-10-08T11:48:33Z</dc:date>
    <item>
      <title>Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820750#M829969</link>
      <description>Hi group,&lt;BR /&gt;&lt;BR /&gt;I have a script called ShellSql.sh. I use it to run SQL*Plus scripts. The ShellSql.sh script has 1 parameter, the name of the sql script to be executed. The line below executes the sql script.&lt;BR /&gt;#----------------------------------------------#Run the SQL*Plus script, storing results in a variable&lt;BR /&gt;#----------------------------------------------SQLRESULT=`sqlplus -s / @$SQL_SCRIPT $OUTPUT &amp;lt; $DIR/endsql.txt`&lt;BR /&gt;&lt;BR /&gt;I want to change my ShellSql.sh script so that the user can add parameters for the SQL script to be executed. The problem is that the number of arguments (parameters) can differ from 0 to x.&lt;BR /&gt;&lt;BR /&gt;I have an idea on how to create something like it but I have no idea how to build this. The idea is to let the user type in all parameters they need after the parameter SQL_SCRIPT. &lt;BR /&gt;1)Check if there is anything behind the word SQL_SCRIPT;&lt;BR /&gt;2)Count the number of spaces between the arguments to find the total number of arguments(0 means 1 argument, 1 means 2 arguments,e tc.)&lt;BR /&gt;3) insert these arguments after the name of the sql_script.&lt;BR /&gt;This would result in something like this: &lt;BR /&gt;SQLRESULT=`sqlplus -s / @$SQL_SCRIPT $ARRAY_OF_ARGUMENTS&lt;BR /&gt;$OUTPUT &amp;lt; $DIR/endsql.txt`&lt;BR /&gt;&lt;BR /&gt;I know its a lot to ask but I really need it.&lt;BR /&gt;&lt;BR /&gt;Thnx&lt;BR /&gt;Sander&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 09:40:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820750#M829969</guid>
      <dc:creator>Sander Derix</dc:creator>
      <dc:date>2002-10-08T09:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820751#M829970</link>
      <description>Sander,&lt;BR /&gt;&lt;BR /&gt;It's time to learn perl:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.linuxjournal.com/article.php?sid=3958" target="_blank"&gt;http://www.linuxjournal.com/article.php?sid=3958&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.stormloader.com/yonghuang/computer/OracleAndPerl.html" target="_blank"&gt;http://www.stormloader.com/yonghuang/computer/OracleAndPerl.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://thomas.eibner.dk/oracle/dbi/" target="_blank"&gt;http://thomas.eibner.dk/oracle/dbi/&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://tlowery.hypermart.net/perl_dbi_dbd_faq.html" target="_blank"&gt;http://tlowery.hypermart.net/perl_dbi_dbd_faq.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 08 Oct 2002 11:48:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820751#M829970</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-10-08T11:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820752#M829971</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I hope I understand it correctly:&lt;BR /&gt;&lt;BR /&gt;ShellSql.sh sqlskript.sql para1 para2 para3&lt;BR /&gt;&lt;BR /&gt;should result in&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;SQLRESULT=`sqlplus -s / @sqlskript.sql para1 para2 para3 $OUTPUT &amp;lt; $DIR/endsql.txt`&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;SQL_SCRIPT=`echo $* | awk '{print $1'}`&lt;BR /&gt;ARRAY_OF_ARGUMENTS=`echo $* | awk '{for ( i=2;i&amp;lt;=NF;i++) printf(" %s ", $i)}'`&lt;BR /&gt;echo $SQL_SCRIPT&lt;BR /&gt;echo $ARRAY_OF_ARGUMENTS&lt;BR /&gt; &lt;BR /&gt;SQLRESULT=`sqlplus -s / @$SQL_SCRIPT $ARRAY_OF_ARGUMENTS $OUTPUT &amp;lt; $DIR/endsql.txt`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 08 Oct 2002 12:29:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820752#M829971</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-10-08T12:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820753#M829972</link>
      <description>I understand same as Christian , therefore&lt;BR /&gt;&lt;BR /&gt;SQL_SCRIPT=$1&lt;BR /&gt;shift&lt;BR /&gt;ARRAY_OF_ARGUMENTS=$*&lt;BR /&gt;&lt;BR /&gt;command is the same&lt;BR /&gt;&lt;BR /&gt;Jean-Luc&lt;BR /&gt;PS : sorry Harry no need to learn perl for this !</description>
      <pubDate>Tue, 08 Oct 2002 12:41:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820753#M829972</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2002-10-08T12:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820754#M829973</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do it in a script (Korn shell).&lt;BR /&gt;It tests for the number of arguments passed in,&lt;BR /&gt;and it uses the shift command to pop off the first argument and put the rest of them into a variable if there is more than one argument passed on the command line.  You don't have to worry about counting spaces to figure out the number of arguments, just use the $# variable.  This way, no matter how many or how few variables they type in behind the script name, they will all wind up in the $ARGS variable.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat testargs&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;# testargs&lt;BR /&gt;&lt;BR /&gt;MYSCRIPT=$1&lt;BR /&gt;&lt;BR /&gt;if [[ $# -gt 1 ]]&lt;BR /&gt;then&lt;BR /&gt;    shift&lt;BR /&gt;    ARGS=$*&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;echo "MYSCRIPT is $MYSCRIPT"&lt;BR /&gt;if [[ ! -z $ARGS ]]&lt;BR /&gt;then&lt;BR /&gt;    echo "args are $ARGS"&lt;BR /&gt;else&lt;BR /&gt;    echo "No other args passed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;./testargs abc      &lt;BR /&gt;MYSCRIPT is abc                                        &lt;BR /&gt;No other args passed                                   &lt;BR /&gt;&lt;BR /&gt;&amp;gt;./testargs abc 1 2 3&lt;BR /&gt;MYSCRIPT is abc                                        &lt;BR /&gt;args are 1 2 3                                         &lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 12:43:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820754#M829973</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-08T12:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820755#M829974</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;And it is actually even easier than my sample script.  Try something like this:&lt;BR /&gt;&lt;BR /&gt;MYSCRIPT=$1&lt;BR /&gt;shift&lt;BR /&gt;ARRAY_OF_ARGUMENTS=$*&lt;BR /&gt;&lt;BR /&gt;then you should be able to use the SQLRESULT line just as you have it posted.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 12:45:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820755#M829974</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-08T12:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Execute a SQL script WITH PARAMETERS using an execute script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820756#M829975</link>
      <description>Hi Sander,&lt;BR /&gt;&lt;BR /&gt;the only thing that could be missing is the way to actually USE the parameters passed to your SQL interpreter:&lt;BR /&gt;&amp;amp;1 will be substituted for the first parameter,&lt;BR /&gt;&amp;amp;2 for the seocnd, and so on...&lt;BR /&gt;Yes, shell uses "$1", but SQL uses "&amp;amp;1".&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Wodisch&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 12:48:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/execute-a-sql-script-with-parameters-using-an-execute-script/m-p/2820756#M829975</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2002-10-08T12:48:44Z</dc:date>
    </item>
  </channel>
</rss>

