Hi
I'm trying to upload data to Teradata using:
proc sql;
create table v4 as
select
EXTRACTION_DATE format=DATE9.,
LIMIT as LIMIT_AMT format=best32.
from work.x
quit;
proc sql;
insert into tera.y
select * from v4;
quit;
I get the error:
ERROR: On an insert, update, or index operation, the value applied to a Teradata 8 byte decimal was out of range - greater than
9.223372036854775808E18.
How do I solve this?
Upload to a volatile table where the variable is defined as float and then copy from there into the real target using a passthru query.
Hi
More information
The limit_amt variable in Teradata is defined as
LIMIT_AMT DECIMAL(32,9) DEFAULT 0.000000000 COMPRESS ,
The limit that I'm trying to upload is
10917118759
The format in SAS is
NAME | TYPE | LENGTH | VARNUM | LABEL | FORMAT | FORMATL | FORMATD | INFORMAT | INFORML |
LIMIT_AMT | 1 | 8 | 7 | BEST | 16 | 2 | BEST | 32 |
Lastly - the dataset on Teradata has been predefined and I don't have access to alter the definitions there
Show the definition of the table you are loading into. From the Teradata documentation an 8 byte decimal value is large enough for decimal numbers with a wide of 10 to 18 digits. The number in your error message has 19 digits. Note also that when you define the variable in Teradata you need to specify how many of those digits are to the right of the decimal point, so the upper bound could be even lower.
Also SAS cannot store 19 digits exactly as a number since it uses 8 byte floating point binary numbers. The maximum number of decimal digits is 15. So if I read in
9,223,372,036,854,775,808
and print it back out it becomes
9,223,372,036,854,777,856
Notice how the last four digits have changed.
What do those number represent? Are they actual numbers that you want to compare? Do you really care about the 16-19 th least significant decimal digits?
Perhaps you just need to create the field as a floating point number in Teradata instead of a decimal number.
After further investigation my question now is:
How do I upload a value gt 999,999,999.9 to Teradata where the field is decimal(32,9)?
I either get the
ERROR: On an insert, update, or index operation, the value applied to a Teradata 8 byte decimal was out of range - greater than
9.223372036854775808E18.
or
ERROR: Teradata insert: Numeric overflow occurred during computation.
Teradata does not want more than 9 decimal places. You told SAS it could format the number with up to 30 decimal places.
Try telling SAS to format the number with no more than 9 decimal places.
Try chaning the format attached to the variable from BEST32. to 32.9 and see if it works.
You are still not going to be able to get SAS to store more than 15 decimal digits exactly
Thanks, Tom
Changing formats on the SAS side does not seem to work
It seems that the number is too large, any value less than or equal to 999,999,999.9 gets inserted into the Teradata, any number larger and I get the error
Upload to a volatile table where the variable is defined as float and then copy from there into the real target using a passthru query.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.