|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Issue with Reference in ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
anilmekala |
Posted: Sat Apr 13, 2013 7:06 am Post subject: Issue with Reference in ESQL |
|
|
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 |
|
 |
adubya |
Posted: Sat Apr 13, 2013 7:30 am Post subject: |
|
|
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 |
|
 |
kimbert |
Posted: Mon Apr 15, 2013 1:21 am Post subject: |
|
|
 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 |
|
 |
dogorsy |
Posted: Tue Apr 16, 2013 5:01 am Post subject: Re: Issue with Reference in ESQL |
|
|
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 |
|
 |
dogorsy |
Posted: Tue Apr 16, 2013 6:19 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|