ORA-06502 in SQL*Plus, not in Toad [message #580861] |
Thu, 28 March 2013 14:42 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/354ca49d89f4a237d008ff3151514657?s=64&d=mm&r=g) |
jimkd1yv
Messages: 3 Registered: March 2013 Location: CT, USA
|
Junior Member |
|
|
Trying to learn and understand Triggers, PL/SQL code, etc. When I execute a simple insert using Toad for Oracle, all is fine. When I try the identical insert in SQL*Plus, it throws error ORA-06502 during execution of the trigger. What have I done wrong?
Here is the error info:
insert into AAAJOB(PROCEDURENAME,DESCRIPTION) VALUES('OOO','PPP')
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "PMSC0.AAAJOB_TIMING", line 10
ORA-04088: error during execution of trigger 'PMSC0.AAAJOB_TIMING'
===
Here is the table and the trigger:
CREATE TABLE PMSC0.AAAJOB
(
CREATETS TIMESTAMP(0) DEFAULT current_timestamp,
PROCEDURENAME VARCHAR2(100 CHAR),
DESCRIPTION VARCHAR2(100 CHAR),
LASTUPDATEDBY VARCHAR2(9 CHAR)
)
TABLESPACE PMSC0_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE OR REPLACE TRIGGER PMSC0.AAAjob_timing
BEFORE INSERT OR UPDATE
ON PMSC0.AAAJOB REFERENCING OLD AS old_row NEW AS new_row
FOR EACH ROW
BEGIN
IF :new_row.createTS <> SYStimestamp
OR :new_row.createTS IS NULL
THEN
SELECT current_timestamp
INTO :new_row.createTS
FROM DUAL;
END IF;
SELECT SYS_CONTEXT ( 'USERENV', 'OS_USER' )
INTO :new_row.lastupdatedby
FROM DUAL;
END;
/
The error seems to be on this:
SELECT current_timestamp
INTO :new_row.createTS
Thanks,
JimR
|
|
|
|
Re: ORA-06502 in SQL*Plus, not in Toad [message #580865 is a reply to message #580861] |
Thu, 28 March 2013 15:27 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Do NOT post schema name, tablespace name and storage parameters in your test case, we have not the same ones:
SQL> CREATE TABLE PMSC0.AAAJOB
2 (
3 CREATETS TIMESTAMP(0) DEFAULT current_timestamp,
4 PROCEDURENAME VARCHAR2(100 CHAR),
5 DESCRIPTION VARCHAR2(100 CHAR),
6 LASTUPDATEDBY VARCHAR2(9 CHAR)
7 )
8 TABLESPACE PMSC0_DATA
9 PCTUSED 0
10 PCTFREE 10
11 INITRANS 1
12 MAXTRANS 255
13 STORAGE (
14 INITIAL 64K
15 MINEXTENTS 1
16 MAXEXTENTS UNLIMITED
17 PCTINCREASE 0
18 BUFFER_POOL DEFAULT
19 )
20 LOGGING
21 NOCOMPRESS
22 NOCACHE
23 NOPARALLEL
24 MONITORING;
CREATE TABLE PMSC0.AAAJOB
*
ERROR at line 1:
ORA-01918: user 'PMSC0' does not exist
Use SQL*Plus and copy and paste your session, the WHOLE session, including all object creations and statement generating the error.
SQL> CREATE TABLE AAAJOB
2 (
3 CREATETS TIMESTAMP(0) DEFAULT current_timestamp,
4 PROCEDURENAME VARCHAR2(100 CHAR),
5 DESCRIPTION VARCHAR2(100 CHAR),
6 LASTUPDATEDBY VARCHAR2(9 CHAR)
7 )
8 /
Table created.
SQL> CREATE OR REPLACE TRIGGER AAAjob_timing
2 BEFORE INSERT OR UPDATE
3 ON AAAJOB REFERENCING OLD AS old_row NEW AS new_row
4 FOR EACH ROW
5 BEGIN
6 IF :new_row.createTS <> SYStimestamp
7 OR :new_row.createTS IS NULL
8 THEN
9 SELECT current_timestamp
10 INTO :new_row.createTS
11 FROM DUAL;
12 END IF;
13
14 SELECT SYS_CONTEXT ( 'USERENV', 'OS_USER' )
15 INTO :new_row.lastupdatedby
16 FROM DUAL;
17 END;
18 /
Trigger created.
SQL> insert into AAAJOB(PROCEDURENAME,DESCRIPTION) VALUES('OOO','PPP');
1 row created.
No error for me.
So do the same thing and add:
select SYS_CONTEXT ( 'USERENV', 'OS_USER' ) from dual;
Regards
Michel
|
|
|
|
|
|