Informix:选择空问题 [英] Informix: Select null problem

查看:92
本文介绍了Informix:选择空问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Informix,我创建了一个临时表,试图从select语句中填充它.之后,我要进行更新,以在临时表中填充更多字段.

Using Informix, I've created a tempory table which I am trying to populate from a select statement. After this, I want to do an update, to populate more fields in the tempory table.

所以我正在做类似的事情;

So I'm doing something like;

create temp table _results (group_ser int, item_ser int, restype char(4));

insert into _results (group_ser, item_ser)
select 
      group_ser, item_ser, null
from
      sometable

但是您不能选择null.

But you can't select null.

例如;

select first 1 current from systables

有效但是

select first 1 null from systables

失败!

(不要让我开始为什么不能不指定表就只做选择当前"之类的SQL Server!)

(Don't get me started on why I can't just do a SQL Server like "select current" with no table specified!)

推荐答案

此页面说不能这样做的原因是因为"NULL"没有类型.因此,解决方法是创建一个仅以所需类型返回NULL的sproc.

This page says the reason you can't do that is because "NULL" doesn't have a type. So, the workaround is to create a sproc that simply returns NULL in the type you want.

尽管这对我来说似乎是一个非常糟糕的解决方案.也许您可以在脚本中创建一个变量,将其设置为null,然后选择该变量?像这样:

That sounds like a pretty bad solution to me though. Maybe you could create a variable in your script, set it to null, then select that variable instead? Something like this:

DEFINE dummy INT;
LET dummy = NULL;

SELECT group_ser, item_ser, dummy
FROM sometable

这篇关于Informix:选择空问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆