SQL Question #3 When I run this code (table OPJEUL.MCD_COSTS_9C_ACCTS_05 does not exist) CREATE TABLE OPJEUL.MCD_COSTS_9C_ACCTS_05 AS SELECT * FROM OPJEUL.COSTS_9C_ACCTS_05 I get an Ora-01847, day must be between 1 and end of the month. There are 2 dates in the input view and all are valid.  I wrote a PL/SQL proc to kick out any invalid dates and none were rejected.  Also, looking at the dates, none of them seem wrong. If I create an empty table and do an Insert, the same error occurs. However, if I change from a table to a view CREATE or replace view OPJEUL.COSTS_9C_ACCTS_05_V AS SELECT * FROM OPJEUL.COSTS_9C_ACCTS_05 the view is created without any problems.
How to debug problem? Do you have Bad Dates in Table? Visually see bad dates. Write a procedure to check for bad dates. Create an empty table and do select Inserts. Create table again without date fields. Check On-line source for help. Create SR with Oracle Support. See if Teacher can help solved problem.
One Approach! Were trying to find the bad records or record? As we can see other methods have failed in this case. So, I would recommend using TOAD Export to see if we can find problems. Use the empty table from #4, to see if we can populate with Export.
TOAD Schema Browser Use Feature - Export data as Insert Statements
Sample Export INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13167, 13745, 22444, 53871, 1, 1, -10892);  INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13167, 13745, 22444, 53872, 1, 1, 10892);  INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13167, 13745, 25998, 209177, 1, 1, -2172);  INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13218, 13218, 26393, 203660, 1, 0, -0.001);  INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13218, 13218, 26394, 203663, 1, 0, -0.0024);  INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES (  2131438, 2, 0, 4130, 0, 13218, 13218, 26395, 203669, 1, 0, 0.8048); commit;
SQL*Plus We need modify to target source for empty table. Look for bad records that don’t insert into empty table. SQL> @I:\Training\load_test

Sql Question #3

  • 1.
    SQL Question #3When I run this code (table OPJEUL.MCD_COSTS_9C_ACCTS_05 does not exist) CREATE TABLE OPJEUL.MCD_COSTS_9C_ACCTS_05 AS SELECT * FROM OPJEUL.COSTS_9C_ACCTS_05 I get an Ora-01847, day must be between 1 and end of the month. There are 2 dates in the input view and all are valid. I wrote a PL/SQL proc to kick out any invalid dates and none were rejected. Also, looking at the dates, none of them seem wrong. If I create an empty table and do an Insert, the same error occurs. However, if I change from a table to a view CREATE or replace view OPJEUL.COSTS_9C_ACCTS_05_V AS SELECT * FROM OPJEUL.COSTS_9C_ACCTS_05 the view is created without any problems.
  • 2.
    How to debugproblem? Do you have Bad Dates in Table? Visually see bad dates. Write a procedure to check for bad dates. Create an empty table and do select Inserts. Create table again without date fields. Check On-line source for help. Create SR with Oracle Support. See if Teacher can help solved problem.
  • 3.
    One Approach! Weretrying to find the bad records or record? As we can see other methods have failed in this case. So, I would recommend using TOAD Export to see if we can find problems. Use the empty table from #4, to see if we can populate with Export.
  • 4.
    TOAD Schema BrowserUse Feature - Export data as Insert Statements
  • 5.
    Sample Export INSERTINTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13167, 13745, 22444, 53871, 1, 1, -10892); INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13167, 13745, 22444, 53872, 1, 1, 10892); INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13167, 13745, 25998, 209177, 1, 1, -2172); INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13218, 13218, 26393, 203660, 1, 0, -0.001); INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13218, 13218, 26394, 203663, 1, 0, -0.0024); INSERT INTO LOAD ( LOAD_ID, STEP_NU, AMT_SRC_ID, LPPY_ID, LOCUS_ID, ENTITY_ID, LGL_ENTITY_ID, RPT_LN_ID, ACCT_ID, TRAN_TYPE_ID, VIEW_TYPE_ID, YTD_AMT ) VALUES ( 2131438, 2, 0, 4130, 0, 13218, 13218, 26395, 203669, 1, 0, 0.8048); commit;
  • 6.
    SQL*Plus We needmodify to target source for empty table. Look for bad records that don’t insert into empty table. SQL> @I:\Training\load_test