Solved

How to Solve Auto Insert Date-Time Problem with SQLLOADER?

Posted on 2014-11-24
7
350 Views
Last Modified: 2014-11-24
Dear Experts,

I have a table like below:

CREATE TABLE TA
   (      X DATE,
      Y VARCHAR2(255 BYTE),
      Z VARCHAR2(31 BYTE),
      T VARCHAR2(127 BYTE),
      K VARCHAR2(127 BYTE),
      L VARCHAR2(127 BYTE),
      M CLOB,
      N DATE DEFAULT SYSDATE
   )

N is going to be filled for each record while insertion. (There is no corresponding N field in the input file.)

Control File is like this:

LOAD DATA  ....
INFILE   ....
BADFILE  ....
DISCARDFILE ....
APPEND INTO TABLE TA
Fields terminated by "|"
TRAILING NULLCOLS
(
X DATE "MON DD HH24:MI:SS" NULLIF (X="NULL"),Y,Z,T,K,L,M,N DATE "MON DD HH24:MI:SS" NULLIF (INSERT_DATETIME="NULL")
)

Each record is being properly recorded to Table, however the field N (field for auto-insert date-time) comes always NULL. What can it be?

BR
0
Comment
Question by:GurcanK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 300 total points
ID: 40462812
easier method might be to use external table.
it's essentially the same syntax but then you can do something like this...


insert into TA (x,y,z,t,k,l,m)
select x,y,z,t,k,l,m from your_external_table;

and then let the N column pick up the TA default
0
 

Author Comment

by:GurcanK
ID: 40462839
Dear Moderator,

I got e-mail but here I could not see any expert reply?!
0
 

Author Comment

by:GurcanK
ID: 40462849
Yes, but the requester group did not want external tables :( No way?
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 300 total points
ID: 40462850
sorry, I deleted my first response and then edited it and put it back, I was hoping to do my edits fast enough but I guess I wasn't
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 300 total points
ID: 40462864
0
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 100 total points
ID: 40462865
A column default does not take effect if you specify a value.  You are specifying NULL, which is a value.  What you need to do is completely leave the column out of the load file and then it will fill with the default.
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 100 total points
ID: 40462889
I think the problem is this line in your controlfile: "TRAILING NULLCOLS".  (This is similar to johnsone's comment.)  I think you will either have to remove that line from your controlfile, or create a "before insert for each row" trigger on your table to automatically fill column N with sysdate, if it is null.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question