Home » SQL & PL/SQL » SQL & PL/SQL » PLS-00405: subquery not allowed in this context
PLS-00405: subquery not allowed in this context [message #386680] Mon, 16 February 2009 10:22 Go to next message
M.Shakeel Azeem
Messages: 226
Registered: September 2006
Senior Member
Dear All,

i am trying to create the following trigger but got the error "PLS-00405: subquery not allowed in this context"
can anybody help me in this regard?

CREATE OR REPLACE TRIGGER trg_sdr_tblsswcdrs
BEFORE INSERT
ON terminusbill.sdr_tblsswcdrs
FOR EACH ROW
DECLARE
elementid NUMBER (10):= 2;
BEGIN

IF :NEW.ssw_duration > 0
AND :NEW.SSW_IC_CarrierID) Not IN (SELECT UPPER(TRUNKID) FROM NE_TRUNKSFORSUBREPORTS )


THEN
INSERT INTO sdr_tblsubmissedcdrs
(smcr_rawcdrid, pc_parsedcode, pe_errorcode,
smcr_callingnumber, smcr_callednumber, ne_elementid,
smcr_calltime, ct_calltypeid, smcr_voiceusageduration
)
VALUES (:NEW.ssw_voicerecordid, 0, 0,
:NEW.ssw_txcallingnum, :NEW.ssw_txcallednum, 2,
:NEW.ssw_disconntime, 0, CEIL (:NEW.ssw_duration / 10)
);
END IF;
END IF;

/

Re: PLS-00405: subquery not allowed in this context [message #386681 is a reply to message #386680] Mon, 16 February 2009 10:30 Go to previous message
cookiemonster
Messages: 12418
Registered: September 2008
Location: Rainy Manchester
Senior Member
You've got one IF and two END IF's.

Your brackets don't match up either.
So I doubt you've posted the full code, please do so next time and use code tags (see the orafaq forum guide for details).

You've got a select in a NOT IN clause - that's your subquery.
You can do this in a SELECT statement
ie
SELECT * 
FROM table
WHERE column NOT IN (select statement);

You can't use it in an IF statement.
Previous Topic: procedure to change db link (merged)
Next Topic: first_value analytic function
Goto Forum:
  


Current Time: Thu Dec 08 04:23:24 CST 2016

Total time taken to generate the page: 0.45493 seconds