<?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: Reading variable from SQL to Unix in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499874#M653689</link>
    <description>Thanks,&lt;BR /&gt;   I will look at these and others on google.</description>
    <pubDate>Fri, 18 Sep 2009 13:28:22 GMT</pubDate>
    <dc:creator>cool_reptile</dc:creator>
    <dc:date>2009-09-18T13:28:22Z</dc:date>
    <item>
      <title>Reading variable from SQL to Unix</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499871#M653686</link>
      <description>Hi, &lt;BR /&gt;   I have a korn shell script and a variable that I'm trying to load data into from a table in Oracle, this variable will then be used in a subject line in an email that will be sent from Unix.  I have this so far but am having difficulty still trying to get the variable to display properly in the mail -s command.  Can someone please help?  Here is the code that only returns '0' in the subject line but I want to actually return the output from the SQL statement into that variable then display it in the Subject line of the Unix mail:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#COMMENT&lt;BR /&gt;. /apps/ppa/bin/.profile&lt;BR /&gt;#export ORACLE_HOME=&lt;YOUR path="" to="" oracle="" home=""&gt;&lt;BR /&gt;#export PATH=$PATH:$ORACLE_HOME/bin&lt;BR /&gt;export emailadd1=firstname.lastname@email.com&lt;BR /&gt;export VAR=0&lt;BR /&gt;&lt;BR /&gt;sqlplus /nolog &amp;lt;&amp;lt; EOF&lt;BR /&gt;connect opcppa/oracle&lt;BR /&gt;set echo off;&lt;BR /&gt;set termout on;&lt;BR /&gt;set linesize 100;&lt;BR /&gt;set pagesize 60;&lt;BR /&gt;set newpage 0;&lt;BR /&gt;set heading off;&lt;BR /&gt;set feedback off;&lt;BR /&gt;spool /tmp/output.lis;&lt;BR /&gt;select COMPANY into "$VAR" from CUSTOMERS where rownum&amp;lt;2;&lt;BR /&gt;spool off;&lt;BR /&gt;EOF&lt;BR /&gt;/usr/bin/uuencode /tmp/output.lis "TestFileOracleData.txt"|mail -s "$VAR" $emailadd1&lt;BR /&gt;&lt;BR /&gt;#End-of-Script&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;/YOUR&gt;</description>
      <pubDate>Thu, 17 Sep 2009 19:30:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499871#M653686</guid>
      <dc:creator>cool_reptile</dc:creator>
      <dc:date>2009-09-17T19:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading variable from SQL to Unix</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499872#M653687</link>
      <description>sqlplus does NOT understand shell variables.&lt;BR /&gt;&lt;BR /&gt;Its only communication channel back is really STDOUT data, and for numerics in a pinch the process exit status.&lt;BR /&gt;&lt;BR /&gt;Google for "sqlplus select into shell  variable"&lt;BR /&gt;You'll get a lot of useful example.&lt;BR /&gt;For example you find a construct like:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;COUNT=`sqlplus -s system/manager &amp;lt;&lt;ABC&gt;&lt;/ABC&gt;set head off;&lt;BR /&gt;select count(*) from table1;&lt;BR /&gt;exit;&lt;BR /&gt;ABC`&lt;BR /&gt;&lt;BR /&gt;[ I'd use the preferred $( ... )  ]&lt;BR /&gt;&lt;BR /&gt;For more than one number you'll need the help of the Shell READ command and perhaps toss in an AWK or PERL filter.&lt;BR /&gt;&lt;BR /&gt;So please play with that thought for a while and see if you need further help!&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein van den Heuvel.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 19:50:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499872#M653687</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-09-17T19:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading variable from SQL to Unix</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499873#M653688</link>
      <description>These two stood out....&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:315416808631" target="_blank"&gt;http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:315416808631&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.idevelopment.info/data/Oracle/DBA_tips/Unix/UNIX_3.shtml" target="_blank"&gt;http://www.idevelopment.info/data/Oracle/DBA_tips/Unix/UNIX_3.shtml&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 20:13:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499873#M653688</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-09-17T20:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading variable from SQL to Unix</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499874#M653689</link>
      <description>Thanks,&lt;BR /&gt;   I will look at these and others on google.</description>
      <pubDate>Fri, 18 Sep 2009 13:28:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/reading-variable-from-sql-to-unix/m-p/4499874#M653689</guid>
      <dc:creator>cool_reptile</dc:creator>
      <dc:date>2009-09-18T13:28:22Z</dc:date>
    </item>
  </channel>
</rss>

