Solved

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

Posted on 2014-11-24
7
324 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
7 Comments
 
LVL 73

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

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 73

Assisted Solution

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

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 34

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now