Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion error on CASE using computed column [CORE6101] #6350

Closed
firebird-automations opened this issue Jul 16, 2019 · 4 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pcisar

Here is reproducible test:

create table test_table_01 (
id int,
get_temp_i computed by ((cast (64 as int))),
fld2 int
);
commit;
insert into test_table_01 (id, fld2) values (1, 1);
commit;

select * from test_01;

      ID    GET\_TEMP\_I         FLD2

============ ============= ============
1 64 1

select get_temp_i+1 from test_01;

              ADD

=====================
65

select
case get_temp_i
when (get_temp_i = 1) then 1
else 2
end as case_result
from test_table_01;

CASE_RESULT

Statement failed, SQLSTATE = 22018
conversion error from string "64"

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

The engine behavior is correct and your test case is wrong.

You want

select
case get_temp_i
when 1 then 1
else 2
end as case_result
from test_table_01;

or

select
case when get_temp_i = 1
then 1
else 2
end as case_result
from test_table_01;

but are doing the equivalente of

select
case get_temp_i
when false then 1
else 2
end as case_result
from test_table_01;

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants