Author |
Message
|
ruchir123 |
Posted: Thu Feb 02, 2012 9:32 pm Post subject: Difference between CAST and ASBITSTREAM |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
Hi All,
I have a small doubt about working with CAST and ASBITSTREAM function
1. CAST(Variable as BLOB CCSID InputProperties.CodedCharSetId);
2. ASBITSTREAM(Variable CCSID InputProperties.CodedCharSetId);
Please tell if there is any basic difference between functionality of these two statements.
Thanks a ton in advance. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Feb 03, 2012 2:20 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please read the documentation of both functions in the info center. If you cannot understand the difference after that, then please tell us exactly what you are confused about. |
|
Back to top |
|
 |
ruchir123 |
Posted: Sun Feb 05, 2012 3:16 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
Hi Kimbert,
Thanks for your response.
My confusion is both the statements will return BLOB for Variable. In that case is there any difference in both the BLOB.
Please tell. |
|
Back to top |
|
 |
Esa |
Posted: Sun Feb 05, 2012 7:45 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
ruchir123 wrote: |
My confusion is both the statements will return BLOB for Variable. In that case is there any difference in both the BLOB.
|
Yes, they both return a BLOB. But take a closer look at the input variables and you may see the light... |
|
Back to top |
|
 |
ruchir123 |
Posted: Sun Feb 05, 2012 9:44 pm Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
Hi Esa,
Thanks for reply.
I think you are talking about, Asbitstream function only take FieldReference as input. But what i tried is i stored some string in an environment variable and then i gave as input for both the functions stated above.
If i am right then will there be any difference in the output for both the functions. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Feb 06, 2012 1:28 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
both the statements will return BLOB for Variable. In that case is there any difference |
Yes, there is a difference. The two functions do different things. Read the info center to find out what each function does. |
|
Back to top |
|
 |
ruchir123 |
Posted: Mon Feb 06, 2012 1:48 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
Hi kimbert,
Thanks. I read the info center and what i could find out is
ASBITSTREAM returns a value of type BLOB that contains a bitstream representation of the field that is pointed to by FieldReference and its children BUT CAST transforms one from one data type into another.
i couldn't find the proper difference. Please  |
|
Back to top |
|
 |
adubya |
Posted: Mon Feb 06, 2012 2:13 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Quote: |
pointed to by FieldReference and its children |
We're getting there  |
|
Back to top |
|
 |
ruchir123 |
Posted: Mon Feb 06, 2012 2:25 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
adubya thanks for reply. So in that case if i give Input as
Code: |
SET Environment.test = '12345678'; |
and i give this Environment.test as input to both the functions then there will be no differnce.
Please tell. |
|
Back to top |
|
 |
adubya |
Posted: Mon Feb 06, 2012 2:27 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Why don't you try it ? Experimentation is a great way to learn (that and reading the manual ) |
|
Back to top |
|
 |
ruchir123 |
Posted: Mon Feb 06, 2012 2:34 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
Actually i tried , there is some differnce , but i couldn't find the real difference.
What i tried is i set my Environment.test = '000000000000000000000000'(24 zeros)
Then i used it as an input for both the functions.
Output for both the functions i provide as correlation id for MQMD.
For CAST function it accpeted but for ASBITSTREAM function it gave error saying not of required/proper length.
So i got confused where is the diff. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Feb 06, 2012 2:42 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
ruchir123 wrote: |
So i got confused where is the diff. |
It's very simple.
CAST works on values.
ASBITSTREAM works on trees.
That is to say, these are two separate functions because they do two separate things.
If they did THE SAME thing they would be THE SAME function. |
|
Back to top |
|
 |
ruchir123 |
Posted: Mon Feb 06, 2012 3:28 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
mqjeff thanks for your reply. i aggreed to your view. So in that case i shouldn't be getting error in the above scenario.
But i got. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Feb 06, 2012 3:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
ruchir123 wrote: |
mqjeff thanks for your reply. i aggreed to your view. So in that case i shouldn't be getting error in the above scenario.
But i got. |
I'm confused. How is Environment.test a message tree?
It's a single node with a single value.
It also doesn't have a parser associated with it.
It's also already a bitstream. |
|
Back to top |
|
 |
ruchir123 |
Posted: Mon Feb 06, 2012 4:13 am Post subject: |
|
|
Acolyte
Joined: 04 Jan 2012 Posts: 58
|
yes it is not a message tree but a single value.
But we can provide such input to ASBITSTREAM function, right.
And it is not giving any error while converting it to BLOB which means it is converting it to BLOB.
So here the issue is if both are BLOB at the end, then whats the difference in both BLOBs. |
|
Back to top |
|
 |
|