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 » ESQL INSERT statments fails to insert a string into INFORMIX

Post new topic  Reply to topic
 ESQL INSERT statments fails to insert a string into INFORMIX « View previous topic :: View next topic » 
Author Message
Angshuman
PostPosted: Thu May 16, 2013 10:27 pm    Post subject: ESQL INSERT statments fails to insert a string into INFORMIX Reply with quote

Apprentice

Joined: 30 Apr 2009
Posts: 29

Hi,

We are writing ESQL statment to insert data into a table (INFORMIX DB).
It is failing to insert a string to a column which is of type CHAR (2). I understand CHAR type should truncate the field and insert first 2 characters into the table.
Writing the SQL statment in PASSTHRU works fine, but not when you write
ESQL statment.
In both cases, we are using odbc connection to connect to the INFORMIX DB.

Can someone please help here.

Thanks,
Angshuman
Back to top
View user's profile Send private message
Esa
PostPosted: Thu May 16, 2013 11:17 pm    Post subject: Re: ESQL INSERT statments fails to insert a string into INFO Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Angshuman wrote:

It is failing to insert a string to a column which is of type CHAR (2). I understand CHAR type should truncate the field and insert first 2 characters into the table.


I understand the type doesn't do any truncating for you, it's your ESQL code that will have to make sure that the data does not exeed the required length.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Thu May 16, 2013 11:28 pm    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

if you don't post the esql statement and the error , it is only guesswork. The comment above is correct, and the error message you get probably tells you that there is an overflow
Back to top
View user's profile Send private message
Angshuman
PostPosted: Fri May 17, 2013 12:53 am    Post subject: Reply with quote

Apprentice

Joined: 30 Apr 2009
Posts: 29

It is an overflow error for the same field. It is a CHAR type and not VARCHAR type.
Like I have mentioned, PASSTHRU function works well with the same data.
Even I run the SQL statement in Database directly, the value gets truncated. But why not when using ESQL statement
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri May 17, 2013 1:12 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

so it is an overflow error.
you say that passthru works, meaning what ? probably that it executes and the data gets truncated. Is that what you want ? if so, in your compute esql you can truncate the data yourself, using RIGHT or LEFT function, depending on what you want. if the problem with your data is that is padded with spaces, use TRIM.
But if your database column is defined as CHAR(2) you MUST send 2 characters.
Back to top
View user's profile Send private message
Angshuman
PostPosted: Fri May 17, 2013 1:55 am    Post subject: Reply with quote

Apprentice

Joined: 30 Apr 2009
Posts: 29

I can truncate the data in ESQL, just trying to understand the reason behind it. Moreover truncation should be done by the table, as it is CHAR datatype and not needed by the code. Why does it behave otherwise in ESQL. SQL works fine with the same data.
PASSTHRU statment does not compile the prepared statement, which gets executed in the Database, which is not the case with ESQL. But I am using odbc connection in both the cases.
[/quote]
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri May 17, 2013 2:22 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Angshuman wrote:
I can truncate the data in ESQL, just trying to understand the reason behind it. Moreover truncation should be done by the table, as it is CHAR datatype and not needed by the code. Why does it behave otherwise in ESQL. SQL works fine with the same data.
PASSTHRU statment does not compile the prepared statement, which gets executed in the Database, which is not the case with ESQL. But I am using odbc connection in both the cases.
[/quote]

No, truncation means data loss. Maybe that is good for you, but unacceptable for most people. If you pay '1001' euros into your bank account, would you like to be credited with '10' or '01' ? , Let me know and I will keep the rest
Back to top
View user's profile Send private message
Angshuman
PostPosted: Fri May 17, 2013 4:43 am    Post subject: Reply with quote

Apprentice

Joined: 30 Apr 2009
Posts: 29

Data is not sensitive. We can live with truncated data.
This is for app logging. insert should not fail at any cost
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri May 17, 2013 4:49 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Angshuman wrote:
Data is not sensitive. We can live with truncated data.
This is for app logging. insert should not fail at any cost


if data is not sensitive and insert should not fail at any cost, then insert always the string '00'.
Back to top
View user's profile Send private message
Angshuman
PostPosted: Fri May 17, 2013 5:21 am    Post subject: Reply with quote

Apprentice

Joined: 30 Apr 2009
Posts: 29

Still does not answer my question. It is a workaround what you are saying and this whole thing is going round and round.
Can someone please help here? Why is it failing in ESQL and not in SQL?
Back to top
View user's profile Send private message
dogorsy
PostPosted: Fri May 17, 2013 5:33 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Angshuman wrote:
Still does not answer my question. It is a workaround what you are saying and this whole thing is going round and round.
Can someone please help here? Why is it failing in ESQL and not in SQL?


no, it is not a workaround. If you don't like it, use passthru, otherwise code your ESQL properly or change the database column definition. Also, go and read some documentation about message broker and odbc. The reason why it is failing in ESQL is clear from the error message. If you want to know why it does not fail in SQL, post the question in the Informix forum
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri May 17, 2013 6:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Angshuman wrote:
Still does not answer my question. It is a workaround what you are saying and this whole thing is going round and round.
Can someone please help here? Why is it failing in ESQL and not in SQL?

Because ESQL and SQL are not 100% the same?
Just truncate it in the code and we'll no longer speak about it.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
new2z
PostPosted: Fri May 17, 2013 12:35 pm    Post subject: Reply with quote

Novice

Joined: 16 May 2013
Posts: 15

Even if you did it in other RDBMS using SQL Server or Oracle or DB2, you will still get these type of errors

Database will always throw an error if you try to insert more than it is supposed to get. It is not the responsibility of the database. it is your responsibility not to feed more than it can take.
There is no solution to this unless you define your CHAR field to a CLOB (if Informix supports it) and allow huge amounts of character data in 1 field
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 » ESQL INSERT statments fails to insert a string into INFORMIX
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.