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 » Issue with Reference in ESQL

Post new topic  Reply to topic
 Issue with Reference in ESQL « View previous topic :: View next topic » 
Author Message
anilmekala
PostPosted: Sat Apr 13, 2013 7:06 am    Post subject: Issue with Reference in ESQL Reply with quote

Acolyte

Joined: 19 Oct 2012
Posts: 63

Hi,

I am facing issue with create Filed in ESQL. Please find my sample input xml and esql code.

INPUT XML :
<Emp>
<Fname>Kishore</Fname>
<Lname>Kumar</Lname>
</Emp>


ESQL Code :

CALL CopyMessageHeaders();
IF OutputRoot.XMLNSC IS NULL THEN
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC';
END IF;

CREATE FIELD OutputRoot.XMLNSC NAME 'Employee';
DECLARE refToOut REFERENCE TO OutputRoot.XMLNSC.Employee;
DECLARE refToIn REFERENCE TO InputRoot.XMLNSC.Emp;
CREATE LASTCHILD OF OutputRoot.XMLNSC.Employee NAME 'Empname' VALUE refToIn.Fname||' '||refToIn.Lname;

I am getting below exception :

Number:INTEGER:5031

Text:CHARACTER:No root element was found while writing the XML message.

help me on to resolve the issue.

Thanks in advance.

Regards,

Anil.
Back to top
View user's profile Send private message
adubya
PostPosted: Sat Apr 13, 2013 7:30 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Code:
CREATE FIELD OutputRoot.XMLNSC NAME 'Employee';
DECLARE refToOut REFERENCE TO OutputRoot.XMLNSC.Employee;   
DECLARE refToIn REFERENCE TO InputRoot.XMLNSC.Emp;   
CREATE LASTCHILD OF OutputRoot.XMLNSC.Employee NAME 'Empname' VALUE refToIn.Fname||' '||refToIn.Lname; 


Try the following instead

Code:
DECLARE refToOut   REFERENCE TO OutputRoot;
CREATE LASTCHILD OF OutputRoot.XMLNSC AS refToOut NAME 'Employee';
DECLARE refToIn REFERENCE TO InputRoot.XMLNSC.Emp;   
CREATE LASTCHILD OF refToOut  NAME 'Empname' VALUE refToIn.Fname||' '||refToIn.Lname; 
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Apr 15, 2013 1:21 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I am getting below exception :

Number:INTEGER:5031

Text:CHARACTER:No root element was found while writing the XML message.
Please quote the entire error message ( that is only the first line of the error ). It will contain a *lot* of information about the problem, and it may even contain some suggestions about how to solve the problem.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Tue Apr 16, 2013 5:01 am    Post subject: Re: Issue with Reference in ESQL Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

anilmekala wrote:
Hi,

I am facing issue with create Filed in ESQL. Please find my sample input xml and esql code.

INPUT XML :
<Emp>
<Fname>Kishore</Fname>
<Lname>Kumar</Lname>
</Emp>


ESQL Code :

CALL CopyMessageHeaders();
IF OutputRoot.XMLNSC IS NULL THEN
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC';
END IF;

CREATE FIELD OutputRoot.XMLNSC NAME 'Employee';
DECLARE refToOut REFERENCE TO OutputRoot.XMLNSC.Employee;
DECLARE refToIn REFERENCE TO InputRoot.XMLNSC.Emp;
CREATE LASTCHILD OF OutputRoot.XMLNSC.Employee NAME 'Empname' VALUE refToIn.Fname||' '||refToIn.Lname;

I am getting below exception :

Number:INTEGER:5031

Text:CHARACTER:No root element was found while writing the XML message.

help me on to resolve the issue.

Thanks in advance.

Regards,

Anil.


you don't need all that esql, just do

DECLARE refToIn REFERENCE TO InputRoot.XMLNSC.Emp;
SET OutputRoot.XMLNSC.Employee.Empname = refToIn.Fname||' '||refToIn.Lname;
Back to top
View user's profile Send private message
dogorsy
PostPosted: Tue Apr 16, 2013 6:19 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

of course, if any of the two input fields is NULL, then the concatenation will be null, and you will be assigning null to the output root, and the error will still be issued.
in that case, you can

SET OutputRoot.XMLNSC.Employee.Empname = TRIM(COALESCE(refToIn.Fname,'')||' '||COALESCE(refToIn.Lname,''));

the trim is to remove the space (' ') added when concatenating in the case where one of the two fields is null.
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 » Issue with Reference in ESQL
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.