Informix: Why does DECODE a json column in view does not work?
Posted in 2026
Topics: Data Types & Schema Design
Hi,
Why does not work DECODE on a json column in a view?
drop table if exists decode_test;
create table decode_test (
id int
,data_json json
,data_vchar varchar(16)
);
insert into decode_test (id) values (1);
drop view if exists decode_test_view;
create view decode_test_view(decode_json, decode_json_as_lvchar, decode_vchar, id, data_json, data_vchar) asselect
DECODE(data_json, null, 0, 1)
,DECODE(data_json::lvarchar, null, 0, 1)
,DECODE(data_vchar, null, 0, 1)
,id, data_json, data_vchar
from decode_test
;
select
DECODE(data_json, null, 0, 1)
,DECODE(data_json::lvarchar, null, 0, 1)
,DECODE(data_vchar, null, 0, 1)
,id, data_json, data_vchar
from decode_test
;
|decode_json|decode_json_as_lvchar|decode_vchar|id |data_json|data_vchar|
|-----------|---------------------|------------|---|---------|----------|
|0 |0 |0 |1 | | |
select * from decode_test_view;
|decode_json|decode_json_as_lvchar|decode_vchar|id |data_json|data_vchar|
|-----------|---------------------|------------|---|---------|----------|
|1 |1 |0 |1 | | |
You are subscribed to "Informix" as paul.cdi@oninit.com. To change your subscriptions, go to http://community.ibm.com/community/user/preferences?section=Subscriptions. To unsubscribe from this community discussion, go to [link removed]