<?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: sql script to check database for specific record in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909777#M825076</link>
    <description>Hi &lt;BR /&gt;&lt;BR /&gt;You can use the util_file package for this one. You can define three files one in read mode and the other 2 in write mode. To be able to write and read from external files in the directory you should have the patch sepcified in the init.ora file with theentry utl_dir=/path.&lt;BR /&gt;Then restart you database for this to be effective.&lt;BR /&gt;&lt;BR /&gt;eg:- &lt;BR /&gt;wf1_handle := UTL_FILE.FOPEN ('/path','tn_list', 'R');&lt;BR /&gt;&lt;BR /&gt;wf2_handle := UTL_FILE.FOPEN '/path','tn_yes', 'W');&lt;BR /&gt;    wf3_handle := UTL_FILE.FOPEN ('/path','tn_no', 'W');&lt;BR /&gt;&lt;BR /&gt;And then in the input file loop till the end and for each line read using (UTL_FILE.GET_LINE (wf1_handle, value) select from the table.&lt;BR /&gt;And if you find a match then write to the tn.yes file otherwise write to the tn.no file using (UTL_FILE.PUT_LINE (wf3_handle, value);.&lt;BR /&gt;&lt;BR /&gt;You have an input file to read from all the tn and then select form a table and if matches write to the output file no.txt &lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;IA</description>
    <pubDate>Wed, 29 Jun 2005 21:46:24 GMT</pubDate>
    <dc:creator>Indira Aramandla</dc:creator>
    <dc:date>2005-06-29T21:46:24Z</dc:date>
    <item>
      <title>sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909775#M825074</link>
      <description>I have a list (7000) of tn that I would like to check to see if they are in the data base. If they are print tn to a tn.yes file, if not print that tn to a tn.not file.&lt;BR /&gt;&lt;BR /&gt;How can I manipulate the sql commands, I think i have the select statement but had to append the appropriate files baffles me.&lt;BR /&gt;&lt;BR /&gt;cat tn.file |while read i&lt;BR /&gt;        do&lt;BR /&gt;        echo $i&lt;BR /&gt;        sqlplus -s admin/admin1 &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;       SELECT TN from TN_TABLE WHERE TN = '$i';&lt;BR /&gt;EOF&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Jun 2005 11:31:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909775#M825074</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2005-06-29T11:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909776#M825075</link>
      <description>For the select statement;&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; select tn from tn_table where tn like '%i';&lt;BR /&gt;&lt;BR /&gt;Notice the % in place of the $ for wildcard searches.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Jun 2005 12:10:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909776#M825075</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-06-29T12:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909777#M825076</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;You can use the util_file package for this one. You can define three files one in read mode and the other 2 in write mode. To be able to write and read from external files in the directory you should have the patch sepcified in the init.ora file with theentry utl_dir=/path.&lt;BR /&gt;Then restart you database for this to be effective.&lt;BR /&gt;&lt;BR /&gt;eg:- &lt;BR /&gt;wf1_handle := UTL_FILE.FOPEN ('/path','tn_list', 'R');&lt;BR /&gt;&lt;BR /&gt;wf2_handle := UTL_FILE.FOPEN '/path','tn_yes', 'W');&lt;BR /&gt;    wf3_handle := UTL_FILE.FOPEN ('/path','tn_no', 'W');&lt;BR /&gt;&lt;BR /&gt;And then in the input file loop till the end and for each line read using (UTL_FILE.GET_LINE (wf1_handle, value) select from the table.&lt;BR /&gt;And if you find a match then write to the tn.yes file otherwise write to the tn.no file using (UTL_FILE.PUT_LINE (wf3_handle, value);.&lt;BR /&gt;&lt;BR /&gt;You have an input file to read from all the tn and then select form a table and if matches write to the output file no.txt &lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;IA</description>
      <pubDate>Wed, 29 Jun 2005 21:46:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909777#M825076</guid>
      <dc:creator>Indira Aramandla</dc:creator>
      <dc:date>2005-06-29T21:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909778#M825077</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;indira has proposed a good solution above. You did not mention your Oracle Version. As from Oracle 9i, you also have the External Tables facility.&lt;BR /&gt;&lt;BR /&gt;see: &lt;A href="http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch12.htm#1009462" target="_blank"&gt;http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch12.htm#1009462&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;for instance, you will start with creating a directory:&lt;BR /&gt;e.g.&lt;BR /&gt;create or replace directory external_tables_dir &lt;BR /&gt;as '/datafiles/'&lt;BR /&gt;&lt;BR /&gt;then create an external table:&lt;BR /&gt;e.g.&lt;BR /&gt;create table external_tab&lt;BR /&gt;  ( text1 varchar2(4000) ,&lt;BR /&gt;    text2 varchar2(4000) ,&lt;BR /&gt;    text3 varchar2(4000)&lt;BR /&gt;  )&lt;BR /&gt;  organization external&lt;BR /&gt;  (type oracle_loader&lt;BR /&gt;   default directory external_tables_dir&lt;BR /&gt;   access parameters&lt;BR /&gt;   (&lt;BR /&gt;    records delimited by newline&lt;BR /&gt;    fields&lt;BR /&gt;    missing field values are null&lt;BR /&gt;    ( text1 position(1:4000),&lt;BR /&gt;      text2 position(4001:8000),&lt;BR /&gt;      text3 position(8001:12000)&lt;BR /&gt;     )&lt;BR /&gt;    )&lt;BR /&gt;   location ('foo.bad')&lt;BR /&gt;   )&lt;BR /&gt;  /&lt;BR /&gt;&lt;BR /&gt;and then:&lt;BR /&gt;select count(*) from external_tab&lt;BR /&gt;&lt;BR /&gt;thus, you can add additional logic by programming a plsql block!&lt;BR /&gt;&lt;BR /&gt;hope this helps too!&lt;BR /&gt;regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Wed, 29 Jun 2005 23:56:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909778#M825077</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2005-06-29T23:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909779#M825078</link>
      <description>Unfortunately, this is a production database and can not be shutdown. I am running 8.1.7.&lt;BR /&gt;&lt;BR /&gt;Thought there would be a easy way to return a value.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Jun 2005 09:23:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909779#M825078</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2005-06-30T09:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909780#M825079</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;this excerpt from oracle faq may help you.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;Can one pass operating system parameters to SQL*Plus?&lt;BR /&gt;One can pass operating system variables to sqlplus using this syntax: &lt;BR /&gt; sqlplus username/password @cmdfile.sql var1 var2 var3Parameter var1 will be mapped to SQL*Plus variable &amp;amp;1, var2 to &amp;amp;2, etc. Look at this example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; sqlplus scott/tiger @x.sql  '"test parameter"' dual&lt;BR /&gt;Where x.sql consists of: &lt;BR /&gt; select '&amp;amp;1' from &amp;amp;2;&lt;BR /&gt; exit 5;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Jun 2005 09:38:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909780#M825079</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2005-06-30T09:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909781#M825080</link>
      <description>Well just change it this way:&lt;BR /&gt;&lt;BR /&gt;sqlplus -s &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;connect admin/admin1 &lt;BR /&gt;SELECT TN from TN_TABLE WHERE TN = '$i';&lt;BR /&gt;exit;&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;This takes the password from the &lt;BR /&gt;"ps -ef" - output and terminates the sqlplus correctly.&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Thu, 30 Jun 2005 11:12:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909781#M825080</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2005-06-30T11:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909782#M825081</link>
      <description>I get an error when I try that&lt;BR /&gt;&lt;BR /&gt;SP2-0306: Invalid option.&lt;BR /&gt;Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] | [INTERNAL]&lt;BR /&gt;where &lt;LOGON&gt;  ::= &lt;USERNAME&gt;[/&lt;PASSWORD&gt;][@&lt;CONNECT_STRING&gt;] | /&lt;BR /&gt;&lt;/CONNECT_STRING&gt;&lt;/PASSWORD&gt;&lt;/USERNAME&gt;&lt;/LOGON&gt;</description>
      <pubDate>Thu, 30 Jun 2005 12:36:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909782#M825081</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2005-06-30T12:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909783#M825082</link>
      <description>You needs are better met by a shell script that can handle both the aspects of your problem:&lt;BR /&gt;&lt;BR /&gt;1.) first you need to find out if your table has any records that meet your criteria.&lt;BR /&gt;2.) secondly, if criteria is met decide which output file they should go to tn.yes or tn.not.&lt;BR /&gt;&lt;BR /&gt;I'ave attached a shell script that does what you're looking for.&lt;BR /&gt;&lt;BR /&gt;best of luck!</description>
      <pubDate>Thu, 30 Jun 2005 18:33:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909783#M825082</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-06-30T18:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909784#M825083</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;here is my new attempt. My first one was a misunderstanding of your question.&lt;BR /&gt;&lt;BR /&gt;hope, that works for you.&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#tn.ksh&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;cat tn.sql &amp;gt; tmp.sql&lt;BR /&gt;awk -f tn.awk tn.file &amp;gt;&amp;gt; tmp.sql&lt;BR /&gt;echo spool off; &amp;gt;&amp;gt; tmp.sql&lt;BR /&gt;echo exit &amp;gt;&amp;gt; tmp.sql&lt;BR /&gt;cat tn.file | sqlplus /nolog @tmp&lt;BR /&gt;grep "^EXN" tn.log | nawk -F\t '{print $2}' &amp;gt; tn.no&lt;BR /&gt;grep "^EXY" tn.log | nawk -F\t '{print $2}' &amp;gt; tn.yes&lt;BR /&gt;&lt;BR /&gt;#tn.awk&lt;BR /&gt;BEGIN{}&lt;BR /&gt;{&lt;BR /&gt;  print "select decode(count(TN),1,'EXY\t',0,'EXN\t')||'"$0"' from TN_TABLE where TN = '"$0"';"&lt;BR /&gt;}&lt;BR /&gt;END{}&lt;BR /&gt;&lt;BR /&gt;#tn.sql&lt;BR /&gt;set echo off&lt;BR /&gt;set feedback off&lt;BR /&gt;set termout off&lt;BR /&gt;set timing off&lt;BR /&gt;set heading off&lt;BR /&gt;set pages 0&lt;BR /&gt;set lines 500&lt;BR /&gt;connect / as sysdba;&lt;BR /&gt;spool tn.log&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Jul 2005 07:47:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909784#M825083</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2005-07-01T07:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: sql script to check database for specific record</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909785#M825084</link>
      <description>Thanks for the info!</description>
      <pubDate>Thu, 25 Aug 2005 16:06:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-script-to-check-database-for-specific-record/m-p/4909785#M825084</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2005-08-25T16:06:27Z</dc:date>
    </item>
  </channel>
</rss>

