2 Replies - 4540 Views - Last Post: 18 November 2010 - 06:57 AM

#1 jammu143  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 24-March 09

How to create trigger to insert current time.

Posted 18 November 2010 - 03:57 AM

Hello frd,
I am working on my DBMS Project in VB 6.0 that is Tollbooth management system
i have to insert one trigger for my project so i had decided to insert time trigger.

I have total 3 table UserLogin, Vehice and Vehicle_Data
the 3rd table Vehicle data contain the following fields
Vehicle_Type, Vehicle_No, Tax_Time, Source, Destination and Tax
Now i had done coding for tax when you select Vehicle Type, Source and Destination the Tax Field will automatically fillup and all the data will Saved in Oracle table but now my problem is that i want to create trigger for Tax_Time column When any new data inserted current time will stored in that column
I had create one but it gives error

create trigger time after insert on vehicle_Data
for each row
begin
insert into Vehicle_Data(Tax_Time) values(to_char(sysdate, 'HH:MI:SSAM DD_MON_YYYY'));
end;
/


here i am attaching screen shot so you got the idea about my project
Please Help me i have only 24 hours..

Note: I am Using VB 6.0 and Oracle 10g Express Edition

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: How to create trigger to insert current time.

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: How to create trigger to insert current time.

Posted 18 November 2010 - 06:01 AM

Hey.

In that situation you would probably want to be using an UPDATE query rather than a INSERT query. The INSERT query will insert an entirely new row. The UPDATE query can modify the old one.

You have access to the data that was inserted inside the trigger vii the :new object, so you can do things like:
UPDATE ...
WHERE thepk = :new.thepk



Another thing you should consider. Normally I would think things like these should be done with the original INSERT query. Can you not simply add the Tax_Time column to the INSERT query in your VB6 code?
Was This Post Helpful? 0
  • +
  • -

#3 jammu143  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 24-March 09

Re: How to create trigger to insert current time.

Posted 18 November 2010 - 06:57 AM

Thanx Atli for quick reply
i didn't get it completely
Can you write full code

And i know it is very easy to insert directly query in my VB code but it is compulsory to create 1 Trigger and 1 stored Procedure for Project so i have to do this. :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1