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.
Similar Messages
-
Bind Variables and Shared Component Report Query
I have a query in a region report which I have replicated to a shared component report query.
Both queries reference page items as bind variables in the where clause.
The report region on screen shows the correct results but the report query shows "no data". This is the case when running "Test Query" and "Download XML data" from the shared component report query definition. If I hardcode the variable names I get rows returned, If I use bind variables - and specify the values for these variables I get no data. THe XML file contains the tags for each bind variable I have specified but has no data between the tags. I have Ticked the box to include application and session state but it appears that the bind variables are not being used.
When I use my report query in the application (URL tied to a button) I get the same problem, the binds are not being passed to the report query.
Can someone please clarify if this is a bug or not? And if not, how can I get it to work.
I am using Apex 4.0.2
Thanks
KathrynHi
To confirm, yes I selected the bind variables. I used these in the report layout, but the xml file has them as empty i.e.
<P0_START_DATE><P0_START_DATE/> with nothing in between.
IN the Test Query section, if I put real values in the boxes for the bind variables, I get no data found. If I hardcode the values into the query, I get the data.
I've repeated the create report query many times and have created a report layout in RTF. I can use the layout with my region - in the print attributes and the layout works with the query but I need to create a PDF using 2 queries - ROWSET1 and ROWSET2. I can generate the XML but the values in the rows are all empty. When I use the layout with a report query instead of the region, I get no data even though I have used the same sql and have selected the bind variables. I was using variables from page items on page zero but have also tried using page items on the current page, the result is the same.
I need to use a report query and a report layout as I need data from 2 queries in the PDF.
I looked at your demo - what happens if you add a second sql query to the report query - is there any chance I can look at the back end (developer access?)
Thanks for your input
Kathryn -
Getting a bad bind variable error while compiling a custom form in R12
Hi,
I am getting a bad bind variable error while compiling a custom form.
I tried setting the forms_path variable and I am still getting the error. Can anyone please suggest what can be done?
DECLARE
BEGIN
IF :parameter.p_line_ship_to = 'T'
THEN
IF :SYSTEM.cursor_item = 'LINE.SHIP_TO'
THEN
:parameter.lov_num_param1 := :line.ship_to_customer_id;
oe_lines.ship_to ('WHEN-VALIDATE-ITEM');
:parameter.lov_num_param1 := :line.ship_to_customer_id;
END IF;
:parameter.p_line_ship_to := 'F';
END IF;
END;
I am getting this error:
Bad bind variable 'parameter.p_line_ship_to'The Parameter is not defined in the form.. But, this form is already been compiled and deployed.. I have to make some changes to the form and tried to compile it, when i am getting this error. Is it possible that the parameter would be defined in some other form or can this error be due to some other reasons?
Thanks in Advance. -
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!
-RajeevYou 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] -
Hi friend,
I do want to use a trigger to update a varchar2 value:
create or replace trigger WORK_STITCH_NAME_TRIG
after insert or update on ASS_WORK_STITCH
for each row
declare
NAME VARCHAR2(100);
begin
if inserting then
select ENAME into NAME from UAMRIS.WORDER where OID=:new.OID;
update UAMRIS.WORDER
set ENAME=(:new.NAME)
where OID=:new.OID;
end if;
end ;
but it gives me error as ':New.Name' bad bind variable.
Can someone help me out with this plz!
Thanks,
Zeeshanuser526055 wrote:
You correction in the trigger created correctly but it is not making any changes to the worder table!If you read my last reply, that was exactly what I said. Now Centinul could be right. Do you have column NAME in triigering table and you want to update WORDER table with column NAME new value? If so, you do not need PL/SQL variable at all:
create or replace trigger WORK_STITCH_NAME_TRIG
after insert or update on ***_WORK_STITCH
for each row
begin
if inserting then
update UAMRIS.WORDER
set ENAME=:new.NAME
where OID=:new.OID;
end if;
end ;
/ SY. -
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 -
10g declare :global variable error (bad bind variable)
In a 10g form, I tried this code in the pl/sql block and in the spec of a library package
begin
:global.config := 'x';
...upon compile, I get an error
"bad bind variable"
...encountered the symbol "GLOBAL" when expecting one of the following...It doesn't like :GLOBAL.variablename := 'x';
What am I doing wrong?
Thank you.globals are allowed in librarys, but in libraries you have to use COPY and NAME_IN to access objects you access via :-logic in forms-modules, e.g. setting the global would be like
COPY('X', 'GLOBAL.CONFIG');Edited by: aweiden on 29.10.2008 19:33 -
Hi all,
I have this code in a PB trigger:
declare
v_alert_button number;
invalid BOOLEAN;
CURSOR C_REFNO_SEARCH IS
SELECT * FROM REFNO_LIB.REFNO_02000_IDENT
WHERE CAGECDXH = :CONTROL.C_CAGECDXH AND
REFNUMHA = :CONTROL.C_REFNUMHA;
BEGIN
OPEN C_REFNO_SEARCH;
FETCH C_REFNO_SEARCH INTO :REFNO_02000_IDENT;
invalid := C_REFNO_SEARCH%NOTFOUND;
IF invalid then
V_ALERT_BUTTON := SHOW_ALERT('REFNUM_NOT_FOUND');
END IF;
CLOSE C_REFNO_SEARCH;
REDISPLAY;
END;
I can't compile this trigger code cleanly. I get a error on the FETCH statment pointing to ":REFNO_02000_IDENT" as a bad bind variable. I'm trying to populate the ":REFNO_02000-IDENT" data block without having to key in over 50 items that are in the block.
Any help is appreciated.
ThanksIt's not possible what you want. I guess you have to key in the items. Forms tries to find the item :REFNO_02000_IDENT and can't find it becuase it doesn't exist. Thats why you get bad bind variable.
-
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 -
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) -
CG$CTRL Bad Bind Variable error Migrating from Forms 4.5 to Forms 6
Hi All,
I have an old application deployed using Forms 4.5 runtime that I would like to migrate to the latest version of Forms.
My intended migration path was Forms 4.5 -> Forms 6i -> Forms 10g.
After successfully converting the source 4.5 .pll library files to Forms 6i by opening the files in the Forms 6i Forms Builder (6.0.8.25) and then saving the library files in the FORMS60_PATH I now encounter the following error that is hindering the migration process:
Error 49 at line 6, column 3
bad bind variable 'CG$CTRL.SE_CODE'
I have read some other posts that mention Headstart Templates. Does anyone know if these CG$xxxx program units are part of Headstart? And if so, how can I get the Template files?
Thanks in advance,
Gary.CG$CTRL are cerated when the forms are developed using the designer...
Oracle Forms requires that every item in a form must belong to a block, but these generated non-base table items are not associated with any module component. There is therefore no repository definition of a data block to which the generated items can belong.
Form Generator resolves this situation by creating a control block to which the generated non-base table items can belong. The generated block is given the name CG$CTRL.
The CG$CTRL block has no physical representation in the generated form and has none of the properties (e.g. block decoration) associated with generated data blocks. The CG$CTRL block is simply a logical object to which generated
So try to find out in which form the above procedure /program unit is being called and then modify the pll accordingly....
Rajesh Alex -
Parameter error - bad bind variable in a Package..!!
Hello All
i am tring to create a security package with in one procedure i am trying to handle the number of times the user enters the wrong user name or password:
-i created a parameter on my login form and add it to my procedure and it works just fine,But when i tried to copy the same procedure the package inside my library can't recognize that Parameter.
-It gives me error : bad bind variable.
The code is as follows.
PARAMETER.COUNT := :PARAMETER.COUNT + 1;
IF :PARAMETER.COUNT > 3 THEN
WRONG_ALERT('WRONG_PASS',' ur number of trials has expiered the form will be closed ');
EXIT_FORM;
END IF;
Can anyboady help me pls.
Regards,
Abdetu.Super,It works Just fine.
Thanks Gerd,
That's make me decide that if i have the following statatment for example:
IF :USER_CODE IS NULL THEN .........
I have to change it to :
IF copy (name_in ('USER_CODE' )) IS NULL THEN..........
But,if i have the following select statment :
==============================
SELECT USER_CODE , USER_PASS WORD
INTO :GLOBAL.USER_CODE , :GLOBAL.USER_PASS WORD
FROM APP_USERS
WHERE USER_CODE = :USER_CODE
AND USER_PASS WORD= :USER_PASS WORD;
Should i transfer it to the following:
=========================
SELECT USER_CODE , USER_PASS WORD
INTO COPY(NAME_IN ('GLOBAL.usr_code'), COPY(NAME_IN ('GLOBAL.PASSWORD')
FROM APP_USERS
WHERE USER_CODE = COPY(NAME_IN ('USER_CODE' )
AND USER_PASS WORD=COPY(NAME_IN ('USER_PASS WORD');
Pls help me,it's my first time ...
Thanks in advance.
Regards,
Abdetu. -
'Error 49 bad bind variable' error message.
When I copied a form that has been working from our Linux server to my PC and compiled it, I received many error messages like this in several procedures, functions and triggers:
“Error 49 at line 69, column 10, bad bind variable ‘edit_Dealer.corporation’
Does anybody know why this is? As I said, the app works for the end user from the Linux server.
Thank You.Does the form you copied have any attached libraries or subclassed objects? If so, did you copy the Library and Object source files to your PC as well? If you copied these supporting files already, are they in a directory location that is part of your FORMS_PATH?
Hope this helps,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly. -
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;
Maybe you are looking for
-
Cannot send email in primary account
Iphone will suddenly not send my Comcast (primary account) email. When I try, I get a prompt asking for my gmail password. This makes no sense but shows up every time. What can be wrong? I don't even have a gmail account set up on my phone... Input
-
ORA-01403: no data found (WWV-16016) error
I have a very simple form with two fields. This form is opened in the update mode through a report which pass a parameter to the form. When I press 'Delete' button to delet the record, I get this error message: Error: An unexpected error occurred: OR
-
Business Document Navigator -- Show only specific document types
Hello to all, I'm using the business document navigator. With parameter excluding of method cl_bds_document_set=>call_navigator you can disable the standard document types are shown by passing the value NO_STANDARD_DOCS. Is it possible to define docu
-
Accessing a different class using ActionPerformed
hi im trying to access a method in a different class using public void actionPerformed (ActionEvent e) { if(e.getSource() == AuthorCombo) { ComboAction(); else if(e.getSource() == SearchButton){
-
PeopleSoft XMLP : Conditional Formatting for Cross tab report
I have developed a XMLP cross tab report using ps query. Report runs good for (.htm,pdf,rtf) extension . But I am unable to format the data based on condition. Code which get displayed at the data field : <?sum ($G1[(./DESCR=current()/DESCR)]/JOB_REQ