I have a big problem. I need to insert data into a DB2 database (details below) from a java client (via JDBC). The problem is that I don't know the type of the columns so the insertion is: INSERT into TABLE1 (col1,col2) values ('value1','value2'), where value1 and value2 may be an integer or a String.
I try to better explain, my client receives 5 values and it doesn't know the structure of the db, it knows that the first values is the table name, the second and the third are the name of columns and the fourth and fifth are the values, but it doesn't know the type (INT,CHAR,....). This client uses four different db, SQL server, mysql, Informix and DB2. For all the others db I add the quotes for each value (like in the insert above) and the insertion ends with success, instead DB2 returns an error, it doesn't succeed to make the insertion.
How can I force the insertion? Is there a configuration value to set to allow the insertion to succeed?
For the test I created a test table (TestTable (id INTEGER, name VARCHAR)) and I want to make this insertion: INSERT into TestTable (id,name) values ('1','Tom').
You cannot do it the way you want. Instead you will have to to it the correct way. You are given the the table name and column names. Use this information to query the DB as to the type of data. Then set the data based on this information.
Thank Andy, but I can't do that, I don't have this kind of control. It's hard to explain, but what's happen is that I execute the client only the first time, then it creates a sequential "workflow" (is not a real workflow, it's a list of operation without condition) that will be executed from a web service. In this "workflow" I can't insert an "If..Then..Else" condition, I mean, I can query the DB and get the type, but I can't create a different query based on response. What I need is something that allows me to submit the query anyway,but, if I well understand, it's impossible.