Author |
Message
|
newguy |
Posted: Tue Nov 14, 2006 5:21 am Post subject: CAST ( Root.MQMD.MsgId AS CHARACTER ) |
|
|
 Novice
Joined: 22 Mar 2006 Posts: 13 Location: Bangalore
|
Hi All,
Im facing a problem while casting MsgId to Character and inserting into table..
The problem is while inserting to table in my database node...
it is inserting as below
'X'414d51206d7962726b5f716d312020201a1a58452000205d''
Which is invalid DB2 operation...
any suggestions are appreciated
Thanks in advance...[/code][/quote] |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 14, 2006 5:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
MsgId is NOT a string - it's a 24 byte array. You can't treat it as a string without pain & misery.
Do a search on the forum - you are by no means the first to fall foul of this! _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Nov 14, 2006 5:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I don't see why that would be an invalid DB2 operation, unless your field is too small to hold the data.
Otherwise, your "problem" is that you didn't specify a CCSID on the CAST statement. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
newguy |
Posted: Tue Nov 14, 2006 5:48 am Post subject: |
|
|
 Novice
Joined: 22 Mar 2006 Posts: 13 Location: Bangalore
|
db2 => insert into TBEAM_RLS_POST(REF_NO) values ('n'1232'')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "1232" was found following "(REF_NO) values
('n'". Expected tokens may include: ",". SQLSTATE=42601
this is something similar to db2 error which I have posted previously... |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Nov 14, 2006 5:51 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That's a quoting problem.
What you are getting back, the form X'aaaaa', is the proper string representation of a BLOB field.
If you want 48 characters, you can do simple string manipulation to extract the data from the proper string representation.
If you want 24 bytes, you can pass a CCSID to the CAST. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
newguy |
Posted: Tue Nov 14, 2006 6:05 am Post subject: |
|
|
 Novice
Joined: 22 Mar 2006 Posts: 13 Location: Bangalore
|
Yes that I can do it with substring or something else and insert into a table...
But Is there any way I can have the whole string like
X'aaa' entry in the MSGID Column in a table. |
|
Back to top |
|
 |
newguy |
Posted: Tue Nov 14, 2006 6:32 am Post subject: |
|
|
 Novice
Joined: 22 Mar 2006 Posts: 13 Location: Bangalore
|
Iam so sorry people... I had a problem with my table schema...
Sorry once again... |
|
Back to top |
|
 |
|