Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Informix > create sequence and create trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-08, 21:32
talk2neo talk2neo is offline
Registered User
 
Join Date: Mar 2008
Posts: 2
create sequence and create trigger

Hello, the below statement works well on oracle ,please can someone help on how to create the below statement successfully on informix database.

CREATE SEQUENCE Y;

CREATE TRIGGER smou_auto BEFORE INSERT on smou
for each row
when (new.id is null)
begin
SELECT y.nextval INTO :new.id FROM DUAL;
end;
/
Reply With Quote
  #2 (permalink)  
Old 03-23-08, 13:53
talk2neo talk2neo is offline
Registered User
 
Join Date: Mar 2008
Posts: 2
There will be no need to create the sequence and there will be no need to create trigger , creating the table intended to use the sequence in the below manner will give the solution expected from the sequence and trigger

create table smou
(id SERIAL not null,
name varchar(30) default NULL,
time varchar(100) default NULL);


"id SERIAL not null" this makes informix provides every inserted record
with a unique number, so there is no need to create sequence or trigger.
Reply With Quote
  #3 (permalink)  
Old 03-24-08, 17:32
ceinma ceinma is offline
Registered User
 
Join Date: Apr 2007
Location: Distrito Federal - Brasil
Posts: 197
unfortunately , with IDS is not possible to execute any command differ of INSERT,DELETE,UPDATE,EXECUTE PROC/FUNC inside a Trigger.

You need create a SPL to get the nextval .

Code:
CREATE SEQUENCE Y; create procedure sp_smou_auto() returning integer return y.nextval ; end procedure ; CREATE TRIGGER smou_auto INSERT on smou referencing new as n for each row when (n.id is null) ( execute procedure sp_smou_auto() into id ) ;
__________________
________________________________________
César Inacio Martins
Distrito Federal - Brasil
________________________________________
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On