Re: Oracle developer 2000 - forms

From: Zbigniew Sliwa <zibi_at_at_yahoo.com>
Date: Tue, 05 Dec 2000 08:05:23 +0100
Message-ID: <3A2C93B3.B683CBB4_at_yahoo.com>


Hello,

ORA-01400 message says (taken from the Oracle manual): cannot insert NULL into (“USER”.”TABLE”.”COLUMN”) Cause: An attempt was made to insert a NULL into the column "USER"."TABLE"."COLUMN". You did an insert into CARDETAILS and did not specify all of the columns that are in that table.
Anyway, you did want to do an update. So change:

> INSERT INTO CARDETAILS (CD_TOTALMILES) VALUES
> (Z);

into

UPDATE	cardetails
SET	cd_totalmiles = Z
WHERE	cd_carid  = :CARDETAILS.CD_CARID;

Or even replace the trigger with the below update (assuming that cr_carcode and cd_carid are primary keys):

UPDATE cardetails

SET       cd_totalmiles = (SELECT  a.CR_MILESPERDAY * b.CD_DAYSHIRED
                          FROM     (SELECT  CR_MILESPERDAY
                                   FROM     CARRENTALS
                                   WHERE    CARRENTALS.CR_CARCODE =
:CD_CARCODE) a,
                                   (SELECT  CD_DAYSHIRED
                                   FROM     CARDETAILS
                                   WHERE    CD_CARID =
:CARDETAILS.CD_CARID) b)
WHERE     cd_carid  = :CARDETAILS.CD_CARID
RETURNING CD_TOTALMILES INTO :CD_AMOUNT;
-- 
Regards,

Zbigniew Sliwa
Oracle Programmer
Poland
email: zibi_at_at_yahoo.com

hr60112 wrote:

>
> My problem in developer 2000 forms is
> I have two tables in the database,
> 1)CarDetails - cd_no:ofdays , cd_totalmiles, etc...
> 2)CarRentals - cr_milesperday , etc..
> In my form for CarDetails, I want to update totalmiles by multiplying
> no:ofdays (of CarDetails form) and
> milesperday(of the CarRentals table).
> I wrote a trigger
> DECLARE
> X NUMBER;
> Y NUMBER;
> Z NUMBER;
> BEGIN
> SELECT CR_MILESPERDAY INTO X FROM CARRENTALS
> WHERE :CD_CARCODE = CARRENTALS.CR_CARCODE;
> SELECT CD_DAYSHIRED INTO Y FROM CARDETAILS
> WHERE CD_CARID = :CARDETAILS.CD_CARID;
> Z := X*Y;
> INSERT INTO CARDETAILS (CD_TOTALMILES) VALUES
> (Z);
> COMMIT;
> SELECT CD_TOTALMILES INTO :CD_AMOUNT FROM CARDETAILS WHERE
> CD_CARID = :CARDETAILS.CD_CARID;
> END;
>
> But it returns a error during the run time, ORA-01400.
> How do i rectify it. Please reply.
> Thank you.
> from hamsinirs_at_hotmail.com
Received on Tue Dec 05 2000 - 08:05:23 CET

Original text of this message