<?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: perl split file for database insert in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025585#M429583</link>
    <description>&amp;gt;&amp;gt; Yes, the vendor should have put a sort in the app. but, I am now learning perl to do this.&lt;BR /&gt;&lt;BR /&gt;Sorry Laura, but that is a no go.&lt;BR /&gt;Oracle may, and will, return data in any order it pleases to, unless instructed to apply 'ORDER'.&lt;BR /&gt;&lt;BR /&gt;Even when one inserts rows in order, then it is only likely, but not garantueed, that a select will return them in order of insertion.&lt;BR /&gt;&lt;BR /&gt;Now if you like gambling then you can do the select -&amp;gt; truncate -&amp;gt; insert business, but then why not do that all within Oracle as John suggests. I suppose you could pipe those commands into Oracle from a perl script:&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt;open (SQL, "| sqlplus....");&lt;BR /&gt;print SQL...&lt;BR /&gt;&lt;BR /&gt;On perl usage. I would NOT suck data into an regular array first, only to re-store as associative array. Why not process as you go:&lt;BR /&gt;&lt;BR /&gt;my $sql_command = &amp;lt;&amp;lt; "EOF"&lt;BR /&gt;:&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;foreach (`$sql_command`) {&lt;BR /&gt;   chomp;&lt;BR /&gt;   my ($key,$value) = split;&lt;BR /&gt;   $table{$key} = $value;&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;for my $key (sort keys %table) {&lt;BR /&gt;print "$key is $table{$key}\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck! (You'll need some :-).&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 30 Jan 2007 17:42:59 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2007-01-30T17:42:59Z</dc:date>
    <item>
      <title>perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025582#M429580</link>
      <description>I am probably making this really difficult but...&lt;BR /&gt;First off I can not use the DBI:DBD oracle module.&lt;BR /&gt;&lt;BR /&gt;What I need to do is pull data from a table, sort, then put back in table.&lt;BR /&gt;Yes, the vendor should have put a sort in the app. but, I am now learning perl to do this.&lt;BR /&gt;&lt;BR /&gt;I have pulled the data into an array, (dont know if this is correct for then inserting back.)&lt;BR /&gt;&lt;BR /&gt;sub doSqlSelect {&lt;BR /&gt;&lt;BR /&gt;my @buffer = qx { sqlplus -S $oraLoginId &amp;lt;&amp;lt;'EOF';&lt;BR /&gt;set heading off&lt;BR /&gt;set pagesize 0&lt;BR /&gt;set feedback off&lt;BR /&gt;SELECT feature||','||description&lt;BR /&gt;FROM vt_feature&lt;BR /&gt;ORDER by 1;&lt;BR /&gt;EOF&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;So now I have my array, separated by comma.&lt;BR /&gt;I need to truncate the table. (deal with that later)&lt;BR /&gt;But, now I need to insert back into the table.&lt;BR /&gt;I was thinking this should have been a hash, or do I split to array?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jan 2007 13:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025582#M429580</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2007-01-30T13:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025583#M429581</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Hashes require unique keys, but should be ideal:&lt;BR /&gt;&lt;BR /&gt;my %table;&lt;BR /&gt;...&lt;BR /&gt;$table{$feature} = $description;&lt;BR /&gt;...&lt;BR /&gt;for my $key (sort keys %table) {&lt;BR /&gt;    print "$key is $table{$key}\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 30 Jan 2007 13:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025583#M429581</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-01-30T13:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025584#M429582</link>
      <description>Why not just do all of this in Oracle itself?&lt;BR /&gt;&lt;BR /&gt;alter table vt_feature rename to vt_feature_old;&lt;BR /&gt;&lt;BR /&gt;create table vt_feature as &lt;BR /&gt;(SELECT feature||','||description&lt;BR /&gt;FROM vt_feature&lt;BR /&gt;ORDER by 1);&lt;BR /&gt;&lt;BR /&gt;drop table vt_feature_old;&lt;BR /&gt;&lt;BR /&gt;... Don't forget to recreate indexes, grant permissions, etc.&lt;BR /&gt;&lt;BR /&gt;I must say though, I'm wondering why you want to sort the data in an Oracle database and not discuss indexes, primary keys, constraints...</description>
      <pubDate>Tue, 30 Jan 2007 14:36:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025584#M429582</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2007-01-30T14:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025585#M429583</link>
      <description>&amp;gt;&amp;gt; Yes, the vendor should have put a sort in the app. but, I am now learning perl to do this.&lt;BR /&gt;&lt;BR /&gt;Sorry Laura, but that is a no go.&lt;BR /&gt;Oracle may, and will, return data in any order it pleases to, unless instructed to apply 'ORDER'.&lt;BR /&gt;&lt;BR /&gt;Even when one inserts rows in order, then it is only likely, but not garantueed, that a select will return them in order of insertion.&lt;BR /&gt;&lt;BR /&gt;Now if you like gambling then you can do the select -&amp;gt; truncate -&amp;gt; insert business, but then why not do that all within Oracle as John suggests. I suppose you could pipe those commands into Oracle from a perl script:&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt;open (SQL, "| sqlplus....");&lt;BR /&gt;print SQL...&lt;BR /&gt;&lt;BR /&gt;On perl usage. I would NOT suck data into an regular array first, only to re-store as associative array. Why not process as you go:&lt;BR /&gt;&lt;BR /&gt;my $sql_command = &amp;lt;&amp;lt; "EOF"&lt;BR /&gt;:&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;foreach (`$sql_command`) {&lt;BR /&gt;   chomp;&lt;BR /&gt;   my ($key,$value) = split;&lt;BR /&gt;   $table{$key} = $value;&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;for my $key (sort keys %table) {&lt;BR /&gt;print "$key is $table{$key}\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck! (You'll need some :-).&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jan 2007 17:42:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025585#M429583</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-01-30T17:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025586#M429584</link>
      <description>correction from my previous posting...&lt;BR /&gt;&lt;BR /&gt;create table vt_feature as&lt;BR /&gt;(SELECT feature||','||description&lt;BR /&gt;FROM vt_feature_old  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; fixed here&lt;BR /&gt;ORDER by 1);&lt;BR /&gt;&lt;BR /&gt;Sorry about that, you need to select from the backed-up tablename, not the destination.</description>
      <pubDate>Tue, 30 Jan 2007 18:41:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025586#M429584</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2007-01-30T18:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025587#M429585</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;Why not fix the code behind the vendors back? Just rename the old table and create a view with the old name on the old table properly ordered. No data will be moved. Sorry, no perl or unix stuff involved.&lt;BR /&gt;Basic Oracle stuff. Example below.&lt;BR /&gt;&lt;BR /&gt;Waddaya think?&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Hein van den Heuvel&lt;BR /&gt;HvdH Performance Consulting.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jan 30 19:46:24 2007&lt;BR /&gt;Copyright (c) 1982, 2005, Oracle.  All rights reserved.&lt;BR /&gt;SQL&amp;gt; connect hein&lt;BR /&gt;Connected.&lt;BR /&gt;SQL&amp;gt;&lt;BR /&gt;SQL&amp;gt; create table vt_feature (feature varchar(20), description varchar(50));&lt;BR /&gt;&lt;BR /&gt;Table created.&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; insert into vt_feature values  ('aap','this is a monkey');&lt;BR /&gt;1 row created.&lt;BR /&gt;SQL&amp;gt;  insert into vt_feature values  ('noot','Dutch for a nut');&lt;BR /&gt;1 row created.&lt;BR /&gt;SQL&amp;gt;  insert into vt_feature values  ('mies','Proper name for a girl');&lt;BR /&gt;1 row created.&lt;BR /&gt;SQL&amp;gt; select * from vt_feature;&lt;BR /&gt;&lt;BR /&gt;FEATURE              DESCRIPTION&lt;BR /&gt;-------------------- -----------------------&lt;BR /&gt;aap                  this is a monkey&lt;BR /&gt;noot                 Dutch for a nut&lt;BR /&gt;mies                 Proper name for a girl&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; rename  vt_feature to vt_feature_base;&lt;BR /&gt;Table renamed.&lt;BR /&gt;SQL&amp;gt; create view vt_feature as select * from vt_feature_base order by 1;&lt;BR /&gt;&lt;BR /&gt;View created.&lt;BR /&gt;SQL&amp;gt;  select * from vt_feature;&lt;BR /&gt;&lt;BR /&gt;FEATURE              DESCRIPTION&lt;BR /&gt;-------------------- -----------------------&lt;BR /&gt;aap                  this is a monkey&lt;BR /&gt;mies                 Proper name for a girl&lt;BR /&gt;noot                 Dutch for a nut&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt;  select * from vt_feature where description like 'P%';&lt;BR /&gt;&lt;BR /&gt;FEATURE              DESCRIPTION&lt;BR /&gt;-------------------- -----------------------&lt;BR /&gt;mies                 Proper name for a girl&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jan 2007 20:06:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025587#M429585</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-01-30T20:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: perl split file for database insert</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025588#M429586</link>
      <description>thanks</description>
      <pubDate>Tue, 06 Mar 2007 16:46:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-file-for-database-insert/m-p/5025588#M429586</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2007-03-06T16:46:50Z</dc:date>
    </item>
  </channel>
</rss>

