<?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: Create a script to insert entry in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162196#M902647</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;my idea would be:&lt;BR /&gt;create a temporary table with&lt;BR /&gt;create table blabla as&lt;BR /&gt;  select from CODE_LOGIN where LOGIN_ID = 'DEV'&lt;BR /&gt;insert into table CODE_LOGIN as select from blabla;&lt;BR /&gt;drop table blabla&lt;BR /&gt;&lt;BR /&gt;I hope, that works,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
    <pubDate>Mon, 12 Jan 2004 16:14:32 GMT</pubDate>
    <dc:creator>Michael Schulte zur Sur</dc:creator>
    <dc:date>2004-01-12T16:14:32Z</dc:date>
    <item>
      <title>Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162195#M902646</link>
      <description>Heres my scenerio,&lt;BR /&gt;&lt;BR /&gt;This is the select statement to show all the table...&lt;BR /&gt;select  *&lt;BR /&gt;from CODE_LOGIN&lt;BR /&gt;order by CODE;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CODE  TYPE  LOGIN_ID PASSWORD ENABLED&lt;BR /&gt;ASHRM, SWITCH, log,  5555,  1&lt;BR /&gt;BCHTM, SWITCH, log,  5555,  1&lt;BR /&gt;BDVNM, SWITCH, log,  5555,  1&lt;BR /&gt;BNRVM, SWITCH, log,  5555,  1&lt;BR /&gt;BRNDM, SWITCH, dev,  april,  1&lt;BR /&gt;DAPHM, SWITCH, dev,  april,  1&lt;BR /&gt;FSBRM, SWITCH, log,  5555,  1&lt;BR /&gt;GDRPM, SWITCH, log,  5555,  1&lt;BR /&gt;GDRVM, SWITCH, log,  5555,  1&lt;BR /&gt;(there is alot more, 70)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I then made a script and that would only show the CODE if it matches 'dev'&lt;BR /&gt;&lt;BR /&gt;select CODE&lt;BR /&gt;from CODE_LOGIN&lt;BR /&gt;where LOGIN_ID = 'DEV'&lt;BR /&gt;order by CODE;&lt;BR /&gt;&lt;BR /&gt;BRNDM&lt;BR /&gt;DAPHM&lt;BR /&gt;...&lt;BR /&gt;(about 50 entries)&lt;BR /&gt;I have this saved to a file. All the CODES that have a login_id of 'dev'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now the big part...&lt;BR /&gt;How do I insert a new record, basically I am adding another login_id to the CODE. But, only if the CODE had the dev login id.&lt;BR /&gt;Can I do a for loop to look at the file that I saved, and insert values into table.&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; insert into CODE_LOGIN (CODE, TYPE, LOGIN_ID, PASSWORD, ENABLED)&lt;BR /&gt;  2  values     (CODE(??),'SWITCH', 'DEV', 'APRIL', 1);&lt;BR /&gt;  &lt;BR /&gt;&lt;BR /&gt;The ? is where the problem is... How do I get the CODE? There are about 50 entries, but they will have the same user_id and passwd inserted in all 50.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated.</description>
      <pubDate>Mon, 12 Jan 2004 15:56:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162195#M902646</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-01-12T15:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162196#M902647</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;my idea would be:&lt;BR /&gt;create a temporary table with&lt;BR /&gt;create table blabla as&lt;BR /&gt;  select from CODE_LOGIN where LOGIN_ID = 'DEV'&lt;BR /&gt;insert into table CODE_LOGIN as select from blabla;&lt;BR /&gt;drop table blabla&lt;BR /&gt;&lt;BR /&gt;I hope, that works,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jan 2004 16:14:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162196#M902647</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-01-12T16:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162197#M902648</link>
      <description>Oops,&lt;BR /&gt;&lt;BR /&gt;forgot:&lt;BR /&gt;update blabla set LOGIN='NEWDEV';&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jan 2004 16:23:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162197#M902648</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-01-12T16:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162198#M902649</link>
      <description>Since you have teh target 'code' values already in a file, you could post-process that file with awk or perl to generate the desired sql statements.&lt;BR /&gt;&lt;BR /&gt;There are many neat SQL solutions.&lt;BR /&gt;Bu in line with you tem file, here are some ideas:&lt;BR /&gt;&lt;BR /&gt;For example, assume the file is called a.dat&lt;BR /&gt;Now create a.awk containing:&lt;BR /&gt;{print "insert into CODE_LOGIN (CODE, TYPE, LOGIN_ID, PASSWORD, ENABLED) values ('" $1 "','SWITCH','DEV','APRIL',1);"}&lt;BR /&gt;&lt;BR /&gt;Now execute:&lt;BR /&gt;awk -f a.awk &amp;lt; a.dat &amp;gt; a.sql&lt;BR /&gt;and&lt;BR /&gt;sqlplus @a.sql&lt;BR /&gt;&lt;BR /&gt;In perl you can of course readily piped the morphed input data straight into sqlplus, which coudl be interesting for frequently repeated transformation.&lt;BR /&gt;&lt;BR /&gt;Or you could use sql to generate sql...&lt;BR /&gt;&lt;BR /&gt;select 'insert into CODE_LOGIN (CODE, TYPE, LOGIN_ID, PASSWORD, ENABLED)' ||&lt;BR /&gt;' values (''' || code ||&lt;BR /&gt;''',''SWITCH'',''DEV'',''APRIL'',1);'&lt;BR /&gt;from test where login_id = 'DEV'&lt;BR /&gt;/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You have set sqlplus NOT to print header/footers or post-edit the spool file.&lt;BR /&gt;&lt;BR /&gt;The ugly part is all those single quotes as we need a double-single quote in a quoted string. The above SQL takes an string with 'insert...' adds the current field value of code and concatenates the other values. You then execute the generated output. Good fun!&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jan 2004 17:31:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162198#M902649</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-01-12T17:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162199#M902650</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Mostly you should be able to do all this directyl witha single statement. I'm not sure I fully understand your requirement but it could be something like:&lt;BR /&gt;&lt;BR /&gt;insert into code_login&lt;BR /&gt; select code, 'switch', 'dev', 'APRIL', 1 &lt;BR /&gt; from code_login&lt;BR /&gt; where login_id = 'dev';&lt;BR /&gt;&lt;BR /&gt;I used "'switch'" as per your partial example.&lt;BR /&gt;But if you wanted the same value as the original record, then just use "type".&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2004 00:28:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162199#M902650</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-01-13T00:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162200#M902651</link>
      <description>Try the following example which uses constraints:&lt;BR /&gt;&lt;BR /&gt;create table temp1 (code char(5), login_id char(3));&lt;BR /&gt;insert into temp1 values ('AAAA', 'DEV');&lt;BR /&gt;insert into temp1 values ('BBBB', 'DEV');&lt;BR /&gt;insert into temp1 values ('CCCC', 'PRD');&lt;BR /&gt;&lt;BR /&gt;create table temp2 as select * from temp1 where login_id='DEV';&lt;BR /&gt;&lt;BR /&gt;alter table temp1 add constraint constraint_name1 primary key (code);&lt;BR /&gt;alter table temp2 add constraint constraint_name2 primary key (code);&lt;BR /&gt;alter table temp1 add constraint constraint_name3 foreign key (code) references temp2 (code);&lt;BR /&gt;&lt;BR /&gt;delete from temp1;&lt;BR /&gt;insert into temp1 values ('AAAA', 'DEV');&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Tue, 13 Jan 2004 00:57:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162200#M902651</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-01-13T00:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a script to insert entry</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162201#M902652</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;try:&lt;BR /&gt;&lt;BR /&gt;insert into code_login (code, type, login_id, password, enabled)&lt;BR /&gt;select code||'2', type, login_id, password, enabled&lt;BR /&gt;from code_login&lt;BR /&gt;where login_id = 'DEV';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;where you can change the &amp;lt;&amp;lt; code||'2' &amp;gt;&amp;gt; as desired.&lt;BR /&gt;&lt;BR /&gt;hope this helps&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2004 01:25:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/create-a-script-to-insert-entry/m-p/3162201#M902652</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2004-01-13T01:25:20Z</dc:date>
    </item>
  </channel>
</rss>

