Solved

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

Posted on 2014-11-24
7
336 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 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle and DateTime math 6 39
PL/SQL More than one element associated with another element 7 27
Oracle dataguard 5 32
Creation date for a PDB 5 22
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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

810 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