views:

183

answers:

3

I want to change the delimiter:

Can someone help me to change the delimiter in sqlplus in Oracle 11g

CREATE OR REPLACE TRIGGER test_trigger 
BEFORE INSERT ON test 
REFERENCING NEW AS NEW FOR EACH ROW 
BEGIN 
SELECT test_sequence.nextval INTO :NEW.ID FROM dual; 
END; 
/ 

this is the trigger I want to create. but after Select statement it stops because of ; is there. that is why I want to change the delimiter. I hope everyone gets the idea on this now..

+1  A: 

There is nothing wrong with the syntax of your trigger. I can run it in my (vanilla) SQL*Plus environment:

SQL> CREATE OR REPLACE TRIGGER test_trigger
  2  BEFORE INSERT ON test
  3  REFERENCING NEW AS NEW FOR EACH ROW
  4  BEGIN
  5  SELECT test_sequence.nextval INTO :NEW.ID FROM dual;
  6  END;
  7  /

Trigger created.

SQL>

And lo! the trigger works:

SQL> insert into test (col1) values ('Simples!')
  2  /

1 row created.

SQL> select * from test
  2  /

        ID COL1
---------- ------------
         1 Simples!

SQL>

All I can think is that you have some blank lines in the code which you are typing. If this is the situation you can override the default behaviour with this SQL*Plus command:

SQL>  set sqlblanklines on
APC
A: 

Is this you are looking for

select q'#Oracle's quote operator#' from dual;

Q'#ORACLE'SQUOTEOPERATO
-----------------------
Oracle's quote operator

Edit 1:

CMDS[EP] {;|c|OFF|ON}

   Change or enable command separator - default is a semicolon (;)
Bharat
when we write a sql or anything we put ; to end the line. so in a trigger i cant do the trigger properly because when i press that it ends the line. cant type the last two lines. thats y i want to change the delimiter. can someone help me
Nubkadiya
@NubKadyia, can you edit your question to put this information along with the problematic trigger code so we help?
carpenteri
@Nubkadiya, I suggest you cut and paste exactly what you're typing into SQLPlus and the output you're getting. It's not clear to me why the semicolon would be causing you any trouble.
Dave Costa
CREATE OR REPLACE TRIGGER test_triggerBEFORE INSERTON testREFERENCING NEW AS NEWFOR EACH ROWBEGINSELECT test_sequence.nextval INTO :NEW.ID FROM dual;END;/this is the trigger i want to create. but after Select statement it stops because of ; is there. thats y i want to change the delimiter. i hope everyone got a idea on this now..
Nubkadiya
@anyone with enough rep put the last comment in the original question?
carpenteri
can you please help me
Nubkadiya
@Nubkadiya - for future reference, you can help us to help you by *asking the right question* in the first place.
APC
A: 

If you're using SQLPlus and not some other tool I'm not sure what the root issue is, but here's the answer to your workaround question:
To change the command delimiter from the default value of ; use

SQL> set cmdsep /
SQL> show cmdsep
cmdsep "/" (hex 2f)

To restore the default value after you've created your trigger:

SQL> set cmds off
SQL> show cmds
cmdsep OFF
BenV