Skip to content
Advertisement

oracle add column with value based on condition

I would like to add a column “tag” based on value of “LEASE_ID_count” with ORACLE.

But i get this error :

value too large for column “CUSTOM_LIFETIME_VALUE_TAG”.”tag” (actual: 7, maximum: 3) , caused by: OracleDatabaseException: ORA-12899: value too large for column “CUSTOM_LIFETIME_VALUE_TAG”.”tag” (actual: 7, maximum: 3

select "COMPANY_CODE", "LEASE_ID_count",
(CASE WHEN "LEASE_ID_count" IN ('3','4', '5') THEN '3 à 5vh' WHEN "LEASE_ID_count" ='1' THEN '1vh' WHEN "LEASE_ID_count" ='2' THEN '2vh' END) "tag"
from "CUSTOM_LIFETIME_VALUE_TESR"

Any idea please to help me ? thanks

Advertisement

Answer

This is too long for a comment. The error message is referring to "CUSTOM_LIFETIME_VALUE_TAG"."tag". This is from a table that has no obvious reference in the query. Okay, perhaps CUSTOM_LIFETIME_VALUE_TESR is a view that references that table. That is possible.

However, the error message is about storing data into that column, not referencing it. So, my best guess is that you have a query like this:

INSERT INTO CUSTOM_LIFETIME_VALUE_TAG (COMPANY_CODE, LEASE_ID_count, tag)
    <your select here>;

And the column tag in this table is defined as 3 characters. Clearly, '3 à 5vh' has 7 characters which is more than 3 which causes an error. Hence the error.

Oracle does have a lot of functionality lurking around. Even so, it is hard for me to think of how a SELECT could cause this error with no DML involved.

As Alex Poole very correctly notes: write the queries without double quotes. Quoted identifiers just make queries harder to write and read.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement