Solved

INSERT_DATE

Posted on 2013-12-17
7
443 Views
Last Modified: 2013-12-17
Hi,
I have a trigger as follow:
BEGIN
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU) VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU);
END;

In the table BCP_ENTRY I need to update field INSERT_DATE with timestamp (when inserting was performed)

BEGIN
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU, INSERT_DATE) VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU, :new.INSERT_DATE :=TIMESTAMP);
END;

I'm receiving error...
Thank you
0
Comment
Question by:andrejaTJ
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Assisted Solution

by:Surrano
Surrano earned 50 total points
Comment Utility
Can you please elaborate on what error you receive?
What is the exact trigger definition and table definition?
Have you tried like this?

BEGIN
    new.INSERT_DATE := TIMESTAMP;
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU, INSERT_DATE) 
    VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU, :new.INSERT_DATE);
END;

Open in new window


or simply

BEGIN
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU, INSERT_DATE) 
    VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU, TIMESTAMP);
END;

Open in new window

0
 

Author Comment

by:andrejaTJ
Comment Utility
Thank you for your reply, but I'm getting error ORA-24344: success with compilation error :(
0
 
LVL 34

Accepted Solution

by:
johnsone earned 100 total points
Comment Utility
What are you trying to put into the INSERT_DATE field?  If you are looking for the current time, then it would be:

BEGIN
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU, INSERT_DATE) VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU, SYSTIMESTAMP);
END;

The full code of the trigger and what you are trying to accomplish would be a lot more helpful than one line.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:andrejaTJ
Comment Utility
Johnsone, Surrano,
This trigger is working without problem:

create or replace
TRIGGER "TADEC_AF"."SAD_HEADER_TRIGGER" AFTER INSERT ON "TADEC_AF"."SAD_HEADER" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW BEGIN
    INSERT INTO BCP_ENTRY (BCP_ENTRY_UNIQUE_NO, BCP_ENTRY_SAD_HEADER_ID, SAD_REPL_COU)
    VALUES ( BCP_ENTRY_SEQ.nextval, :new.SAD_ID, :new.SAD_REPL_COU);
END;

When I'm trying to add SYSDATE to the fiels INSERT_DATE... Error.
Simply, I have DATE field (7) in the table BCP_ENTRY where is required to add TIMESTAMP or SYSDATE.... Like now()
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 100 total points
Comment Utility
Then what I posted should work.  Have you tried it?  That would put the current timestamp in there.  Oracle should automatically convert it to DATE if that is the data type of INSERT_DATE (or you can change SYSTIMESTAMP to SYSDATE.
0
 
LVL 8

Expert Comment

by:Surrano
Comment Utility
what an oversight indeed, I should've noticed it was TIMESTAMP instead of SYSTIMESTAMP ;)
0
 

Author Comment

by:andrejaTJ
Comment Utility
Thank you both... All the best!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
Via a live example, show how to take different types of Oracle backups using RMAN.

728 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

14 Experts available now in Live!

Get 1:1 Help Now