If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Multiple For each in procedure

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-10, 12:03
pbangalore pbangalore is offline
Registered User
 
Join Date: Nov 2009
Posts: 14
Red face Multiple For each in procedure

I am working with informix 10 and have been facing an issue while using multiple for each in a procedure. It works when i have just the first for each and the following for eachs does not seem to work.

Ex:
CREATE PROCEDURE test_1()

BEGIN

/*
'Started working on Entities of type - network element, shelf, card, port,central office'
*/
FOREACH SELECT e.entity_id
INTO ent_id
FROM entity e
where substr(e.hier_name,5,2) in ('CA')
and e.hier_name not in ('BGRVCAXFRLO','BGRVCAXFRS1','BLYTCABARL0','BLYTCA XF92K','BLYTCAXGRS1','BLYTCAXHRL1','CEVLCAXFRS6',
'HVSUCAXFRS1','PYVLCAAARL0','WDFRCAAARL0','WDFRCAX FRS1','PLVRCAXFRS1')


/*Delete the attributes of the entity*/
delete from ent_attr
where entity_id = ent_id;



/*Delete the alias of the entity*/
delete from entity_alias
where entity_id = ent_id;



/*Delete the entity from entity_relations*/
delete from entity_relations
where entity_id = ent_id;

delete from entity_relations
where rel_ent_id = ent_id;



/*Delete the entity*/

delete from entity
where entity_id = ent_id;


END FOREACH;
/*
'Completed working on Entities of type - network element, shelf, card, port,central office'
*/

/*
'Started working on Entities of type - circuit, channel' ;
*/

FOREACH SELECT e.entity_id
INTO ent_id
FROM entity e
where substr(e.hier_name,18,2) in ('CA')
and e.hier_name not in ('BGRVCAXFRLO','BGRVCAXFRS1','BLYTCABARL0','BLYTCA XF92K','BLYTCAXGRS1','BLYTCAXHRL1','CEVLCAXFRS6',
'HVSUCAXFRS1','PYVLCAAARL0','WDFRCAAARL0','WDFRCAX FRS1','PLVRCAXFRS1')


/*Delete the attributes of the entity*/
delete from ent_attr
where entity_id = ent_id;



/*Delete the alias of the entity*/
delete from entity_alias
where entity_id = ent_id;



/*Delete the entity from entity_relations*/
delete from entity_relations
where entity_id = ent_id;

delete from entity_relations
where rel_ent_id = ent_id;



/*Delete the entity*/
delete from entity
where entity_id = ent_id;



END FOREACH;

FOREACH SELECT e.entity_id
INTO ent_id
FROM entity e
where substr(e.hier_name,30,2) in ('CA')
and e.hier_name not in ('BGRVCAXFRLO','BGRVCAXFRS1','BLYTCABARL0','BLYTCA XF92K','BLYTCAXGRS1','BLYTCAXHRL1','CEVLCAXFRS6',
'HVSUCAXFRS1','PYVLCAAARL0','WDFRCAAARL0','WDFRCAX FRS1','PLVRCAXFRS1')


/*Delete the attributes of the entity*/
delete from ent_attr
where entity_id = ent_id;



/*Delete the alias of the entity*/
delete from entity_alias
where entity_id = ent_id;



/*Delete the entity from entity_relations*/
delete from entity_relations
where entity_id = ent_id;

delete from entity_relations
where rel_ent_id = ent_id;



/*Delete the entity*/
delete from entity
where entity_id = ent_id;



END FOREACH;
/*
'Completed working on Entities of type - circuit, channel' ;
*/

/*
'Started working on Entities of type - network'
*/
FOREACH SELECT e.entity_id
INTO ent_id
FROM entity e
where substr(e.hier_name,1,2) in ('CA')
and e.hier_name not in ('BGRVCAXFRLO','BGRVCAXFRS1','BLYTCABARL0','BLYTCA XF92K','BLYTCAXGRS1','BLYTCAXHRL1','CEVLCAXFRS6',
'HVSUCAXFRS1','PYVLCAAARL0','WDFRCAAARL0','WDFRCAX FRS1','PLVRCAXFRS1')


/*Delete the attributes of the entity*/
delete from ent_attr
where entity_id = ent_id;



/*Delete the alias of the entity*/
delete from entity_alias
where entity_id = ent_id;



/*Delete the entity from entity_relations*/
delete from entity_relations
where entity_id = ent_id;

delete from entity_relations
where rel_ent_id = ent_id;



/*Delete the entity*/
delete from entity
where entity_id = ent_id;



END FOREACH;

/*
'Completed working on Entities of type - network'
*/
END;
END PROCEDURE;


Your help is really appreciated
Thanks in advance
Reply With Quote
Reply

Thread Tools
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

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