0

I have created a table in oracle xe

create table tbl_unit_mst
(
  id number(10,0) constraint id_pk primary key,
  unit_code char(2) not null constraint unit_code_uk unique,
  unit_name varchar2(30) not null constraint unit_name_uk unique,
  crtd_date date default sysdate,
  is_active number(1,0) default 1 constraint is_active_ck check(is_active in (0,1)),
  crtd_by varchar2(6)
);

and then created a squence

create sequence seq_tbl_unit
start with 1
increment by 1
nocache
nocycle;

then I created a Trigger

create  trigger trig_id_increment
  before insert
    on tbl_unit_mst for each row
      begin
        select seq_tbl_unit.nextval into : new.id from dual;
    end;

Now when I am trying to run an insert statement insert into tbl_unit_mst ( unit_code, unit_name) values('01','Ajbapur'); it gives an error SQL Error: No more data to read from socket

If I disable Trigger then it is working fine. can anyone help me to find out where I am making mistakes

Ravi
  • 1,744
  • 2
  • 20
  • 37
  • You must be using some other program to run this? Are you using Java? Have you seen http://stackoverflow.com/questions/7839907/no-more-data-to-read-from-socket-error and http://stackoverflow.com/questions/12605835/no-more-data-to-read-from-socket? What is your actual error message? – Ben Jul 28 '14 at 12:36
  • I am writing this query on oracle sql developer – Ravi Jul 28 '14 at 12:37
  • In that case the second question I mention: [No more data to read from socket](http://stackoverflow.com/questions/12605835/no-more-data-to-read-from-socket) is a duplicate; you need to investigate a lot further as it's probably a more serious database error. – Ben Jul 28 '14 at 12:39
  • 1
    If your actual trigger code has a space between the colon and `new.id`, you would get an error when you tried to create the trigger. `:new.id` needs to be one, single, contiguous token. Are you actually getting an error when you create the trigger? Or did you just introduce the space when posting the question? – Justin Cave Jul 28 '14 at 13:40
  • 1
    thanks @JustinCave--- I used **into:new.id** instead of **into : new.id** and it is working now – Ravi Jul 29 '14 at 05:23
  • @RVB `into :new.id` would be better. – jpmc26 Oct 06 '17 at 21:22

0 Answers0