Error in trigger: PLS-00049: bad bind variable
Hi,
I am trying one of the XML/XDK samples from technet (http://otn.oracle.com/tech/xml/htdocs/XDBDemo2.html) and get this error while compiling the trigger: here's the code snippet
create or replace trigger PURCHASEORDEREXPLOSION
instead of insert on NEWPURCHASEORDER
for each row
declare
begin
DOCUMENT := :new.PODOCUMENT; <--Error here: PLS-00049: bad bind variable 'NEW.PODOCUMENT'
I can't understand why is this happening? Any clues??
Thanks!
-Rajeev
You don't specify bind variables with the colon ":" prefix in PL/SQL.
The procedure you posted builds a query using string concatenation. Even if you remove the colon from your variable name you still won't be using bind variables.
If you want to use bind variables you should consider doing the following:
1. Use the DBMS_SQL package.
2. Use EXECUTE IMMEDIATE with the USING clause.
3. Use OPEN <REF CURSOR> FOR <STATEMENT> with the USING clause.
Each one has different advantages/disadvantages.
If looks as if you want to pass in a dynamic IN list. If you use bind variables it will effectively treat the entire list as ONE value enclosed in single quotes. If you truly want a dynamic IN list you need to investigate another method.
Tom Kyte has some information on Dynamic IN lists here: [How can I do a variable in list?|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425]
Similar Messages
-
Error(19,19): PLS-00049: bad bind variable 'P_WHERE'
Hi Everyone,
Making my first attempt at bind variables. From what I've read it really improves performance.
The code below works great until I try to make TEST1_PROC.P_WHERE a bind variable with the ':' prefix, such as :P_WHERE.
Suggestions?
Thank You in Advance for Your Help,
Lou
create or replace
PROCEDURE TEST2_PROC
AS
my_refcur SYS_REFCURSOR;
my_id ci_summrpt_report_codes.id% TYPE;
my_descr ci_summrpt_report_codes.descr% TYPE;
my_where VARCHAR2(10) := '1,4';
BEGIN
TEST1_PROC(my_refcur, my_where) ;
DBMS_OUTPUT.PUT_LINE('ID DESCR');
DBMS_OUTPUT.PUT_LINE('----- -------');
LOOP
FETCH my_refcur INTO my_id, my_descr;
EXIT
WHEN my_refcur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(my_id || CHR(9) || my_descr);
END LOOP;
CLOSE my_refcur;
END TEST2_PROC;
CREATE OR REPLACE
PROCEDURE TEST1_PROC
p_refcur OUT SYS_REFCURSOR,
p_where IN VARCHAR2)
IS
v_id NUMBER(2) ;
v_descr VARCHAR2(25) ;
v_select VARCHAR2(200) ;
BEGIN
v_select:='SELECT * FROM
(SELECT 1 AS "ID", ''ONE'' AS "DESCR" FROM DUAL
UNION ALL
SELECT 2, ''TWO'' FROM DUAL
UNION ALL
SELECT 3, ''THREE'' FROM DUAL
UNION ALL
SELECT 4, ''FOUR'' FROM DUAL)
WHERE ID IN (' || :p_where || ')';
DBMS_OUTPUT.PUT_LINE(v_select) ;
OPEN p_refcur FOR v_select;
END TEST1_PROC;You don't specify bind variables with the colon ":" prefix in PL/SQL.
The procedure you posted builds a query using string concatenation. Even if you remove the colon from your variable name you still won't be using bind variables.
If you want to use bind variables you should consider doing the following:
1. Use the DBMS_SQL package.
2. Use EXECUTE IMMEDIATE with the USING clause.
3. Use OPEN <REF CURSOR> FOR <STATEMENT> with the USING clause.
Each one has different advantages/disadvantages.
If looks as if you want to pass in a dynamic IN list. If you use bind variables it will effectively treat the entire list as ONE value enclosed in single quotes. If you truly want a dynamic IN list you need to investigate another method.
Tom Kyte has some information on Dynamic IN lists here: [How can I do a variable in list?|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425] -
PLS-00049: bad bind variable 'NEW.ID' on trigger
Hi guys, I am using Oracle SQL Developer version 2.1.1.64 and having the sql statement like below
CREATE TABLE Zipcodes
zipcode_id NUMBER(10),
zipcode VARCHAR2(10),
district_id NUMBER(10),
PRIMARY KEY(zipcode_id)
CREATE SEQUENCE ZIPCODE_ID_SEQ START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER ZIPCODE_TRIGGER
BEFORE INSERT
ON ZIPCODES
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
SELECT ZIPCODE_ID_SEQ.NEXTVAL INTO :NEW.ZIPCODE_ID FROM DUAL;
END;
And I got errors:
Error(2,40): PLS-00049: bad bind variable 'NEW.ID'
Error(4,5): PL/SQL: Statement ignored
Error(4,39): PLS-00357: Table,View Or Sequence reference 'ZIPCODE_ID_SEQ.NEXTVAL' not allowed in this context
Error(2,36): PLS-00049: bad bind variable 'NEW.ID'
Error(2,2): PL/SQL: SQL Statement ignored
Error(2,9): PL/SQL: ORA-02289: sequence does not exist
Error(5,1): PLS-00103: Encountered the symbol "SHOW"
Firstly, I dont even have the "SHOW" key world in my syntax.
What is it happening ?
Thank you in advance.Hi,
954390 wrote:
Hi guys, I am using Oracle SQL Developer version 2.1.1.64 Thanks; that could be useful information. Even more important is your database version (e.g. 11.2.0.2.0)
and having the sql statement like below
CREATE TABLE Zipcodes
zipcode_id NUMBER(10),
zipcode VARCHAR2(10),
district_id NUMBER(10),
PRIMARY KEY(zipcode_id)
)Don't you need a semicolin or a slash after the CREATE TABLE statement?
CREATE SEQUENCE ZIPCODE_ID_SEQ START WITH 1 INCREMENT BY 1;Did you get a message like "Sequence created" at this point?
CREATE OR REPLACE TRIGGER ZIPCODE_TRIGGER
BEFORE INSERT
ON ZIPCODES
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
SELECT ZIPCODE_ID_SEQ.NEXTVAL INTO :NEW.ZIPCODE_ID FROM DUAL;
END;
And I got errors:
Error(2,40): PLS-00049: bad bind variable 'NEW.ID'
Error(4,5): PL/SQL: Statement ignored
Error(4,39): PLS-00357: Table,View Or Sequence reference 'ZIPCODE_ID_SEQ.NEXTVAL' not allowed in this context
Error(2,36): PLS-00049: bad bind variable 'NEW.ID'
Error(2,2): PL/SQL: SQL Statement ignored
Error(2,9): PL/SQL: ORA-02289: sequence does not exist
Error(5,1): PLS-00103: Encountered the symbol "SHOW"
Firstly, I dont even have the "SHOW" key world in my syntax.
What is it happening ?You don't have anything like NEW.ID, either.
Also, the line numbers in error messages for triggers start with the first DECLARE or BEGIN statement, so this trigger only has 3 lines, yet you're getting line numbers up to 5 in the error messages.
That trigger works fine for me in SQL*Plus (database 10.2.0.1.0).
Are you sure you're showing the complete script, exactly what you're running? If you had some syntax error before the CREATE OR REPLACE TRIGGER statement, that might possibly account for the parser getting confused.
Does your code work in SQL*Plus? -
PLS-00049: bad bind variable 'IN_DPC_CODE'
Hi,
I am gettig following errors while creating a stored procedure. please help me.
BEGIN
EXECUTE IMMEDIATE sql_stmt
INTO OUT_ROWNUM, OUT_DPC_CODE_ORIG, OUT_SENSOR_ID, OUT_HEADER_DATE,OUT_FIRST_BLOCK_NUMBER, LAST_BLOCK_NUMBER, OUT_RECORD_QUANTITY,OUT_FILE_ID, OUT_FILE_NAME, OUT_TRACE_SEQUENCE_NO, OUT_TRAILER_DATE, OUT_PROCESSED_DATE, OUT_ROW_NUMBER
USING :IN_DPC_CODE, :IN_SENSOR_ID, :IN_TRAILER_DATE, :IN_LAST_BLOCK_NUMBER;Hi,
Here i am sending total code. Please suggest me accordingly.
After executing this i am getting following errors.
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object NRUPWEIS.TAB_SELECT is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> show errors
Errors for PROCEDURE TAB_SELECT:
LINE/COL ERROR
92/19 PLS-00049: bad bind variable 'IN_DPC_CODE'
92/33 PLS-00049: bad bind variable 'IN_SENSOR_ID'
92/48 PLS-00049: bad bind variable 'IN_TRAILER_DATE'
92/66 PLS-00049: bad bind variable 'IN_LAST_BLOCK_NUMBER'
116/3 PLS-00103: Encountered the symbol "END"
code:
-- -- Input parameters:
-- -- ALBQ 602071 20050913153100 53290
-- -- exec tab_select('ALBQ', '602071', '053290', '20050912153100')
-- CREATE or REPLACE PROCEDURE tab_select IS
-- type curTyp is ref cursor;
-- tab_cv curTyp;
CREATE or REPLACE PROCEDURE tab_select (IN_DPC_CODE IN CHAR, IN_SENSOR_ID IN NUMBER, IN_LAST_BLOCK_NUMBER IN NUMBER,
IN_TRAILER_DATE IN CHAR) IS
sql_stmt varchar2(2000);
sql_stmt2 varchar2(2000);
IN_DPC_CODE CHAR(4);
IN_SENSOR_ID CHAR(6);
IN_TRAILER_DATE CHAR(14);
IN_LAST_BLOCK_NUMBER number;
OUT_ROWNUM number(8) := 0;
OUT_DPC_CODE_ORIG CHAR(4);
OUT_SENSOR_ID CHAR(6);
OUT_HEADER_DATE CHAR(14);
OUT_FIRST_BLOCK_NUMBER number(9) := 0;
OUT_LAST_BLOCK_NUMBER number(9) := 0;
OUT_RECORD_QUANTITY number(8) := 0;
OUT_FILE_ID CHAR(10);
OUT_FILE_NAME CHAR(30);
OUT_TRACE_SEQUENCE_NO number(5) := 0;
OUT_TRAILER_DATE CHAR(14);
OUT_PROCESSED_DATE CHAR(14);
OUT_ROW_NUMBER number(8) := 0;
BEGIN
DBMS_OUTPUT.DISABLE;
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE('**** BEFORE sql_stmt Line: ' || ' ' ||
IN_DPC_CODE || ' ' ||
IN_SENSOR_ID || ' ' ||
IN_TRAILER_DATE || ' ' ||
IN_LAST_BLOCK_NUMBER);
DBMS_OUTPUT.PUT_LINE('**** ' );
sql_stmt := 'SELECT rNum, dpcCode, sID, hDate, fBlock, ' ||
'lBlock, recQty, fID, fName, ' ||
'tSeqNo, sType, tDate, fStatCode, pDate, recCount, r ' ||
'FROM (SELECT rownum rNum, DPC_CODE_ORIG dpcCode, ' ||
'SENSOR_ID sID, ' ||
'to_char(HEADER_DATE, ''YYYYMMDDHH24MISS'') hDate, ' ||
'FIRST_BLOCK_NUMBER fBlock, ' ||
'LAST_BLOCK_NUMBER lBlock, ' ||
'RECORD_QUANTITY recQty, ' ||
'FILE_ID fID, ' ||
'substr(FILE_NAME,1,30) fName, ' ||
'TRACE_SEQUENCE_NO tSeqNo, ' ||
'SENSOR_TYPE sType, ' ||
'to_char(TRAILER_DATE, ''YYYYMMDDHH24MISS'') tdate, ' ||
'NVL(FILE_STATUS_CODE, ''NL'') fStatCode, ' ||
'to_char(PROCESSED_DATE, ''YYYYMMDDHH24MISS'') pDate, '||
'NVL(RECIRCULATE_COUNT, 0) recCount, ' ||
'ROW_NUMBER() ' ||
'OVER(ORDER BY LAST_BLOCK_NUMBER, TRAILER_DATE) r ' ||
'FROM logfc10t ' ||
'WHERE DPC_CODE_ORIG = :IN_DPC_CODE ' ||
'AND SENSOR_ID = :IN_SENSOR_ID ' ||
'AND (((TRAILER_DATE >= TO_DATE(:IN_TRAILER_DATE, ''YYYYMMDDHH24MISS''))' ||
'AND (LAST_BLOCK_NUMBER > :IN_LAST_BLOCK_NUMBER)) ' ||
' OR (TRAILER_DATE > TO_DATE(:IN_TRAILER_DATE, ''YYYYMMDDHH24MISS'')))) ' ||
'WHERE r = 1 ';
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE('**** BEFORE execute immediate Line: ');
-- p(sql_stmt);
-- Put_Xl_line(sql_stmt);
DBMS_OUTPUT.PUT_LINE('**** ' );
BEGIN
EXECUTE IMMEDIATE sql_stmt
INTO OUT_ROWNUM, OUT_DPC_CODE_ORIG, OUT_SENSOR_ID, OUT_HEADER_DATE,
OUT_FIRST_BLOCK_NUMBER, OUT_LAST_BLOCK_NUMBER, OUT_RECORD_QUANTITY,
OUT_FILE_ID, OUT_FILE_NAME, OUT_TRACE_SEQUENCE_NO, OUT_TRAILER_DATE,
OUT_PROCESSED_DATE, OUT_ROW_NUMBER
USING :IN_DPC_CODE, :IN_SENSOR_ID, :IN_TRAILER_DATE, :IN_LAST_BLOCK_NUMBER;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE('**** IMMED ' || sqlcode || ' ' || substr(sqlerrm,1,200));
DBMS_OUTPUT.PUT_LINE('**** ' );
END;
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE('**** AFTER execute immediate Line: ');
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE ('*** Next Line: ' || OUT_ROWNUM || OUT_DPC_CODE_ORIG || OUT_SENSOR_ID ||
OUT_HEADER_DATE || OUT_FIRST_BLOCK_NUMBER || OUT_LAST_BLOCK_NUMBER ||
OUT_RECORD_QUANTITY || OUT_FILE_ID || OUT_FILE_NAME ||
OUT_TRACE_SEQUENCE_NO || OUT_TRAILER_DATE || OUT_PROCESSED_DATE || OUT_ROW_NUMBER);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('**** ' );
DBMS_OUTPUT.PUT_LINE('**** ERROR ' || sqlcode || ' ' || substr(sqlerrm,1,200));
DBMS_OUTPUT.PUT_LINE('**** ' );
end;
end tab_select;
set serveroutput on
exec tab_select('OMAN', '612628', '993610', '20070214141700')
--exec tab_select('OMAN', '612628', '6434', '20070214144700')
--exec tab_select('OMAN', '612628', '13098', '20070214150200')
--exec tab_select('OMAN', '612628', '19874', '20070214151700')
--exec tab_select('OMAN', '612628', '33398', '20070214154700')
-- quit -
1. create table t1
(t1ID int,
t1nam varchar2(33)
2. create or replace view t1t2t3
t1id, t1name, t2id, t2nam, t2cty, t2st, aid, aname, bid, bname, t3id, t3nam
as
select * from t1, t2, t1 a, t1 b, t3
where t1.t1ID = t2.id(+)
and T2.CTY = a.t1ID(+)
and t2.sty = b.t1ID(+)
and t1.t1ID = t3.t3id(+)
3. CREATE OR REPLACE TRIGGER t1t2t3
INSTEAD OF INSERT or update
ON t1t2t3
BEGIN
insert into t1
values(:new.t1ID, :new.t1nam);
END t1t2t3;
Get error:
[Error] PLS-00049 (6: 19): PLS-00049: bad bind variable 'NEW.T1NAM'
Pls advise. I am using Toad.
Thanks.tnam1 not belongs to t1t2t3.
:new should be used to te columns of the table on which you are writing the trigger.
Here i think t1t2t3 has t1name field you have to use :new.t1name instead of :new.t1nam(which belongs to table t1) -
10/15 PLS-00049: bad bind variable 'NEW.MEMBER'
I have created a view based on 2 tables called member and account which works fine i am then trying to create a trigger to update my member view as
create or replace trigger member_view_update
Instead of update on member_view
for each row
begin
update member set
last_name = :new.last_name,
first_name =:new.first_name,
manager_number= :new.manager_number,
title=:new.title,
address=:new.address,
telephone_1 =:new.telephone_1,
post_code=:new.post_code,
where rowid= :new.member.rowid;
update account set account_balance=:new.account_balance
where rowid=:new.account_rowid;
end;
But this has the following errors
LINE/COL ERROR
2/2 PL/SQL: SQL Statement ignored
10/2 PL/SQL: ORA-01747: invalid user.table.column, table.column, or
column specification
10/15 PLS-00049: bad bind variable 'NEW.MEMBER'
View code
Create or replace view member_view as
select member.rowid member_rowid,
member.member_number,last_name, first_name, manager_number, title, telephone_1, address, post_code,
account.rowid account_rowid,
account_balance
from member, account
WHERE MEMBER.MEMBER_NUMBER = ACCOUNT.MEMBER_NUMBERHello,
I think that you have to replace
where rowid= :new.member.rowid;By
where rowid= :new.member_rowid;Francois -
Error PLS-00049 Bad bind variable
Hi I just want to test a simple procedure
and getting PLS-00049 error:
CREATE OR REPLACE PACKAGE BODY test_pkg AS
PROCEDURE bind_varibales AS
v_name TEST.NAME%TYPE;
v_tmp NUMBER;
BEGIN
v_name :='TEST_01';
SELECT COUNT(*) INTO v_tmp FROM TEST WHERE TEST.NAME = :v_name;
v_name :='TEST_02';
SELECT COUNT(*) INTO v_tmp FROM TEST WHERE TEST.NAME = :v_name;
END bind_varibales;
END test_pkg;
What is wrong here?
Thanksremove the colon in your variable v_name.
CREATE OR REPLACE PACKAGE BODY test_pkg AS
PROCEDURE bind_varibales AS
v_name TEST.NAME%TYPE;
v_tmp NUMBER;
BEGIN
v_name :='TEST_01';
SELECT COUNT(*) INTO v_tmp FROM TEST WHERE TEST.NAME = v_name;
v_name :='TEST_02';
SELECT COUNT(*) INTO v_tmp FROM TEST WHERE TEST.NAME = v_name;
END bind_varibales;
END test_pkg; -
ERROR: Package deleted because of bad bind-variable
hello,
i believe to have a serious problem here and i need help. portal deleted packages twice because of a "bad bind variable" so i had to start over again.
i'm trying to write a simple blackboard-application. Users can post and read posts. No answers, no threads
This is the structure:
Tables: categories with cat_id,cat_name
posts with post_id,cat_id, date,user_id,title,content
Reports for list of categories and list of posts in a certain category
Link from category-name to list of posts in category
This link uses :cat_id as passed parameter from category-list to list of posts
The list of posts has this select-statement:
SELECT post_id,cat_id,date,user_id,title
FROM schemaname.posts
WHERE cat_id = :cat_id;
So far everything works fine
Now i want to customize the look of the report. On the "Report and Customization Form Text"-Tab I wrote some html-code into the header-field. Then i tried to include a select statement to print the category-name. But everything i wrote between the <oracle></oracle>-tags was displayed as code and not parsed. So i next tried to put a select-statement into the "after header displayed"-field on the "additional PL/SQL Code"-Tab.
This is what i wrote:
declare
cat varchar2(20);
begin
SELECT cat_name into cat
FROM schemaname.categories
WHERE cat_id = :cat_id;
end;
When i now run the report i get a 4-page error-message saying package was deleted and that i used a bad bind-variable.
Can somebody please help?
we use portal 30982 on 9i database and windows 2000
Thank you very much
Ralf SchmittHi,
You cannot use bind variable in the additional plsql section. If you want to access the value of :cat_id then you should
pick it up from p_arg_names and p_arg_values.
In the additional plsql code "after header displayed"-
declare
cat_nm varchar2(50);
begin
for i in 1..p_arg_names.count
loop
if p_arg_names(i) = 'cat_id' then
SELECT cat_name into cat
FROM schemaname.categories
WHERE cat_id = p_arg_values(i);
exit;
end if;
end loop;
htp.p('Cateegory :' ||cat_nm);
end;
Thanks,
Sharmila -
What's wrong with this script
desc psaudit;
Name Type
AUDIT_OPRID VARCHAR2(30)
AUDIT_STAMP DATE
AUDIT_ACTN VARCHAR2(1)
RECNAME VARCHAR2(15)
FIELDNAME VARCHAR2(18)
OLDVALUE VARCHAR2(65)
NEWVALUE VARCHAR2(65)
KEY1 VARCHAR2(65)
KEY2 VARCHAR2(65)
KEY3 VARCHAR2(65)
KEY4 VARCHAR2(65)
KEY5 VARCHAR2(65)
KEY6 VARCHAR2(65)
KEY7 VARCHAR2(65)
KEY8 VARCHAR2(65)
KEY9 VARCHAR2(65)
KEY10 VARCHAR2(65)
KEY11 VARCHAR2(65)
KEY12 VARCHAR2(65)
KEY13 VARCHAR2(65)
KEY14 VARCHAR2(65)
KEY15 VARCHAR2(65)
22 rows selected
CREATE OR REPLACE TRIGGER JOB_TR
AFTER INSERT OR UPDATE OR DELETE ON PS_JOB_BT
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
V_AUDIT_OPRID VARCHAR2(64);
BEGIN
DBMS_APPLICATION_INFO.READ_CLIENT_INFO(V_AUDIT_OPRID);
IF :OLD.RECNAME IS NULL
THEN
INSERT INTO PSAUDITWRK
VALUES (GET_PS_OPRID(V_AUDIT_OPRID),SYSDATE,'I',:NEWRECNAME,:NEWFIELDNAME,:NEWOLDVALUE,:NEWNEWVALUE,:NEWKEY1,:NEWKEY2,:NEWKEY3,:NEWKEY4,:NEWKEY5,:NEWKEY6,:NEWKEY7,:NEWKEY8,:NEWKEY9,:NEWKEY10,:NEWKEY11,:NEWKEY12,:NEWKEY13,:NEWKEY14,:NEWKEY15);
ELSE
IF :NEWRECNAME IS NULL
THEN
INSERT INTO PSAUDITWRK
VALUES (GET_PS_OPRID(V_AUDIT_OPRID),SYSDATE,'D',:OLD.RECNAME,:OLD.FIELDNAME,:OLD.OLDVALUE,:OLD.NEWVALUE,:OLD.KEY1,:OLD.KEY2,:OLD.KEY3,:OLD.KEY4,:OLD.KEY5,:OLD.KEY6,:OLD.KEY7,:OLD.KEY8,:OLD.KEY9,:OLD.KEY10,:OLD.KEY11,:OLD.KEY12,:OLD.KEY13,:OLD.KEY14,:OLD.KEY15);
ELSE
INSERT INTO PSAUDITWRK
VALUES (GET_PS_OPRID(V_AUDIT_OPRID),SYSDATE,'B',:OLD.RECNAME,:OLD.FIELDNAME,:OLD.OLDVALUE,:OLD.NEWVALUE,:OLD.KEY1,:OLD.KEY2,:OLD.KEY3,:OLD.KEY4,:OLD.KEY5,:OLD.KEY6,:OLD.KEY7,:OLD.KEY8,:OLD.KEY9,:OLD.KEY10,:OLD.KEY11,:OLD.KEY12,:OLD.KEY13,:OLD.KEY14,:OLD.KEY15);
INSERT INTO PSAUDIT
VALUES (GET_PS_OPRID(V_AUDIT_OPRID),SYSDATE,'A',:NEWRECNAME,:NEWFIELDNAME,:NEWOLDVALUE,:NEWNEWVALUE,:NEWKEY1,:NEWKEY2,:NEWKEY3,:NEWKEY4,:NEWKEY5,:NEWKEY6,:NEWKEY7,:NEWKEY8,:NEWKEY9,:NEWKEY10,:NEWKEY11,:NEWKEY12,:NEWKEY13,:NEWKEY14,:NEWKEY15);
END IF;
END IF;
END JOB_TR;
Warning: compiled but with compilation errors
LINE/COL ERROR
5/4 PLS-00049: bad bind variable 'OLD.SYSADM'
8/49 PLS-00049: bad bind variable 'NEW.RECNAME'
8/62 PLS-00049: bad bind variable 'NEW.FIELDNAME'
8/77 PLS-00049: bad bind variable 'NEW.OLDVALUE'
8/91 PLS-00049: bad bind variable 'NEW.NEWVALUE'
8/105 PLS-00049: bad bind variable 'NEW.KEY1'
8/115 PLS-00049: bad bind variable 'NEW.KEY2'
8/125 PLS-00049: bad bind variable 'NEW.KEY3'
8/135 PLS-00049: bad bind variable 'NEW.KEY4'
8/145 PLS-00049: bad bind variable 'NEW.KEY5'
8/155 PLS-00049: bad bind variable 'NEW.KEY6'
LINE/COL ERROR
8/165 PLS-00049: bad bind variable 'NEW.KEY7'
8/175 PLS-00049: bad bind variable 'NEW.KEY8'
8/185 PLS-00049: bad bind variable 'NEW.KEY9'
8/195 PLS-00049: bad bind variable 'NEW.KEY10'
8/206 PLS-00049: bad bind variable 'NEW.KEY11'
8/217 PLS-00049: bad bind variable 'NEW.KEY12'
8/228 PLS-00049: bad bind variable 'NEW.KEY13'
8/239 PLS-00049: bad bind variable 'NEW.KEY14'
8/250 PLS-00049: bad bind variable 'NEW.KEY15'Hi,
Your trigger still don't have any reference to OLD.SYSADM, meaning those compile errors are from something else.
You should
1. Format your trigger (Which you have to some degree)
2. Paste it into SQL*Plus
3. Followed it by alter trigger ... compile
4. And show errors.
5. Paste back everything here
6. Remember to enclose SQL*Plus output in {noformat}{noformat} tags
Regards
Peter
edit:
I take back what I said about formatting. This is how it looks formatted:create or replace trigger job_tr
after insert or update or delete
on ps_job_bt
referencing new as new old as old
for each row
declare
v_audit_oprid varchar2(64);
begin
dbms_application_info.read_client_info(v_audit_oprid);
if :old.recname is null
then
insert into psauditwrk
values (get_ps_oprid(v_audit_oprid)
,sysdate
,'I'
,:newrecname
,:newfieldname
,:newoldvalue
,:newnewvalue
,:newkey1
,:newkey2
,:newkey3
,:newkey4
,:newkey5
,:newkey6
,:newkey7
,:newkey8
,:newkey9
,:newkey10
,:newkey11
,:newkey12
,:newkey13
,:newkey14
,:newkey15);
else
if :newrecname is null
then
insert into psauditwrk
values (get_ps_oprid(v_audit_oprid)
,sysdate
,'D'
,:old.recname
,:old.fieldname
,:old.oldvalue
,:old.newvalue
,:old.key1
,:old.key2
,:old.key3
,:old.key4
,:old.key5
,:old.key6
,:old.key7
,:old.key8
,:old.key9
,:old.key10
,:old.key11
,:old.key12
,:old.key13
,:old.key14
,:old.key15);
else
insert into psauditwrk
values (get_ps_oprid(v_audit_oprid)
,sysdate
,'B'
,:old.recname
,:old.fieldname
,:old.oldvalue
,:old.newvalue
,:old.key1
,:old.key2
,:old.key3
,:old.key4
,:old.key5
,:old.key6
,:old.key7
,:old.key8
,:old.key9
,:old.key10
,:old.key11
,:old.key12
,:old.key13
,:old.key14
,:old.key15);
insert into psaudit
values (get_ps_oprid(v_audit_oprid)
,sysdate
,'A'
,:newrecname
,:newfieldname
,:newoldvalue
,:newnewvalue
,:newkey1
,:newkey2
,:newkey3
,:newkey4
,:newkey5
,:newkey6
,:newkey7
,:newkey8
,:newkey9
,:newkey10
,:newkey11
,:newkey12
,:newkey13
,:newkey14
,:newkey15);
end if;
end if;
end job_tr;
It is immediately seen that this
if :newrecname is null
Should be
if :new.recname is null
And this error isn't even shown in your eledged compile errors.
Edited by: Peter Gjelstrup on Feb 10, 2009 7:00 AM -
Getting Errors in PL/SQL - bad bind variable and encountered the symbol...
CREATE OR REPLACE TRIGGER update_QOH
AFTER INSERT ON ORDERLINE
FOR EACH ROW
DECLARE
QOH_PRODUCT PRODUCT.QOH%TYPE;
BEGIN
SELECT QOH INTO QOH_PRODUCT FROM PRODUCT WHERE :old.product_no = :new.product_no;
IF :new.QTY <= :old.QOH THEN
QOH = :old.QOH - :new.QTY
ELSE
send_email(ord_no, 'Backorder');
INSERT INTO BACKORDER (backorder_no_seq.NEXTVAL, :new.product_no, :new.qty, SYSDATE);
INSERT INTO PRODVENDOR (po_no_seq.NEXTVAL, :new.vendor_no, :new.product_no, :new.vend_qty, :new.shipping_method, SYSDATE, NULL, NULL, NULL);
END IF;
END;
Error(5,17): PLS-00049: bad bind variable 'OLD.QOH'
Error(6,7): PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ;
Error(6,9): PLS-00049: bad bind variable 'OLD.QOH'Hi,
Welcome to the forum!
I see 4 mistakes:
851543 wrote:
CREATE OR REPLACE TRIGGER update_QOH
AFTER INSERT ON ORDERLINE
FOR EACH ROW
DECLARE
QOH_PRODUCT PRODUCT.QOH%TYPE;
BEGIN
SELECT QOH INTO QOH_PRODUCT FROM PRODUCT WHERE :old.product_no = :new.product_no;
IF :new.QTY <= :old.QOH THEN
QOH = :old.QOH - :new.QTY(1) The variable qoh isn't declared.
(2) Did you mean the assignment operator, :=, rather than the equality operator, = ?
(3) An assignment statement must end with a semi-colon.
ELSE
send_email(ord_no, 'Backorder');(4) The variable ord_no isn't declared.
INSERT INTO BACKORDER (backorder_no_seq.NEXTVAL, :new.product_no, :new.qty, SYSDATE);
INSERT INTO PRODVENDOR (po_no_seq.NEXTVAL, :new.vendor_no, :new.product_no, :new.vend_qty, :new.shipping_method, SYSDATE, NULL, NULL, NULL);
END IF;
END;
/While you can reference :NEW and :OLD values in the trigger, it doesn't make any sense to reference the :OLD values. On an INSERT (which is the only time this trigger fires), all :OLD values are NULL.
>
Error(5,17): PLS-00049: bad bind variable 'OLD.QOH'
Error(6,7): PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ;
Error(6,9): PLS-00049: bad bind variable 'OLD.QOH'I don't believe the code you posted is causing these errors. Each of the errors mentioned above would cause a different message. Post the actual code and error messages.
Whenever you post a question, post all the code necessary for people to re-create the problem and test their ideas.
In this case, that means CREATE statements for any tables or sequences involved, INSERT statements for any tables that need rows (such as product) as they exist before the INSERT, some INSERT statements for orderline, and the contents of all the tables after each of those INSERTs.
Always say which version of Oracle you're using. -
PLS-00049 error :bad bind variable
We recently migrated our dev databse to 10g
for the following table the trigger is erroring out as follows :
The same trigger works in 9i production though .Can anyone see anything that might be amiss
CREATE TABLE ARCH_CLAIM_REJECTION_CODES
REJECTION_ID NUMBER(38) NOT NULL,
REJECTION_DESC VARCHAR2(600 BYTE),
DT_STAMP NUMBER,
DT_CREATED DATE,
DT_LAST_UPDATED DATE
INSERT INTO CLAIM VALUES (
:OLD.REJECTION_ID,
:OLD.REJECTION_DESC,
:OLD.DT_STAMP,
:OLD.DT_LAST_UPDATED,
:OLD.DT_CREATED
PLS-00049: bad bind variable 'OLD.REJECTION_ID'
PLS-00049: bad bind variable 'OLD.REJECTION_DESC'
PLS-00049: bad bind variable 'OLD.DT_STAMP'
PLS-00049: bad bind variable 'OLD.DT_LAST_UPDATED'
PLS-00049: bad bind variable 'OLD.DT_CREATED'REATE OR REPLACE TRIGGER ODSLIVE.TR_CLAIM_REJECTION_CODES_BUR
BEFORE UPDATE ON CLAIM_REJECTION_CODES
FOR EACH ROW
DECLARE
gv_errcode VARCHAR2(100);
gv_errmsg VARCHAR2(100);
BEGIN
--DBMS_OUTPUT.PUT_LINE('TRIGGER CALLED FOR CLAIM_REJECTION_CODES');
INSERT INTO ARCH_CLAIM_REJECTION_CODES VALUES (
:OLD.REJECTION_ID,
:OLD.REJECTION_DESC,
:OLD.DT_STAMP,
:OLD.DT_LAST_UPDATED,
:OLD.DT_CREATED
EXCEPTION
WHEN OTHERS THEN
gv_errcode :=SQLCODE;
gv_errmsg :=SQLERRM;
PKG_COMMONACTIVITIES.PR_ERRORLOG_DETAILS('TRIG-01-0001',
gv_errcode,
gv_errmsg,
'TR_CLAIM_REJECTION_CODES_BUR',
'CLAIM_REJECTION_CODES');
--DBMS_OUTPUT.PUT_LINE('TM-01-0001 '||'TR_CLAIM_REJECTION_CODES_BUR '||'CLAIM_REJECTION_CODES'||gv_errmsg);
--RAISE;
END TR_CLAIM_REJECTION_CODES_BUR; -
Bad bind variable error on creating trigger
hi
im trying to create a trigger on a table in Oracle and I keep gettin this error:
PLS-00049: bad bind variable 'NEW.ID'
TeamID is a primary Key, it creates the sequence fine, but i get the error on the create trigger,
CREATE TABLE TBLTEAMS
TEAMID NUMBER(5),
NAME VARCHAR2(50 BYTE),
MANAGER VARCHAR2(50 BYTE),
COSTCENTRE NUMBER(9),
PARENTTEAMID NUMBER(5)
create sequence seq_Teamsautonumber;
create trigger trg_Teamsautonumber
before insert on tblteams
for each row
begin
select seq_Teamsautonumber.nextval into :new.id from dual;
end;
any ideas?You have said
:new.idthat means you are trying to load the sequence value into a column that doesn't exist in your table.
you would need to use
:new.teamidAssuming you are trying to auto-populate the TEAMID column on your table. -
TRIGGER ERROR: bad bind variable
Hello,
I'm just starting off with oracle and am trying to do the same as auto_increment in mysql is doing by creating this sequence and trigger, but on the trigger I am getting the following error:
error:
PLS-00049: bad bind variable 'TAKEOVER_USERS.TAKEOVER_UID'This is the code for trigger, table and sequence:
trigger:
CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1"
BEFORE
insert on "TAKEOVER_USERS"
for each row
begin
select TAKEOVER_UID.nextval into :takeover_users.TAKEOVER_UID from dual;
end;Table:
CREATE TABLE "TAKEOVER_USERS"
( "TAKEOVER_UID" NUMBER NOT NULL ENABLE,
"TAKEOVER_FBID" VARCHAR2(20) NOT NULL ENABLE,
"takeover_accepted_terms" NUMBER(1,1) NOT NULL ENABLE,
"takeover_lastName" VARCHAR2(30),
"takeover_firstName" VARCHAR2(30),
"takeover_country" VARCHAR2(40),
"takeover_session" VARCHAR2(50) NOT NULL ENABLE,
"takeover_created" TIMESTAMP (6) NOT NULL ENABLE,
CONSTRAINT "takeover_users_PK" PRIMARY KEY ("TAKEOVER_UID") ENABLE
)sequence:
CREATE SEQUENCE "TAKEOVER_UID" MINVALUE 1 MAXVALUE 99999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLEYou got any idea what I need to change to make this work?
Thanks!
Christineif your DB is 11g you can try this
CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1"
BEFORE
insert on "TAKEOVER_USERS"
for each row
begin
:NEW.TAKEOVER_UID:=TAKEOVER_UID.nextval;
end;if 10g or older..
CREATE OR REPLACE TRIGGER "TAKEOVER_USERS_T1"
BEFORE
insert on "TAKEOVER_USERS"
for each ROW
BEGIN
SELECT TAKEOVER_UID.NEXTVAL INTO :NEW.TAKEOVER_UID FROM dual;
end;Regards,
Prazy -
Bad bind variable 'NEW.SYS_NC_ROWINFO$
Hi
in order to assist in error resolution when inserting XML data into a XMLTYPE table I have attempted to create a trigger on the table as
SQL> CREATE or replace TRIGGER VALIDATE_PersonAlert3
2 before insert on pa_tab3
3 for each row
4 declare
5 XMLDATA xmltype;
6 begin
7 XMLDATA := :new.sys_nc_rowinfo$;
8 xmltype.schemavalidate(XMLDATA);
9 end;
10 /
Warning: Trigger created with compilation errors.
and get the following
SQL> show errors
Errors for TRIGGER VALIDATE_PERSONALERT3:
4/19 PLS-00049: bad bind variable 'NEW.SYS_NC_ROWINFO$'
SQL> spool off
Anyone know the answer ?
The Trigger example was based on the Oracle 9i XML Developers Guide.
Is there more to adding XDB to database than running catqm.sql ?Hi
To install XDB you should also run catxdbj.sql (in the XDB manual, page A-3, you can find more info...).
I had no problem to create a trigger accoring to the documentation...
Chris -
Hi,
I'm trying to run a script to generate the table. And I'm getting the following error at
create or replace trigger bi_wvufr_applications
before insert on wvufr_applications
for each row
begin
if :new.application_id is null
then select wvufr_applications_seq.nextval
into :new.application_id
from dual;
end if;
:new.created_date := sysdate;
:new.created_by := nvl(wwv_flow.g_user,user);
end;
ERROR at line 7: PLS-00049: bad bind variable 'NEW
Can anybody explain me what I'm doing wrong?
Any help is greatly appreciated
Thanks in advance
- HarithaHi,
I'm new to HTML DB and I'm in the initial stage of creating the database(Tables) and I'm getting the above error. Has anybody ran the scripts successfully to generate the tables for Issue Tracking Tutorial? Because the above code snippet for trigger exist in that script. I'm following those scripts to generate the tables and the triggers for my application and I'm getting the above error.
Any help, Please !!
Thanks
- Haritha
Maybe you are looking for
-
How to unsync messages between macbook air and my iPhone
I started using the messages on my macbook air. Then I accidentally used the same Apple id for my Iphone. Now what ever messages I recieve on my macbook I also get on my phone. Is there a way I can unsync the two so that I can only get the messages o
-
Currency transalation in update rules
Hi Gurus, I have activated some business content cubes and reports. The update rules to cube translated purchase order keyfigures to default currency EURO. I want to change this to GBP( Which source currency). In other terms i don't want any currency
-
We are currently upgrading our Oracle Forms 6i applications into Forms 10g. During this process, we have encountered a screen flashing issue. The application is coded in such a way that there is one form that remains open and it keeps calling other f
-
Screen sharing over the net. Is it possible.
I was wondering if someone with screen sharing abilities could help out. I was wondering. Is it possible to share screens over the net. For example, my mom is like a 100 miles away. Running Leopard. How could I access her screen so that I could show
-
Hi all, I am having trouble locating a LabVIEW Toolkit. Could somebody please send me a link to somewhere where I can download the eval version of the Report Generator Toolkit for Microsoft Office for LabVIEW 2013 64bit.? Thank you in advance, Bob