Author |
Message
|
mbsa |
Posted: Mon Mar 04, 2013 11:50 am Post subject: asbitstream casting |
|
|
Apprentice
Joined: 04 Mar 2013 Posts: 41
|
Trying to insert the cobol message in DB column.Used the asbitstream function,But getiing the below error.How do i cast?
Code: |
DECLARE Msg BLOB;
SET Msg = ASBITSTREAM(InputRoot.DFDL.IMSTRANRECORD CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
Declare Msg_Char CHAR;
SET Msg_Char = CAST(Msg AS CHAR CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
------------
BIP2521E: ('gen.operation1_Request_Response_Compute2.Main', '18.24') : Error casting the value ''X'11fc0000474b5230373620202020202020202020202020202020202020202020202020202020220202020202020202020202020202020''' to ''CHARACTER''.
An error occurred when casting a value to a different data type. This may be because no conversions exist between the two data types or because the particular value was unsuitable.
|
Last edited by mbsa on Mon Mar 04, 2013 12:34 pm; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Mar 04, 2013 12:03 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Remove the CCSID and Encoding from the second CAST. |
|
Back to top |
|
 |
mbsa |
Posted: Mon Mar 04, 2013 12:42 pm Post subject: |
|
|
Apprentice
Joined: 04 Mar 2013 Posts: 41
|
Updated the second cast,but still same error.
Code: |
SET Msg = ASBITSTREAM(InputRoot.DFDL.IMSTRANRECORD CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
Declare Msg_Char CHAR;
SET Msg_Char = CAST(Msg AS CHAR);
SET OutputRoot.XMLNSC.DBMESSAGE.MessageIn = Msg_Char; |
BIP2521E: ('gen.operation1_Request_Response_Compute2.Main', '18.24') : Error casting the value
An error occurred when casting a value to a different data type. This may be because no conversions exist between the two data types or because the particular value was unsuitable.[/code] |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 04, 2013 1:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Did you deploy that change?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mbsa |
Posted: Mon Mar 04, 2013 1:10 pm Post subject: |
|
|
Apprentice
Joined: 04 Mar 2013 Posts: 41
|
I did remove the encoding ccsid before only but posted wrongly.The error is without ccsid and encoding in the second cast. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Mar 05, 2013 2:18 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You are casting from BLOB to CHARACTER so the CCSID and encoding are required. Please can you provide details of the actual values of CCSID and encoding - perhaps from a user trace or a Trace node. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 05, 2013 2:42 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Don't use a CAST in the second statement, just straight assignment to get the hex values?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Wed Mar 06, 2013 1:13 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
fjb_saper said:
Quote: |
Don't use a CAST in the second statement, just straight assignment to get the hex values? |
It's a fair point. The OP has not said what the type of the database column is. I have been assuming that it's a CHAR or a VARCHAR because that's what the ESQL led me to believe. |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Mar 06, 2013 2:10 am Post subject: Re: asbitstream casting |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
mbsa wrote: |
Code: |
DECLARE Msg BLOB;
SET Msg = ASBITSTREAM(InputRoot.DFDL.IMSTRANRECORD CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding); |
|
If the message contains a mix of character and non-character data, then a simple CAST won't reconstruct the original data. For example:
mbsa wrote: |
Code: |
BIP2521E: ('gen.operation1_Request_Response_Compute2.Main', '18.24') : Error casting the value "X'11fc0000...'" |
|
that doesn't look like character data.
mbsa wrote: |
The error is without ccsid and encoding in the second cast. |
Check again. CAST(blob AS CHARACTER) should not generate a conversion error, without either a CCSID or Encoding clause. |
|
Back to top |
|
 |
mbsa |
Posted: Thu Mar 07, 2013 6:27 am Post subject: |
|
|
Apprentice
Joined: 04 Mar 2013 Posts: 41
|
Thanks for the reply.
The code is working.
The IMS copybook had binary header which we need to remove and then use the ccsid and encoding while casting to char.Thanks all. |
|
Back to top |
|
 |
FelipeSchmidt |
Posted: Sun Sep 15, 2013 5:09 am Post subject: Re: asbitstream casting |
|
|
Newbie
Joined: 13 Sep 2013 Posts: 1
|
mbsa wrote: |
Trying to insert the cobol message in DB column.Used the asbitstream function,But getiing the below error.How do i cast?
[/code]DECLARE Msg BLOB;
SET Msg = ASBITSTREAM(InputRoot.DFDL.IMSTRANRECORD CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
Declare Msg_Char CHAR;
SET Msg_Char = CAST(Msg AS CHAR CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
------------
BIP2521E: ('gen.operation1_Request_Response_Compute2.Main', '18.24') : Error casting the value ''X'11fc0000474b5230373620202020202020202020202020202020202020202020202020202020220202020202020202020202020202020''' to ''CHARACTER''.
An led lighting occurred when casting a value to a different data type. This may be because no conversions exist between the two data types or because the particular value was unsuitable.
[/code] |
Hello friend I am getting similar code error so where you able to sort it out? Please help me if you can
Last edited by FelipeSchmidt on Mon Sep 16, 2013 7:19 am; edited 1 time in total |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Sep 15, 2013 7:12 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
did you remove the binary header as the previous answer implied? _________________ 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 |
|
 |
|