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
Solved

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

Posted on 2014-11-24
7
338 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 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
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 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 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
Processing of multiple cursor 6 58
Trying to get a Linked Server to Oracle DB working 21 67
ORA-02288: invalid OPEN mode 2 56
Row_number in SQL 6 33
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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 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.

789 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