Error while inserting data to a database

Hello,

I’m trying to insert some data through the DB Insert node.
One of the data I want to insert is Double because doesn’t want me to cast it into an Integer since it’s an 18 digits number.

When I launch the insertion of this data to a numeric field of my database I have this error:
ERROR DB Insert 0:11036 Execute failed: Error while adding rows #-1000 - #0, reason: ORA-01461: une valeur ‘LONG’ ne peut être liée que dans une colonne de type ‘LONG’

Is there a mean to avoid the correction into long type or at least insert data through custom request so I would be able to cast my data in Oracle directly ?

Thanks

Sébastien Charneau

Hi,
Since a relational database stores the data in a very structured fashion, all values in a column must have the same type. So if you want to store a very long value, the whole column must support long values. It is not possible to mix types.
Kind regards
Alexander

Hi Alexander,

I’d like to insert an integer and Knime automattically convert my column in Long value.
I can’t see how to force it to go as a numeric.

I changed the Output Type Mapping options for numeric values to be used as numeric but it doesn’t seem to change a thing…

Is there a way to execute a script I would have write by myslef ?

Regards

Sébastien

Hi,
if you have a 18 digits number, you cannot put it into a table column for integers, as integers generally only allow numbers up to 2147483647 (4 bytes). If you want to store that number, you have to change the column type to long, which allows numbers up to 9223372036854775807 (8 bytes).
Kind regards
Alexander

2 Likes

Ok but I have some other problem after that. The first one is that I have some numbers larger than
the long type authorize, but if I but them in Double value I have a systematic rounding of everything which is a bigger issue to me
Regards
Sébastien

Hi,
double also only has 8 bytes, so it cannot store more. Are your numbers all positive? You may be able to use an unsigned data type to double your range in the positive numbers. Which database system are you using?
Kind regards
Alexander

Hi,

I don’t have any negative number, all of them are positive…
They are numbers calculated by another system I want to insert in an Oracle database and all of them have between 18 and 20 numbers

Regards

Sébastien

Hi,
I don’t know that much about Oracle databases and their types, but maybe you should think about storing the numbers as CHAR (20) instead.
Kind regards
Alexander

Hi,

It was my last resort option :wink:
But I think I will do this.

Moreover, is there a logical reason why after converting a column into a Double it’s rounded ? It looks like Knime just want to keep the visible numbers ok and keeps the exponent to complete

Regards

Sébastien

Hi,
You can right-click on the column header in the table view and choose to display the values with double precision.
Kind regards
Alexander

1 Like

Use Number type

A decimal number with up to 38 significant digits in the range of -(10125) to +(10125).

2 Likes

Hi beginner, my Oracle field is already in Number type that’s really a trouble with my Knime/Oracle interface

I’m not sure if there is any difference between number and numeric but numeric will for sure work as else many of my workflows would not work. Number/numeric however need to be defined correctly so that your value fits into the field. If it’s defined as numeric(10,0) you will not be able to insert your 20 digit numbers.

2 Likes

Yeah I know, but I already can insert numbers up to 38 digits it’s why I’m very suspicious about Knime way of casting numbers

I’ve been inserting numeric data with knime for close to a decade without issue so you are most likely doing something wrong on your side (wrong driver version, faulty workflow, faulty type mapping etc…)

2 Likes

Wow! Now I feel I just started 2 weeks ago :smiley:

Br,
Ivan

OK, I was exaggerating a bit to make the point. :grinning:

1 Like

Yes it’s why I posted on the forum I’m sure there is a thing I’m not doing well or not understanding well.
Is there a node where I can write my sql request by muself to see it’s the node I’m not using well or before ?

Hi @charneas,

to write your own SQL for inserting data to database use DB SQL Executor node.

Not a database expert but you don’t have a LONG column in your db and you are trying to insert LONG column type thus getting this ORA message.

“The LONG and LONG RAW datatypes have been deprecated and the easiest solution to the ORA-01461 error is to change the column datatype to as CLOB.”
http://www.dba-oracle.com/t_ora_01461_can_bind_a_long_value_only_for_insert_into_a_long_column.htm

Br,
Ivan

1 Like

Hi ipazin,

It works with the SQL Executor so I will stick with it thanks :slight_smile:

1 Like