<?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/shell looping question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000043#M914404</link>
    <description>Have your script "addem" :&lt;BR /&gt;&lt;BR /&gt;while read -r tspace datafile filesize&lt;BR /&gt;do&lt;BR /&gt;echo "Alter tablespace ..... " &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;then run your script and pipe the output :&lt;BR /&gt;&lt;BR /&gt;sh addem | sqlplus internal &lt;BR /&gt;&lt;BR /&gt;(I don't know sqlplus at all but most other db vendor command line utilities take stuff froms stdin.</description>
    <pubDate>Thu, 19 Jun 2003 08:48:35 GMT</pubDate>
    <dc:creator>JJ_4</dc:creator>
    <dc:date>2003-06-19T08:48:35Z</dc:date>
    <item>
      <title>sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000037#M914398</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;   I am trying to script the method of adding data files to a tablespace using shell script and sql. for eg:&lt;BR /&gt;while read -r tspace datafile filesize&lt;BR /&gt;do&lt;BR /&gt;  sqlplus internal &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;  Alter tablespace .....&lt;BR /&gt;  exit&lt;BR /&gt;  EOF&lt;BR /&gt;done&lt;INFILE&gt;&lt;/INFILE&gt;&lt;BR /&gt;  The problem with this method is for every data file added, the script will login to sqlplus. This will be inefficient when lot of datafiles are added.  Is there a way where i can keep the looping method but have only one sql login connection?  &lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;Roger</description>
      <pubDate>Tue, 17 Jun 2003 19:30:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000037#M914398</guid>
      <dc:creator>Roger Baptiste</dc:creator>
      <dc:date>2003-06-17T19:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000038#M914399</link>
      <description>how about....&lt;BR /&gt;&lt;BR /&gt;while read -r tspace datafile filesize &lt;BR /&gt;do &lt;BR /&gt;echo "Alter tablespace ..... " &amp;gt;&amp;gt;myscript.sql&lt;BR /&gt;done&lt;INFILE&gt;&lt;/INFILE&gt;&lt;BR /&gt;sqlplus internal @myscript.sql</description>
      <pubDate>Tue, 17 Jun 2003 19:51:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000038#M914399</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2003-06-17T19:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000039#M914400</link>
      <description>Just a thought, but you might be better off keeping it as a single datafile rather than scripting the entire thing at once.  The overhead is high, but it would give you a change to verify that there is enough space to add the datafile to the disk as well, which might cut-down on unexpected errors.&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Tue, 17 Jun 2003 21:05:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000039#M914400</guid>
      <dc:creator>Brian Crabtree</dc:creator>
      <dc:date>2003-06-17T21:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000040#M914401</link>
      <description>hi roger,&lt;BR /&gt;&lt;BR /&gt;a few ideas i can think of:&lt;BR /&gt;try&lt;BR /&gt;===============================&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;TBS=tbs&lt;BR /&gt;DF=/u01/oracle/oradata/file&lt;BR /&gt;sqlplus yd/yd@dev &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;&lt;BR /&gt;declare&lt;BR /&gt;  st varchar2(100);&lt;BR /&gt;begin&lt;BR /&gt;for c1 in (select rownum from all_objects where rownum &amp;lt; 5) loop&lt;BR /&gt;st:='alter tablespace $TBS'||c1.rownum||' add datafile $DF'||c1.rownum;&lt;BR /&gt;dbms_output.put_line(st);&lt;BR /&gt;execute immediate st;&lt;BR /&gt;dbms_output.put_line('Modified.');&lt;BR /&gt;end loop;&lt;BR /&gt;exception&lt;BR /&gt;when others then&lt;BR /&gt;dbms_output.put_line(sqlerrm);&lt;BR /&gt;end;&lt;BR /&gt;/&lt;BR /&gt;eof&lt;BR /&gt;==============================================&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Wed, 18 Jun 2003 04:16:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000040#M914401</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2003-06-18T04:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000041#M914402</link>
      <description>sorry for the garbled output. attached the demo script.&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Wed, 18 Jun 2003 04:24:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000041#M914402</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2003-06-18T04:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000042#M914403</link>
      <description>Totally agree with Jim, in my opinion,  I will build the sql script first, and then batch process it.</description>
      <pubDate>Wed, 18 Jun 2003 04:26:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000042#M914403</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-06-18T04:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000043#M914404</link>
      <description>Have your script "addem" :&lt;BR /&gt;&lt;BR /&gt;while read -r tspace datafile filesize&lt;BR /&gt;do&lt;BR /&gt;echo "Alter tablespace ..... " &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;then run your script and pipe the output :&lt;BR /&gt;&lt;BR /&gt;sh addem | sqlplus internal &lt;BR /&gt;&lt;BR /&gt;(I don't know sqlplus at all but most other db vendor command line utilities take stuff froms stdin.</description>
      <pubDate>Thu, 19 Jun 2003 08:48:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000043#M914404</guid>
      <dc:creator>JJ_4</dc:creator>
      <dc:date>2003-06-19T08:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000044#M914405</link>
      <description>I guess my question would be "why do you want to do this?"&lt;BR /&gt;It's really not good to have a large number of datafiles - there are limits and each one will need a process to connect to the database.&lt;BR /&gt;&lt;BR /&gt;The way I maintain my databases is a bit different. For one I have largefile systems enabled so I can go above 2GB. I just extend the tablespaces using the following script.&lt;BR /&gt;Once it runs, I have a script with all datafiles listed - it's just a matter of changing the sizes for those tablespaces that need to grow. Running the script "alters" all the datafiles - but only the changed ones actually grow. We use OFA - so all my datafiles are in one tree - adjust the find statement as needed.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;echo "set echo on" &amp;gt; alter_datafiles_all.sql&lt;BR /&gt;echo "spool alter_datafiles_all.log" &amp;gt;&amp;gt; alter_datafiles_all.sql&lt;BR /&gt;find /oracle/DATA -type f -exec ls -s {} \; |grep -v "+"|grep -v "/ctrl"|sort -k2|awk '{printf("%s\047%s\047\t%s%d%s\n","alter database datafile ",$2," resize ",$1/1024/2,"M;")}'&amp;gt;&amp;gt; alter_datafiles_all.sql&lt;BR /&gt;echo "exit" &amp;gt;&amp;gt; alter_datafiles_all.sql</description>
      <pubDate>Thu, 19 Jun 2003 14:29:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000044#M914405</guid>
      <dc:creator>bob hollis</dc:creator>
      <dc:date>2003-06-19T14:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: sql/shell looping question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000045#M914406</link>
      <description>&lt;BR /&gt;Thanks for all the responses. &lt;BR /&gt;&lt;BR /&gt;My question on using looping through sql script in a shell script was not specifically to adding datafiles; The same process can be applied to other repetitive tasks too like creating tablespaces etc.&lt;BR /&gt;&lt;BR /&gt; I know little bit of sql but Yogiraj's script seems intresting to try.  Jim's solution seems simple.&lt;BR /&gt;&lt;BR /&gt;  Bob's suggestion is fine too, but the only issue is when we are creating new VG's/DG's we would need to create new datafiles. But it's a handy way to  extend  existing files.&lt;BR /&gt;&lt;BR /&gt;Any further suggestions are also welcome. Some of the answers deserved a 8-10, but am holding the rabbit until i try them succesfully.&lt;BR /&gt;&lt;BR /&gt;Roger</description>
      <pubDate>Thu, 19 Jun 2003 21:51:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-shell-looping-question/m-p/3000045#M914406</guid>
      <dc:creator>Roger Baptiste</dc:creator>
      <dc:date>2003-06-19T21:51:22Z</dc:date>
    </item>
  </channel>
</rss>

