Home » SQL & PL/SQL » SQL & PL/SQL » trigger
trigger [message #868] Sun, 10 March 2002 09:28 Go to next message
sara
Messages: 36
Registered: February 2000
Member
Hello,
trigger PRE-TEXT-ITEM
1.SELECT nvl(max(sno),0)+1 INTO :xyz.sno FROM xyz;
gives result on runtime form sno= 1,2,3 .....

Now I want to generate sno A1, A2, A3....
2.SELECT nvl(to_char(max(sno),'A'||(sno)),0)+1 INTO :xyz.sno FROM xyz;
compile successfully but on runtime gives an error
FRM-40735 TIGGER RAISED UNHANDLED EXCEPTION ORA-00937

What's wrong with this querry.please rectify?
Re: trigger [message #880 is a reply to message #868] Mon, 11 March 2002 00:45 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
try it
SELECT 'A'||to_char(nvl(max(sno),0)+1)
INTO :xyz.sno FROM xyz;
Re: trigger [message #890 is a reply to message #868] Mon, 11 March 2002 07:10 Go to previous message
suresh vemulapali
Messages: 6
Registered: January 2002
Junior Member
Hi pratap,
U r selecting from and inserting into the same table.but thanx anyway.
i did this way at the moment

> insert into xyz (sno) values( 'A-'||SEQ1.NEXTVAL);
>SQL> SELECT * FROM XYZ;

SNO
----------
A-1

But if any one could remove the errors in the following query it would be valued .
> insert into xyz (sno) values( 'A-'||to_char(nvl(max(sno),0)+1));
Previous Topic: Nested query
Next Topic: sql+ alter table constraint syntax
Goto Forum:
  


Current Time: Thu Apr 25 22:18:29 CDT 2024