Hi all,
I've been struggling quite a bit inserting numbers into an Oracle table using PP8.0 and the ODBC driver 6.0.
Basically, I'm computing the square root of some data and inserting both the data and its square root in a table.
I'm many occasions - not all - the number inserted is not the actual value's square root, but the value of the previous data record.
For instance, I have the following numbers: 20.2, 9.1, 18.4. Therefore, I should insert 20.2, 4,4944..., 9.1, 3.0166..., 18.4, 4.2895
Once inserted in the table, I read: 20.2, 4.4944..., 9.1, 9.1, 18.4, 18.4. It replicated the values instead of inserting the square root value.
I found that formating the value prior to insert it does work.
my_value := format("%9.5", my_value);
The table contains proper values: 20.2, 4,49444, 9.1, 3.01662, 18.4, 4.28952
I thought this might be of interest to the community.
Pierre

I think you are running into the same bug that I ran into.
(for support) ref:00D7KBYe.5007DBLkP
Take a look at what the PLP thinks the data types are: (replace Conc with your property name)
PLP Script
type_0 := GetPropertyType(Conc, 0 );
type_1 := GetPropertyType(Conc, 1 );
type_2 := GetPropertyType(Conc, 2 );
type_3 := GetPropertyType(Conc, 3 );
It appears that the PLP ODBC component doesn't like it when you switch from String to Double and back to String.
I've gotten "null" values inserted into the database which has thrown off development by a day or two.
The solution I used was to force all the values to be Double prior to inserting into the database.
Your solution seems to be similar but forces it to a String.
Personally, I like to keep my numbers as numbers, my dates as dates, and my strings as strings.
If you want to 'cut off' the values, a hybrid solution would be best.
my_value := double( format("%9.5", my_value) );
Indeed, it does force a string.
Another workaround was to multiply the result of the square root by 1.0 which forces to a number.
Pierre
I've done that "multiply by 1.0" trick in PERL many times. But i'm surprised you had to do that on the SQRT() line instead of the 'original' line.
IMHO - it just looks better (code wise) to see that you are re-casting/force-casting the data to be a specific data type.
-- (also, adding a comment line saying why you had to do this helps you out 5 years later when you/someone else is debugging code)
A 3rd solution would be to modify the SELECT statement instead.
select my_value from my_table
UNION
select sqrt(my_value) from my_table
I'm sure you have your reasons for not doing this....
PS - let me know if I should post up my 'test-bug' protocol.
Not sure I understand your point.
I read data from a SD file, then compute the square root with pipeline pilot to further insert into an Oracle table.
sqr_val := sqrt(my_value);
What select are you talking about?
Surprisingly, inserting the result of the square root (sqr_val) failed, whereas it didn't fail when I reformat sqr_val (as a string) or compute sqr_val as follow:
sqr_val := sqrt(my_value)*1.0; (in pilot script)
SQL statement remains the same. Table column type is set to NUMBER.
My guess is that the ODBC driver is responsible for the failure. Trying JDBC instead returned "is not a number" error which let thought of formating sqr_val to reduce the number of digits.
issue with ODBC/(?JDBC?)
From what I have seen, the ODBC component appears to be written with the following assumtion.
- if the first record is a string, then all other records are also stings.
Since I have ran into this issue with PLP 7.5 using the Oracle 11gR2 drivers, I believe it is an issue with the PLP ODBC Component itself and not the underling ODBC driver.
Hopefully, someone from support can speak up.
(I have not ran a full range of tests to prove it.)
SELECT statement explanation
the idea is: If you put data into the database, you will eventually need to pull it out.
one work-around to the INSERT problem would be to have Oracle do the sqrt() calculation when you pull the data out.
This wouldn't make sense if you are doing searches on the sqrt() value (where that column would need to be indexed) hence the header at the begining of the paragraph.
There are many other ways to get the sqrt() value in. (all of them more complicated then it needs to be.)
IMHO - The correct way is to have SciTegic/Accelrys fix the component.
Hi,
We had a similar problem, with data inserted, but not the one we wanted (lots of duplicates).
The solution was to tick a box on the odbc configuration panel (on the PP server).
Search on my archive mail....
found it, it is for driver 5.3, but there may be something similar with 6.0
Malcolm wrote: If these are the DataDirect drivers we provide (listed as Scitegic Oracle 5.3) do you have the Emable SQL Describe Param set on the Advanced Properties?
It was not, and by ticking this box, it worked. It was our magic move (it solved a connection issue as well on another db).
this solution may not be relevant at all to this problem, but just in case.
Cheers,
Jérémy
Pierre,
Looking at your diagram it is not easy to discern what is going on inside of your Custom manipulators. I have attached a basic example which I think is doing what you are, and this works fine for me. I'm wondering if you can run this example and tell me if you still see this issue. If not, then we can look at your specific example and try to see what is going on.
Both Michael and Jeremy have brought up some good points. If you are doing what Michaels suggests and have different data types for different records this could cause an issue. I haven't seen his exact issue before so I am not sure how it would fail. As for Jeremy's point, the SQLDescribe param is responsible for Type Casting data coming in from an external source (Pipeline Pilot) into an Oracle database. So in some cases when you are having data type problems this is the culprit.
In either case, I still can't reproduce the problem at hand, so I think trying to run this example may be the best way to go. Then we can take it from there to see if this is a bug, or something that can be corrected in your protocol. All you need to do is specify a Data Source. A test table will be created and then deleted after displaying the data.
Rob
Hi Rob,
Custom components only sets the value_name and computes square root of value.
Then the insert state is extremely simple: insert into my_table (id, value_name, value_numeric) values (myseq.nextval, ?, ?)
I didn't answer to Jérémy's post, but yes the driver is properly set. I ran into issues he's describing years ago and addressed them.
What I'm describing is really weird in the fact that it sometime properly inserts the value and sometime insert the value of the previous record, it never crash or stop.
I'll try your protocol and let you know.
Pierre
Rob,
I ran your protocol but didn't see any issue.
However, if I use the (deprecated in 8.0) ODBC components (and comment out the 'cast' function), the issue shows up.
I've modified your protocol to include a 'data_index' column so that I can join the 'before' and 'after' data. (ie what is suppose to go in with what actually came out.)
Since I'm using Oracle, I changed the table to be a Global Temporary table. (this way, i'm not creating and dropping the table every time i run this protocol)
{ok, so it is a lot more complicated changes then what needs to be... but i still see the bug.}
After running your new test protocol I can now see the problem and it is understandable why this occurs. Oracle is very strict with data typing and so one can't enter data of a string type into a numeric field. In this case it seems Pipeline Pilot or possibly the driver is trying to be smart and convert the incoming data to fit into the field type specified in the Oracle table. Somewhere along the way things get confused. I like to think of this as the system outsmarting itself. There is an open bug report for this as you have mentioned.
However, this problem only seems to affect the earlier version of the ODBC components. If you rewrite your protocol to use the latest version of components this protocol will not even run. You will get an error specifying that you are trying to send data of varying types to a single field. I don't know how the development team feels about this, but in my opinion this in itself solves the bug. I feel it should be the programmers responsibility to be mindful of the Database restraints, datatypes, etc. before pushing data in. Again this is just my opinion. But at the very least I think we have shown that by specifying the datatypes so that the data maps to the field in Oracle, is a viable workaround if it is not the solution.
Hi,
I have encountered a similar problem using JDBC drivers into a MySQL database. I am trying to populate a table from a file where one of the columns is nullable integer. The first record in the file has a blank for the integer column. When I run a SQL insert, the JDBC driver complains that the data type is not an integer - I assume it is trying to insert a blank space. So I changed the data type to integer before inserting by using the ChangePropertyType(col_name, "Integer") function call. This has the effect of converting all the blanks to 0 which is incorrect. Does anyone have a suggestion to get around this problem?
Thanks,
Liz
Just FYI, everything is read as a string by the Delimited Text Reader -- a delimited text file contains no type information, and PP does not use any heuristics when reading the data to try to deduce the "true" data type. But for downstream components, the general rule is "if it looks like a number, treat it as a number; otherwise, treat it as a string." ODBC, being more strongly typed, is not as easygoing about all this -- hence the various issues being discussed in this thread.
Liz,
You might try ChangePropertyType(col_name, 'NullValue') before the insert. As you saw, changing an empty string to an Integer won't work, because there is no such thing as a "null integer" in Pipeline Pilot.
Cheers,
Dana
Hi Rob,
I ran your protocol. Indeed, it does work. Commenting out the ChangePropertyType line make it fail with the following error message:
Property "value" has different types in different data records (was SciTegic.value.StringValue is now SciTegic.value.DoubleValue)
Interestingly, although the miss inserted value was the square root (second record), the problem came from the initial value.
The first record has a value of 0 and it's type is set to String, the second record has a value of 356.3 and is considered a string as well.
type_0 := GetPropertyType(value, 0 );
If I change the first record (in the file) to 0.01, it is still read as a string by the delimited text reader.
Shouldn't we consider this as a bug in the delimited text reader?
Thanks all for your answers and help
Pierre