<?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 to select / insert records in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390664#M865265</link>
    <description>Jean Luc, &lt;BR /&gt;&lt;BR /&gt;You are indeed correct. I have changed the DATE datatype to CHAR with the following syntax &lt;BR /&gt;&lt;BR /&gt;WHERE TRUNC(TO_CHAR(max_date + 1, 'RRRR-MM-DD-SS-MI-HH24')) = TRUNC(a.added_date);&lt;BR /&gt;&lt;BR /&gt;Seems to be working now!&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
    <pubDate>Thu, 30 Sep 2004 10:50:45 GMT</pubDate>
    <dc:creator>Declan Heerey</dc:creator>
    <dc:date>2004-09-30T10:50:45Z</dc:date>
    <item>
      <title>SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390654#M865255</link>
      <description>I need to write some SQL or PL/SQL that will perform the following function; &lt;BR /&gt;&lt;BR /&gt;Select from table A B C and insert into table D E F– which I can do quiet easily but I need to select the row that was created yesterday and insert it into the destination table&lt;BR /&gt;&lt;BR /&gt;Also on the last day of the month I need to insert the previous days row and delete all of the other rows from the table&lt;BR /&gt;&lt;BR /&gt;Tables A, B and C contain a column added_date (data format = 2004081906254600) which is what I am using to define the rows needed to insert into table D, E and F&lt;BR /&gt;&lt;BR /&gt;Am I making sense? &lt;BR /&gt;&lt;BR /&gt;All help appreciated&lt;BR /&gt;&lt;BR /&gt;Decl</description>
      <pubDate>Thu, 30 Sep 2004 08:28:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390654#M865255</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T08:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390655#M865256</link>
      <description>Declan,&lt;BR /&gt;&lt;BR /&gt;is the added_date DATE format ?&lt;BR /&gt;&lt;BR /&gt;then the process seems to be the same :&lt;BR /&gt;You always pick up rows from previous day , but on the last day of the month you must truncate the table beforehand.&lt;BR /&gt;This could be check with :&lt;BR /&gt;TO_CHAR(SYSDATE,'MM') &amp;lt;&amp;gt; TO_CHAR(SYSDATE + 1,'MM')&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Thu, 30 Sep 2004 09:22:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390655#M865256</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T09:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390656#M865257</link>
      <description>Jean-Luc, &lt;BR /&gt;&lt;BR /&gt;I should have mentioned that i need to keep the last record of the month to start the next months history log. &lt;BR /&gt;&lt;BR /&gt;I suppose i could truncate the table and then reselect the data for the previous day. &lt;BR /&gt;&lt;BR /&gt;At the moment i have something like this &lt;BR /&gt;&lt;BR /&gt;CREATE OR REPLACE PROCEDURE history &lt;BR /&gt;AS&lt;BR /&gt;  max_date              DATE;&lt;BR /&gt;  number_of_days_to_do        NUMBER;&lt;BR /&gt;  i                     NUMBER; &lt;BR /&gt;&lt;BR /&gt;  CURSOR lc_get_max_date  &lt;BR /&gt;  IS&lt;BR /&gt;  SELECT MAX(added_date)&lt;BR /&gt;  FROM   table_history;&lt;BR /&gt;&lt;BR /&gt;BEGIN&lt;BR /&gt;&lt;BR /&gt;  OPEN lc_get_max_date;&lt;BR /&gt;  FETCH lc_get_max_date INTO max_date; &lt;BR /&gt;  IF lc_get_max_date%NOTFOUND THEN &lt;BR /&gt;    max_date:= TO_DATE('01-'||TO_CHAR(SYSDATE,'MON-RR'),'DD-MON-RR'); &lt;BR /&gt;  END IF;&lt;BR /&gt;  CLOSE lc_get_max_date;&lt;BR /&gt;&lt;BR /&gt;  number_of_days_to_do := SYSDATE-max_date-1; &lt;BR /&gt;&lt;BR /&gt;  FOR i IN 1..number_of_days_to_do LOOP &lt;BR /&gt;&lt;BR /&gt;  INSERT INTO table_history(account_id, net_asset_value, status,&lt;BR /&gt;added_by, added_date, updated_by, updated_date) &lt;BR /&gt;  SELECT account_id, net_asset_value, status, added_by, added_date,&lt;BR /&gt;updated_by, updated_date &lt;BR /&gt;  FROM table&lt;BR /&gt;****  WHERE TRUNC(max_date)+1 = TRUNC(added_date);&lt;BR /&gt;  &lt;BR /&gt;  END LOOP;&lt;BR /&gt;END;&lt;BR /&gt;&lt;BR /&gt;BUT THE TRUNC line does not work!&lt;BR /&gt;&lt;BR /&gt;Thanks for the help</description>
      <pubDate>Thu, 30 Sep 2004 09:33:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390656#M865257</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T09:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390657#M865258</link>
      <description>Sorry,&lt;BR /&gt;&lt;BR /&gt;but could you answer :&lt;BR /&gt;is the added_date DATE format ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Sep 2004 09:52:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390657#M865258</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T09:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390658#M865259</link>
      <description>Jean Luc, &lt;BR /&gt;&lt;BR /&gt;Sorry Jean Luc the answer is no the column is VARCHAR2(40) &lt;BR /&gt;&lt;BR /&gt;Declan</description>
      <pubDate>Thu, 30 Sep 2004 09:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390658#M865259</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T09:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390659#M865260</link>
      <description>I think the pb is you have 2 different datatypes :&lt;BR /&gt;WHERE TRUNC(max_date)+1 = TRUNC(added_date);&lt;BR /&gt;&lt;BR /&gt;max_date DATE&lt;BR /&gt;added_date VARCHAR2&lt;BR /&gt;&lt;BR /&gt;you need to convert one or the other &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Thu, 30 Sep 2004 10:09:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390659#M865260</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T10:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390660#M865261</link>
      <description>At the column level ?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Sep 2004 10:13:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390660#M865261</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T10:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390661#M865262</link>
      <description>no.&lt;BR /&gt;in the query&lt;BR /&gt;&lt;BR /&gt;where TRUNC(TO_CHAR(&lt;YOURDATE&gt; + 1, '&lt;FORMAT&gt;)) = TRUNC(...)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc&lt;/FORMAT&gt;&lt;/YOURDATE&gt;</description>
      <pubDate>Thu, 30 Sep 2004 10:24:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390661#M865262</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T10:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390662#M865263</link>
      <description>Apologies Jean Luc i'm having a paddy with this. I realised my mistake after i'd sent my last reply :o) What do you mean by format? VARCHAR2?</description>
      <pubDate>Thu, 30 Sep 2004 10:29:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390662#M865263</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T10:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390663#M865264</link>
      <description>Well, let's illustrate with this &lt;BR /&gt;SQLWKS&amp;gt; select  user&lt;BR /&gt;     2&amp;gt; from dual&lt;BR /&gt;     3&amp;gt; where trunc(SYSDATE)=trunc('20040930')&lt;BR /&gt;     4&amp;gt; &lt;BR /&gt;where trunc(SYSDATE)=trunc('20040930')&lt;BR /&gt;                    *&lt;BR /&gt;ORA-00932: inconsistent datatypes&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You cannot comapre 2 different datatypes, you must convert the char dataype to a date format or vice versa.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Thu, 30 Sep 2004 10:35:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390663#M865264</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T10:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390664#M865265</link>
      <description>Jean Luc, &lt;BR /&gt;&lt;BR /&gt;You are indeed correct. I have changed the DATE datatype to CHAR with the following syntax &lt;BR /&gt;&lt;BR /&gt;WHERE TRUNC(TO_CHAR(max_date + 1, 'RRRR-MM-DD-SS-MI-HH24')) = TRUNC(a.added_date);&lt;BR /&gt;&lt;BR /&gt;Seems to be working now!&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 30 Sep 2004 10:50:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390664#M865265</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2004-09-30T10:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: SQL to select / insert records</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390665#M865266</link>
      <description>Declan,&lt;BR /&gt;&lt;BR /&gt;I suppose you can assign points that show the thread has been answered and solution found.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc&lt;BR /&gt;PS : no point here</description>
      <pubDate>Thu, 30 Sep 2004 10:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sql-to-select-insert-records/m-p/3390665#M865266</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-09-30T10:55:55Z</dc:date>
    </item>
  </channel>
</rss>

