ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9: Mapping Node, Oracle Sequence

Post new topic  Reply to topic
 IIB9: Mapping Node, Oracle Sequence « View previous topic :: View next topic » 
Author Message
akil
PostPosted: Mon Apr 06, 2015 6:02 am    Post subject: IIB9: Mapping Node, Oracle Sequence Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

When using a mapping node to insert data to table that needs an identity column, the current method that we follow is

# have a compute node before the mapping node, that gets the sequence value
# store the sequence in an LE variable
# use that in the mapping node.

This works for a single row insert at a time.

In case the model is an array, and the mapping node needs to insert multiple rows (for-each), this breaks,

Is there a way to fetch sequence.curval from dual in the mapping node?
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
martinb
PostPosted: Thu Apr 09, 2015 2:06 am    Post subject: Re: IIB9: Mapping Node, Oracle Sequence Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

akil wrote:

...
In case the model is an array, and the mapping node needs to insert multiple rows (for-each), this breaks,


In what way does it "break"?


akil wrote:

Is there a way to fetch sequence.curval from dual in the mapping node?


Unclear what you want here?


Meanwhile consider these points


    In the For Each transform, you can use the $VarName-index variable to provide the index of the input array that the Graphical Data Mapping editor is processing. Perhaps this could be added to the sequence value?.

    The Join transform can be used to process two or more arrays. You can provide a simple Join expression to select matching index entries from each array to be passed into the nested mapping. Perhaps this could be used to join a insert data values array with a sequence values array?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Apr 09, 2015 3:18 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

IMHO, you would be better off doing the insert via a stored procedure.

That way you can be sure of getting the right sequence number for the insert. also if this is done inside a DB transaction, you can guarantee that no other insert will try to use the same sequence number value as you are.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
akil
PostPosted: Thu Apr 09, 2015 9:33 am    Post subject: Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

When the database table needs an identity column , we use a sequence In oracle ( as it does not have an auto increment option ).

So an insert flow, is something like the following

....compute ( fetch from sequence , store in LE ) --- ( mapping node, inserts into table, using the value from the LE .

When the mapping mode has to run a for each, then

.... compute ( fetch from sequence x times , store array in LE ) --- ( mapping node, inserts ,....)

When the mapping node has to run multiple for each...it just keeps getting messy ..that's what I meant by break.

It would have been so much more easier, if I could select the sequence from within the mapping node, avoiding the Compute / LE..is that doable?

Using a local index does not guarantee uniqueness across multiple instances.

Oracle Procedures can't be called from a mapping node

Sequences aren't subject to the database transaction, so that is not a concern, it's the clumsiness of fetching the values in a compute.
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
aleksk
PostPosted: Tue Nov 10, 2015 2:55 am    Post subject: Reply with quote

Newbie

Joined: 02 Jul 2014
Posts: 4

If you don't need the ID for anything else besides insert, you can use BI trigger on the table and fetch the next value of the sequence in it. For example:
Code:
TRIGGER name BEFORE INSERT
ON table
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
  IF :NEW.ID IS NULL THEN SELECT seq_name.NEXTVAL INTO :NEW.ID FROM DUAL; END IF;
END;
Back to top
View user's profile Send private message
maurito
PostPosted: Tue Nov 10, 2015 6:30 am    Post subject: Reply with quote

Partisan

Joined: 17 Apr 2014
Posts: 358

akil wrote:
When the database table needs an identity column .


use a trigger.

Code:

create or replace trigger FOO_trg
before insert on FOO
for each row
begin
  select FOO_seq.nextval into :new.x from dual;
end;
/
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9: Mapping Node, Oracle Sequence
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.