<?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: Ask for SQL statement in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690498#M842563</link>
    <description>Hi,&lt;BR /&gt;Which db are you using? Are you using oracle and sqlplus?&lt;BR /&gt;If so you can format columns with something like:&lt;BR /&gt;column &lt;COL_NAME&gt; format a20     (for varchar)&lt;BR /&gt;and&lt;BR /&gt;column &lt;COL_NAME&gt; format 99.9    (for numbers)&lt;BR /&gt;Regards.&lt;BR /&gt;L.B.&lt;/COL_NAME&gt;&lt;/COL_NAME&gt;</description>
    <pubDate>Tue, 26 Mar 2002 08:06:23 GMT</pubDate>
    <dc:creator>LBertoglio</dc:creator>
    <dc:date>2002-03-26T08:06:23Z</dc:date>
    <item>
      <title>Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690497#M842562</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have data like this:&lt;BR /&gt;SN       PN  COMP_DATA_ITEM   COMP_DATA_VALUE  &lt;BR /&gt;===============================================TWWW2   PN1   DATECODE           DATE1 &lt;BR /&gt;TWWW2   PN1   LOTCODE            LOT1 &lt;BR /&gt;TWWW2   PN1   SUPPLY_CODE        SUP1 &lt;BR /&gt;TWWW2   PN1   PART_SERIAL        PART1 &lt;BR /&gt;TWWW2   PN2   DATECODE           DATE2&lt;BR /&gt;TWWW2   PN2   LOTCODE            LOT2 &lt;BR /&gt;TWWW2   PN2   SUPPLY_CODE        SUP2&lt;BR /&gt;TWWW2   PN2   PART_SERIAL        PART2&lt;BR /&gt;&lt;BR /&gt;and I want this output from sql:&lt;BR /&gt;SN    PN  DATECODE LOTCODE SUPPLY_CODE PART_SERIAL&lt;BR /&gt;==================================================&lt;BR /&gt;TWWW2 PN1 DATE1    LOT1    SUP1        PART1 &lt;BR /&gt;TWWW2 PN2 DATE2    LOT2    SUP2        PART2 &lt;BR /&gt;&lt;BR /&gt;How can I write SQL , I am new with it.&lt;BR /&gt;appreciate your help and point will given.</description>
      <pubDate>Tue, 26 Mar 2002 07:43:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690497#M842562</guid>
      <dc:creator>Printaporn_1</dc:creator>
      <dc:date>2002-03-26T07:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690498#M842563</link>
      <description>Hi,&lt;BR /&gt;Which db are you using? Are you using oracle and sqlplus?&lt;BR /&gt;If so you can format columns with something like:&lt;BR /&gt;column &lt;COL_NAME&gt; format a20     (for varchar)&lt;BR /&gt;and&lt;BR /&gt;column &lt;COL_NAME&gt; format 99.9    (for numbers)&lt;BR /&gt;Regards.&lt;BR /&gt;L.B.&lt;/COL_NAME&gt;&lt;/COL_NAME&gt;</description>
      <pubDate>Tue, 26 Mar 2002 08:06:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690498#M842563</guid>
      <dc:creator>LBertoglio</dc:creator>
      <dc:date>2002-03-26T08:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690499#M842564</link>
      <description>I'll assume an Oracle 8 or later DB.&lt;BR /&gt;&lt;BR /&gt;You've got overnormalized data. So denormalize it first, then do an ordinary join.&lt;BR /&gt;&lt;BR /&gt;Select MA.SN, MA.PN, DT.DATECODE, &lt;BR /&gt;  LT.LOTCODE, SU.SUPPLY_CODE, PA.PART_SERIAL&lt;BR /&gt;From&lt;BR /&gt;  (Select distinct SN, PN&lt;BR /&gt;   From OVERN) MA,&lt;BR /&gt;  (Select SN, PN, COMP_DATA_VALUE DATECODE&lt;BR /&gt;   From OVERN&lt;BR /&gt;   Where COMP_DATA_ITEM = 'DATECODE' ) DT,&lt;BR /&gt;  (Select SN, PN, COMP_DATA_VALUE LOTCODE&lt;BR /&gt;   From OVERN&lt;BR /&gt;   Where COMP_DATA_ITEM = 'LOTCODE' ) LT,&lt;BR /&gt;  (Select SN, PN, COMP_DATA_VALUE SUPPLY_CODE&lt;BR /&gt;   From OVERN&lt;BR /&gt;   Where COMP_DATA_ITEM = 'SUPPLY_CODE' ) SU,&lt;BR /&gt;  (Select SN, PN, COMP_DATA_VALUE PART_SERIAL&lt;BR /&gt;   From OVERN&lt;BR /&gt;   Where COMP_DATA_ITEM = 'PART_SERIAL' ) PA&lt;BR /&gt;Where&lt;BR /&gt;  MA.SN = DT.SN (+) and&lt;BR /&gt;  MA.PN = DT.PN (+) and&lt;BR /&gt;  MA.SN = LT.SN (+) and&lt;BR /&gt;  MA.PN = LT.PN (+) and&lt;BR /&gt;  MA.SN = SU.SN (+) and&lt;BR /&gt;  MA.PN = SU.PN (+) and&lt;BR /&gt;  MA.SN = PA.SN (+) and&lt;BR /&gt;  MA.PN = PA.PN (+)&lt;BR /&gt;&lt;BR /&gt;This assumes that the keys are SN and PN.&lt;BR /&gt;&lt;BR /&gt;It's not going to be quick however. If you need it to be fast, do it one step at a time using insert for the MA and update after...&lt;BR /&gt;&lt;BR /&gt;Have fun... ;-)&lt;BR /&gt;&lt;BR /&gt;Ryan</description>
      <pubDate>Tue, 26 Mar 2002 08:43:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690499#M842564</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-03-26T08:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690500#M842565</link>
      <description>thanks Ryan , it work.&lt;BR /&gt;but this case still open for more ideas.</description>
      <pubDate>Tue, 26 Mar 2002 09:20:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690500#M842565</guid>
      <dc:creator>Printaporn_1</dc:creator>
      <dc:date>2002-03-26T09:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690501#M842566</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;SOlution from Ryan is work at this current time&lt;BR /&gt;but in near future , if there is more than 4 COMP_DATA_ITEM other than DATECODE ,LOTCODE  SUPPLY_CODE and PART_SERIAL , like user can add another COMP_DATA_ITEM  and value.&lt;BR /&gt;then we need to change Ryan query ,&lt;BR /&gt;Do we have other solution not only limit to query.&lt;BR /&gt;&lt;BR /&gt;thanks and appreciate.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Mar 2002 10:22:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690501#M842566</guid>
      <dc:creator>Printaporn_1</dc:creator>
      <dc:date>2002-03-26T10:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690502#M842567</link>
      <description>I think I know what you mean, but you'll face a fundamental relational database issue in that the column selection of a view cannot be dynamic. &lt;BR /&gt;&lt;BR /&gt;If you are using this query in an application rather than in a view, what you need to do is create a meta-query that creates the second query, or process the data into a crosstab using the native application code.&lt;BR /&gt;&lt;BR /&gt;You could also redefine a view using some sort of periodic batch process.&lt;BR /&gt;&lt;BR /&gt;Aside: In general it is not advisable to let users modify the attributes of application data. This is essentially what you are doing as each COMP_DATA_ITEM represents an attribute. I suspect that eventually the data will become "dirty" as users add attributes that were not intended by the designer. This could get especially bad if the users start adding attributes that have a many-to-one relationship with your key. (but then again, who knows...)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Mar 2002 11:14:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690502#M842567</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-03-26T11:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690503#M842568</link>
      <description>wadeekup...&lt;BR /&gt;&lt;BR /&gt;There's another option we used for a similar problem in one of our applications.&lt;BR /&gt;&lt;BR /&gt;Create a PL/SQL stored function (myvaluefunc) that takes your key as parameters and returns a string usable by your application code. &lt;BR /&gt;&lt;BR /&gt;This string is the concatenation of all the possible fields (sorted how you like, perhaps with a sort field in another code table that controls the values of comp_data_item).&lt;BR /&gt;&lt;BR /&gt;You also would need another function that would return the header fields. Then, create your view or select like:&lt;BR /&gt;&lt;BR /&gt;Select&lt;BR /&gt;  1 DISP_ORD, 'key1', 'key2', myheaderfunc(key1,key2) MyValues&lt;BR /&gt;From&lt;BR /&gt;  Dual&lt;BR /&gt;Union Select&lt;BR /&gt;  2 DISP_ORD, key1, key2, myvaluefunc(key1,key2) MyValues&lt;BR /&gt;From&lt;BR /&gt;  OverNorm&lt;BR /&gt;Order by &lt;BR /&gt;  DISP_ORD&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Mar 2002 11:28:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690503#M842568</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-03-26T11:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690504#M842569</link>
      <description>khortoadkup...&lt;BR /&gt;&lt;BR /&gt;the second part of the union in the above view needs only select the distinct values of overnorm, so instead of &lt;BR /&gt;&lt;BR /&gt;from&lt;BR /&gt;  overnorm&lt;BR /&gt;&lt;BR /&gt;use&lt;BR /&gt;&lt;BR /&gt;from &lt;BR /&gt;  (select distinct key1, key2 from overnorm)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Mar 2002 11:31:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690504#M842569</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-03-26T11:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Ask for SQL statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690505#M842570</link>
      <description>Hi Ryan,&lt;BR /&gt;Bon jour&lt;BR /&gt;Surprise that you know some of my language.&lt;BR /&gt;thanks a lot for your guideline , at least I can start.&lt;BR /&gt;Merci&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Mar 2002 02:41:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ask-for-sql-statement/m-p/2690505#M842570</guid>
      <dc:creator>Printaporn_1</dc:creator>
      <dc:date>2002-03-27T02:41:00Z</dc:date>
    </item>
  </channel>
</rss>

