Solved

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

Posted on 2014-11-24
7
346 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
Industry Leaders: 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!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Developer 6 75
exp/imp 25 102
upgrading Oracle 10g/ 11g / 11g R2 to Oracle 12c 25 89
Oracle collections 15 39
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

730 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