<?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: Shell Script to database in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014874#M718748</link>
    <description>I suspect tht the reason you have received no help (or from your Perl question either) is that you seem unwilling to at least make an attempt at a script. &lt;BR /&gt;&lt;BR /&gt;Awk is probably a little easier to grasp/use so here is a START:&lt;BR /&gt;&lt;BR /&gt;Create a little awk script, my.awk&lt;BR /&gt;{&lt;BR /&gt;  if (length($0) &amp;gt; 0)&lt;BR /&gt;    {&lt;BR /&gt;      n = split($0,array,";")&lt;BR /&gt;      printf("%s %5s %-8.8s\n",array[1],array[2],array[3])&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This will print the first three fields (separataed by semicolons and format them as strings)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now feed the output of your SQL to awk,&lt;BR /&gt;&lt;BR /&gt;sqlplus .... | awk -f my.awk&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;awk -f my.awk &amp;lt; spool.out</description>
    <pubDate>Thu, 03 Jul 2003 17:33:36 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2003-07-03T17:33:36Z</dc:date>
    <item>
      <title>Shell Script to database</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014872#M718746</link>
      <description>&lt;BR /&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;When I do a select in my data base I got the result below, but I??d to use the fields in order to compare.&lt;BR /&gt;The problem is that I have a lot of blank spaces, I??m using set colsep ";" in order to have the columns separated.&lt;BR /&gt;&lt;BR /&gt; 1  - How can I use the fieds, extract the data ?&lt;BR /&gt; 2- How to organize the query result ? Remove the blanks and well formated ?&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; select ascii(GRP_BEP),SNPUPDT,DYNUPDT,A_OD_REF,A_PRV_ID,&lt;BR /&gt;A_SUB_ID,CMMAD,CMM,CMMNB,CMMNM,CMMST,CMMZIP,&lt;BR /&gt;CURCRED,CUS_NBR,CUSTID,DATEBLO,DATEFIN,ascii(F_TARP),ascii(FRST_ACC),LAST_CCA,MAX_CRED,MN15,NB_CCA,RI,&lt;BR /&gt;ASCII(STA),TASERQU,USR_PIN from custlc where cus_nbr is not null and ascii(state)=0;&lt;BR /&gt;             0; 180545248;01-JUL-03;         0;0         ;&lt;BR /&gt;00047234580344                          ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CE             ;          ;   3124800;852697013 ;47382     ;17/09/2003&lt;BR /&gt;19/07/2003;              0;              0;25/06/2003;   3127600;852697013&lt;BR /&gt;         1;     47382;  ##########;         1;&lt;BR /&gt;&lt;BR /&gt;             0; 180699629;03-JUL-03;         0;0         ;&lt;BR /&gt;00043461980315                          ;&lt;BR /&gt;&lt;BR /&gt;SILVIA HELENA CORREA RODRIGUES&lt;BR /&gt;CE             ;          ;    691600;854693827 ;12976     ;05/10/2003&lt;BR /&gt;06/08/2003;              0;              0;01/07/2003;   2500000;854693827&lt;BR /&gt;         3;     12976;  ##########;         1;&lt;BR /&gt;&lt;BR /&gt;             0; 179276618;09-JUN-03;         0;0         ;&lt;BR /&gt;BRUNO LEONARDO - CGR TESTE              ;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 16:54:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014872#M718746</guid>
      <dc:creator>Ricardo Bassoi</dc:creator>
      <dc:date>2003-07-03T16:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script to database</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014873#M718747</link>
      <description>Hi, I'm not 100% sure I understand your question.  The best way to do this is to get the perl DB add on for your database.&lt;BR /&gt;&lt;BR /&gt;BUT&lt;BR /&gt;&lt;BR /&gt;if you want to seperate out the fields&lt;BR /&gt;&lt;BR /&gt;awk -F";" '{print $1}' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;The above will print the first column using ; as the delimeter.&lt;BR /&gt;&lt;BR /&gt;If you want to further format the answers (from within a script) use printf, either within or outside awk.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;unload to "output.txt" select cust_name, age, height, bank_balance from table delieter ";";&lt;BR /&gt;&lt;BR /&gt;and you can use a script (one-liner) to print out thses results like so:&lt;BR /&gt;&lt;BR /&gt;awk -F ";" '{printf"%12s %4d %4d %12.2f\n", $1, $2, $3, $4}' output.txt&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Tim&lt;/FILE&gt;</description>
      <pubDate>Thu, 03 Jul 2003 17:29:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014873#M718747</guid>
      <dc:creator>Tim D Fulford</dc:creator>
      <dc:date>2003-07-03T17:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script to database</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014874#M718748</link>
      <description>I suspect tht the reason you have received no help (or from your Perl question either) is that you seem unwilling to at least make an attempt at a script. &lt;BR /&gt;&lt;BR /&gt;Awk is probably a little easier to grasp/use so here is a START:&lt;BR /&gt;&lt;BR /&gt;Create a little awk script, my.awk&lt;BR /&gt;{&lt;BR /&gt;  if (length($0) &amp;gt; 0)&lt;BR /&gt;    {&lt;BR /&gt;      n = split($0,array,";")&lt;BR /&gt;      printf("%s %5s %-8.8s\n",array[1],array[2],array[3])&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This will print the first three fields (separataed by semicolons and format them as strings)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now feed the output of your SQL to awk,&lt;BR /&gt;&lt;BR /&gt;sqlplus .... | awk -f my.awk&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;awk -f my.awk &amp;lt; spool.out</description>
      <pubDate>Thu, 03 Jul 2003 17:33:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-database/m-p/3014874#M718748</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-03T17:33:36Z</dc:date>
    </item>
  </channel>
</rss>

