ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » space to NULL

Post new topic  Reply to topic
 space to NULL « View previous topic :: View next topic » 
Author Message
gmabrito
PostPosted: Wed Jun 18, 2003 12:40 pm    Post subject: space to NULL Reply with quote

Apprentice

Joined: 19 Mar 2002
Posts: 35

I am having some probems with a string field that contains spaces. When I try to insert this field into a not null field in a database I get errors complaining that the field is null, when in reality it is spaces. How do I prevent this? Thanks.

WMQI 2.1 CSD04 Oracle 8i
Incoming MRM message to database insert via compute node.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 18, 2003 1:07 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Is your MRM element definition set up to treat spaces as logical nulls?

If so, the value your Root.MRM.Field will hold will be NULL, and not spaces.
Back to top
View user's profile Send private message
gmabrito
PostPosted: Wed Jun 18, 2003 1:21 pm    Post subject: Reply with quote

Apprentice

Joined: 19 Mar 2002
Posts: 35

The element definition is:

Physical Type: Fixed Length String
Lenght Count : 8
Length Units : Bytes
Byte Alignment : 1 Byte
String Justification: Left Justify
Padding Character: SPACE
Skip Count: 0
Encoding Null: NULLPadFill
Back to top
View user's profile Send private message
shalabh1976
PostPosted: Wed Jun 18, 2003 1:40 pm    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

I think for a database insert the syntax would look like :
Insert into Database.<Schema>.<Table>(col1,col2,col3) values( 'a',,'c');

Now since there are spaces for the second column the database treats it as a null.
If you want to put spaces you need to write :
Insert into Database.<Schema>.<Table>(col1,col2,col3) values( 'a',' ','c');

Now as your input is coming as spaces you need the quotes,
so as that cannot be done on the database statement you need to check for the existence of a space and then change it somehow.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
gmabrito
PostPosted: Wed Jun 18, 2003 2:12 pm    Post subject: Reply with quote

Apprentice

Joined: 19 Mar 2002
Posts: 35

I am going to use COALESCE(source_value1, source_value2...)
Back to top
View user's profile Send private message
gmabrito
PostPosted: Thu Jun 19, 2003 5:31 am    Post subject: Reply with quote

Apprentice

Joined: 19 Mar 2002
Posts: 35

COALESCE and IS NULL is not working because in the message it is a spaces, but when it gets to the insert removes the spaces.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 19, 2003 8:33 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If a trace output for the field shows that it does contain spaces and not a NULL value, then I think it may be an issue with your database setup. But I don't use Oracle, so I can't say what. Try looking at the ODBC configuration.

One thing to try is switching your insert statement from a standard ESQL insert to using PASSTHRU. I've run into odd conversion issues like this with SQLServer that were fixed by using PASSTHRU instead.
Back to top
View user's profile Send private message
gmabrito
PostPosted: Thu Jun 19, 2003 8:53 am    Post subject: Reply with quote

Apprentice

Joined: 19 Mar 2002
Posts: 35

the trace shows an empty string. I am getting around it by

IF (elementname = '' or elementname IS NULL) THEN
elementname = ' ';
END IF;


This seems to be working fine.
Back to top
View user's profile Send private message
Craig B
PostPosted: Thu Jun 19, 2003 9:25 am    Post subject: Reply with quote

Partisan

Joined: 18 Jun 2003
Posts: 316
Location: UK

If your MRM-CWF bitstream contains spaces for that particular field then the definitions you have specified will lead to the CWF parser populating the field with the zero length string (''). This is because the Padding character is SPACE and when the CWF parser populates the logical value it will trim the padding character according to justification. In this case, all spaces will be trimmed leaving the value of zero length string which is not NULL as you have found.

As far as I am aware, Oracle should accept a zero length string and be able to distinguish this from the different value of NULL. However, I believe this is dependent on the column type of the column you are inserting to. Although you have worked around your problem, just out of curiosity, what column type were you inserting to, and what was the error that you got from your INSERT call?
_________________
Regards
Craig
Back to top
View user's profile Send private message
drajib
PostPosted: Fri Jun 20, 2003 12:13 am    Post subject: Reply with quote

Apprentice

Joined: 25 Mar 2003
Posts: 42
Location: India

Yes, Oracle definitely distinguishes between '' (a zero length string) & null. In this scenario, I believe that the onus is on the ODBC driver for converting '' to null.

Best regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » space to NULL
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.