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 » Using Counter Variable in Insert Statement

Post new topic  Reply to topic
 Using Counter Variable in Insert Statement « View previous topic :: View next topic » 
Author Message
pdmenon
PostPosted: Wed Feb 09, 2011 12:19 am    Post subject: Using Counter Variable in Insert Statement Reply with quote

Voyager

Joined: 05 Apr 2010
Posts: 80

Dear Experts,

Can we use Counter Variables in Insert Statement like -->

Code:
SET COUNTER =1;
WHILE (COUNTER <= FOR_COUNTER) DO

INSERT INTO Database.TBL_TableName(
Column1,
Column2)
Values (
Environment.EXTRACT.RECORD[COUNTER].Column1,
Environment.EXTRACT.RECORD[COUNTER].Column2,
)

END WHILE;


When using above code i am getting Syntax error stating -->

Severity and Description Syntax error. Valid options include: (
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Feb 09, 2011 12:24 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.

Where are you incrementing COUNTER?
_________________
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
pdmenon
PostPosted: Wed Feb 09, 2011 12:31 am    Post subject: Reply with quote

Voyager

Joined: 05 Apr 2010
Posts: 80

My bad.. The code should be:

Code:

SET COUNTER =1;
WHILE (COUNTER <= FOR_COUNTER) DO

INSERT INTO Database.TBL_TableName(
Column1,
Column2)
Values (
Environment.EXTRACT.RECORD[COUNTER].Column1,
Environment.EXTRACT.RECORD[COUNTER].Column2,
)

SET COUNTER = COUNTER + 1;

END WHILE;

Back to top
View user's profile Send private message
mgk
PostPosted: Wed Feb 09, 2011 1:33 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Quote:
Can we use Counter Variables in Insert Statement like


Yes you can use Counters in Insert statements, but only if the syntax for the Insert Statement is correct.

There were two errors in the code you posted. The correct code should be:

Code:
INSERT INTO Database.TBL_TableName(
Column1,
Column2)
Values (
Environment.EXTRACT.RECORD[COUNTER].Column1,
Environment.EXTRACT.RECORD[COUNTER].Column2
);


Can you spot the two differences?

Kind regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
pdmenon
PostPosted: Wed Feb 09, 2011 1:37 am    Post subject: Reply with quote

Voyager

Joined: 05 Apr 2010
Posts: 80

Dear mgk,

It was my typo. I have ' ;' at the end of insert statement and no extra comma after the column end.
Back to top
View user's profile Send private message
fatherjack
PostPosted: Wed Feb 09, 2011 1:58 am    Post subject: Reply with quote

Knight

Joined: 14 Apr 2010
Posts: 522
Location: Craggy Island

pdmenon wrote:
Dear mgk,

It was my typo. I have ' ;' at the end of insert statement and no extra comma after the column end.


Of course. We should've guessed that. Now how many guesses at the real syntax error in your code do you think we should have?
_________________
Never let the facts get in the way of a good theory.
Back to top
View user's profile Send private message
j.f.sorge
PostPosted: Wed Feb 09, 2011 9:51 am    Post subject: Reply with quote

Master

Joined: 27 Feb 2008
Posts: 218

Anyways it will be better to make use of a REFERENCE variable and MOVE NEXTSIBLING until LASTMOVE is FALSE.
_________________
IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
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 » Using Counter Variable in Insert Statement
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.