Author |
Message
|
paustin_ours |
Posted: Wed May 07, 2014 11:19 am Post subject: space field results in empty value |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
I have an incoming message that i parse using MRM parser. Some of the fixed length fields are just spaces.
when i parse this incoming data the result field that i store in environment is empty. is there a way i can make the result to store at least one space, somthing like '' if the incoming message field is all spaces?
i looked at default setting and also null setting but those seem to be for when i write a message out. Is there something that i can do for incoming message.
only other option is to put a coalesce in each and every field that might have spaces. ANy suggestions? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 07, 2014 11:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You did not specify the version... but I seem to remember that with MRM, depending on my null settings I could have a field with only spaces show up as null. However you may need to make sure the field is nillable first.
I know that for my cobol copybook imports I used to set all fields to nillable...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed May 07, 2014 11:29 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
version 8.0.0.3
Incoming data is not null its something like
FIELD1 FIELD3
FIELD2 is 10 spaces. When i parse this the environment tree
has
Env.Field2=
which is empty
I rather want
Env.Field2=''
I tried the null setting, didnt help..maybe i missed something i will try again |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed May 07, 2014 11:33 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
spaces for trimmed i guess |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 08, 2014 2:53 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Incoming data is not null its something like
FIELD1 FIELD3
FIELD2 is 10 spaces. |
I don't think you got the point there.
You can tell the MRM parser ( or the DFDL parser ) to parse a field that contains only spaces as a NULL. It's a common requirement. Then, in your ESQL you can treat the field specially by using 'IS NULL'.
May not be any more convenient than using COALESCE - depends on whether you can just store the NULL value in the Environment. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
paustin_ours |
Posted: Thu May 08, 2014 4:23 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
I tested this and you are right thats how it is working. It would be nice to have an option to parse the spaces as some other character other than null (in my reuqirement a single space). This way I dont have to do it in my esql. This sounds like a fair requirement, in case you want to insert into a table column that is not null (this is my case as well) I dont have to write extra checks if the message set does it for me. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 08, 2014 4:38 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
paustin_ours wrote: |
I tested this and you are right thats how it is working. It would be nice to have an option to parse the spaces as some other character other than null (in my reuqirement a single space). This way I dont have to do it in my esql. This sounds like a fair requirement, in case you want to insert into a table column that is not null (this is my case as well) I dont have to write extra checks if the message set does it for me. |
Well if you do not tell the parser to treat fields with only spaces as null you would get the number of spaces in the field (check it). Don't know if that would satisfy your DB requirement though...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
paustin_ours |
Posted: Thu May 08, 2014 4:43 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Quote: |
Well if you do not tell the parser to treat fields with only spaces as null you would get the number of spaces in the field (check it). Don't know if that would satisfy your DB requirement |
no thats not how i see it work. If i dont tell the parser to treat spaces as null. The field is empty.
I parse it onto environment and in a subsequent JCN where i do an insert to db, i get cannot insert null because the column is not nullable. |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 08, 2014 4:50 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
paustin_ours said:
Quote: |
It would be nice to have an option to parse the spaces as some other character other than null (in my reuqirement a single space). This way I dont have to do it in my esql. This sounds like a fair requirement |
It would be nice for you, because it would save you writing some code. The problem is, where do we stop? What if somebody else wants it parsed as a nul character instead of a space? Or they want to interpret zeros (not spaces), in this way?
The bottom line is that you are asking for transformation logic to be put into the parser. The nil handling logic is a very simple form of transformation logic. The only reason that it is included in the parser is that nils are a very common way to handle 'out of band' data ( data that does not conform to the field type ). Without the nil handling, it would not be possible to handle a text integer field that was filled with nul characters. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
paustin_ours |
Posted: Thu May 08, 2014 4:53 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Quote: |
The bottom line is that you are asking for transformation logic to be put into the parser |
point taken. Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 08, 2014 4:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
paustin_ours wrote: |
Quote: |
Well if you do not tell the parser to treat fields with only spaces as null you would get the number of spaces in the field (check it). Don't know if that would satisfy your DB requirement |
no thats not how i see it work. If i don't tell the parser to treat spaces as null. The field is empty.
I parse it onto environment and in a subsequent JCN where i do an insert to db, i get cannot insert null because the column is not nullable. |
Define the field is empty: Fieldvalue(ref) is NULL ? or Fieldvalue(ref) = '' ?
Are you using a trim function anywhere? What is the result of mystring.trim() ?
Is your field defined as nillable to the parser? How does your db treat an empty string? String.isEmpty() is true... Does it consider it to be equivalent to a null value? Java does treat them differently...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
paustin_ours |
Posted: Thu May 08, 2014 5:01 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
when i parse it onto Environment. this is how it shows up on a debugger.
Environment.Field2=
and not
Environment.Field2='' or Environment.Field2=null [this is my original set up before making nillable in message set]
then in the jcn when i do xpath...getvalueasstring, it returns null and db throws errors. |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu May 08, 2014 5:16 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
paustin_ours wrote: |
when i parse it onto Environment. this is how it shows up on a debugger.
|
do not believe everything the debugger tells you
What does a user trace + trace node tell you? _________________ 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 |
|
 |
fjb_saper |
Posted: Thu May 08, 2014 5:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
paustin_ours wrote: |
when i parse it onto Environment. this is how it shows up on a debugger.
Environment.Field2=
and not
Environment.Field2='' or Environment.Field2=null [this is my original set up before making nillable in message set]
then in the jcn when i do xpath...getvalueasstring, it returns null and db throws errors. |
This is not a scientific answer. You need to specifically evaluate
Code: |
IF FIELDVALUE(Environment.Field2) ISNULL THEN |
This is to determine whether the field is parsed as null.
As I said also verify in your model whether the field is marked as nillable.
You might want to explicitely set the field as non nillable.
The other thing you are doing is parsing to the environment. Did you define a domain for your parsing? Did you define a parser to the environment? You might be suffering from some side effect of the environment not having a parser attached to it...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|