Solved

Error while writing trigger in Oracle Enterprise Manager Console

Posted on 2008-10-14
11
1,363 Views
Last Modified: 2013-12-18
Hi,

I am using Oracle Enterprise Manager to write a trigger, but get "Missing in or out parameters at index:: 1" everytime that I want to use :new or :old. I looked around on the internet and it seems to be either a bind variable problem or using preparedStatement instead of Statement problem, but I have no idea how I can use that in Enterprise Manager Console. Does anyone know what I can do to get the Enterprise Manager to accept :new and :old for what they are?
0
Comment
Question by:PopoDi
  • 6
  • 4
11 Comments
 
LVL 7

Expert Comment

by:Dr_Billy
ID: 22711997
can you post the code of the trigger ?
0
 

Author Comment

by:PopoDi
ID: 22712049
Hi Dr. Billy,

this is one of the variations that I tried (it really does not matter what I do inside the trigger, the missing parameter error comes out as soon as I use the semicolon for NEW or OLD inside the "trigger body" window):

CREATE OR REPLACE TRIGGER "TEST"."PR_UPDATE" AFTER
UPDATE OF "PSZ" ON "TEST"."TABLE1" FOR EACH ROW BEGIN

var1 VARCHAR2(10)

var1 := :OLD.KEYTAG

INSERT INTO REVTRACK (KEYTAG, CHGCOL)
VALUES ( var1, 'PSZ');
END;


0
 
LVL 2

Expert Comment

by:WallaceAdrian
ID: 22712362
This should do it.

CREATE OR REPLACE TRIGGER TEST.PR_UPDATE AFTER
UPDATE OF PSZ ON TEST.TABLE1 FOR EACH ROW
DECLARE
var1 VARCHAR2(10);
BEGIN
var1 := :OLD.KEYTAG;
INSERT INTO REVTRACK (KEYTAG, CHGCOL)
VALUES ( var1, 'PSZ');
END;
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:PopoDi
ID: 22712434
Hi WallaceAdrian,

I still get the same error about a missing index (attached jpeg file).

Apparently it has to do with variable binding for :OLD (or :NEW) and I don't know how to get around it in Enterprise Manager (I've seen one solution for sql saying to use Statement instead of PreparedStatement, but I don't know how this could be done through Enterprise Manager interface either - I am very new to this) .

Thanks!
errormsg.JPG
0
 
LVL 2

Accepted Solution

by:
WallaceAdrian earned 500 total points
ID: 22712544
Have you tried creating the trigger in SQLPLUS?

The easiest way is to create a script file with your create statement (i.e. create_trigger.sql)

Connect to the database in sqlplus and execute

@create_trigger.sql
0
 

Author Comment

by:PopoDi
ID: 22712617
Hi WallaceAdrian,

I only have Enterprise Manager.
Is there a way of getting the values from the record without using :NEW or :OLD (like a function call or something)?

Thanks!
0
 
LVL 2

Expert Comment

by:WallaceAdrian
ID: 22712692
You should have the sqlplus.exe in your oracle bin folder.

You could use a stored procedure to record the changes before updating the table.

procedure update_table1(i_table1 in table1%rowtype) is
begin
  INSERT INTO REVTRACK (KEYTAG, CHGCOL)
  VALUES ( i_table1.psz, 'PSZ');
  update table1
  set row = i_table1
  where pk = i_table1.pk;
end;
0
 

Author Comment

by:PopoDi
ID: 22712883
well oracle is definitely not my forte. :) This is the first time I'm doing anything with it.

what I am trying to do is update the REVTRACK table whenever a table1.psz is changed - I want to add table1.keytag into revtrack.keytag and concatenate 'psz' into the revtrack.chgcol (what I posted above does not concatenate yet).

So in your stored procedure, you are updating table1, right? Would I just drop the 3 columns to adapt it to what I want?
0
 
LVL 2

Expert Comment

by:WallaceAdrian
ID: 22718837
The procedure is updating table1. I'm not sure what you mean about dropping the 3 columns?
0
 

Author Comment

by:PopoDi
ID: 22724379
oh sorry, I meant last 3 lines of code (I did not even realize I wrote columns). :)
thanks!
0
 

Author Closing Comment

by:PopoDi
ID: 31505927
As you said, using a different interface solved the problem.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question