Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2004, 12:29 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error about trigger

Hi All
I try to use this trigger for inserting RecordID in Shoppingcart Table.

DECLARE
NEXTID NUMBER(3);
BEGIN

SELECT MAX(RECORDID) INTO NEXTID FROM SHOPPINGCART;
:NEW.RECORDID := LTRIM(NEXTID+1);
END;
************************************************** *
 It is an empty table now. By inserting the other fields and leaves the RecordID for triggering. The Oracle shows this error

ORA-01400; can not insert null into (“SCOTT”.”SHOPPINGCART”.”RECORDID”)
************************************************** *
How could I solve this error?

Thanks in advance

Blueman137


 
Old March 10th, 2004, 02:55 PM
aas aas is offline
Authorized User
 
Join Date: Mar 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to aas
Default

Quote:
quote:Originally posted by Blueman137
 Hi All
I try to use this trigger for inserting RecordID in Shoppingcart Table.

DECLARE
NEXTID NUMBER(3);
BEGIN

SELECT MAX(RECORDID) INTO NEXTID FROM SHOPPINGCART;
:NEW.RECORDID := LTRIM(NEXTID+1);
END;
************************************************** *
 It is an empty table now. By inserting the other fields and leaves the RecordID for triggering. The Oracle shows this error

ORA-01400; can not insert null into (“SCOTT”.”SHOPPINGCART”.”RECORDID”)
************************************************** *
How could I solve this error?

Thanks in advance

Blueman137
try as : ":NEW.RECORDID := LTRIM(NVL(NEXTID,0)+1);"

But best to use sequence for this scope.

;)

 
Old March 10th, 2004, 08:53 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi AAS

Thanks For your reply
I already find out the problem by sequence

Blueman137







Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Trigger arnabghosh SQL Server 2000 3 August 21st, 2008 02:07 AM
Trigger Error kuku SQL Server 2000 7 August 25th, 2005 10:29 PM
Trigger realgone_ SQL Language 4 January 27th, 2005 11:49 AM
Trigger Creation Syntax Error SniffenLik SQL Language 3 July 25th, 2004 12:28 PM
Retrive Error no or message from Trigger salman VB Databases Basics 0 May 5th, 2004 06:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.