[英][Amazon](500310) Invalid operation: column “INVC_RLS_LCTN ” is of type integer but expression is of type character varying;
I'm trying to insert values in a table that resides in RedShift database. 我试图在驻留在RedShift数据库中的表中插入值。 But when i insert the NULL value in an integer column i get the following error: 但是,当我在整数列中插入NULL值时,出现以下错误:
Amazon Invalid operation: column "INVC_RLS_LCTN " is of type integer but expression is of type character varying; Amazon无效操作:“ INVC_RLS_LCTN”列的类型为整数,但表达式的类型为字符变化;
Here is the schema: 这是模式:
CREATE TABLE DM_TX_LINE_FCT
(
SRRGT_ID BIGINT NOT NULL,
IGT_RSRVTN_ID CHARACTER VARYING(40),
INVC_RLS_LCTN INTEGER,
)
distkey(TX_SRRGT_KEY)
SORTKEY(LCTN_ID, PRCSSNG_DT_KEY);
I'm inserting in the table like this 我这样插入表格
...
...
PT.CASHIER_NBR,
PT.MMBRSHP_CARD_ID,
MMBR.MMBRSHP_CARD_SRRGT_ID,
NULL as IGT_RSRVTN_ID,
NULL as INVC_RLS_LCTN,
...
...
Can anyone tell me, why can't i store NULL in integer value? 谁能告诉我,为什么我不能将NULL存储在整数值中?
The database is guessing the NULL
value's type as a VARCHAR
. 数据库正在猜测NULL
值的类型为VARCHAR
。 Probably because of something else happening in the query. 可能是因为查询中发生了其他情况。
Explicitly cast it to INTEGER
to allow insertion. 明确将其INTEGER
转换为INTEGER
以允许插入。
CREATE TEMP TABLE "nulltest" ("nulltest" INT);
--CREATE TABLE
INSERT INTO "nulltest" SELECT CAST(NULL AS VARCHAR(10));
--ERROR: column "nulltest" is of type integer but expression is of type character varying
--HINT: You will need to rewrite or cast the expression.
INSERT INTO "nulltest" SELECT CAST(NULL AS INTEGER);
--INSERT 0 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.