简体   繁体   English

[Amazon](500310)无效的操作:“ INVC_RLS_LCTN”列的类型为整数,但表达式的类型为字符变化;

[英][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.

相关问题 [Amazon](500310)无效的操作:声明为返回整数的函数中的返回类型不匹配; - [Amazon](500310) Invalid operation: return type mismatch in function declared to return integer; java sql error列的类型为整数,但表达式的类型为字符变化 - java sql error column is of type integer but expression is of type character varying Redshift 中的 DAU WAU MAU 错误:[Amazon](500310) 无效操作:由于内部错误,不支持此类关联子查询模式; - DAU WAU MAU Error in Redshift: [Amazon](500310) Invalid operation: This type of correlated subquery pattern is not supported due to internal error; knex js - 列的类型为时间戳,但表达式的类型为字符变化 - knex js - column is of type timestamp but expression is of type character varying SQL 错误 [500310] [42703]:[Amazon](500310) 操作无效:events_20180626_temp 中不存在列“engagement_time_msec”; - SQL Error [500310] [42703]: [Amazon](500310) Invalid operation: column "engagement_time_msec" does not exist in events_20180626_temp; [Amazon](500310)无效的操作:“ INTO”处或附近的语法错误,无法插入CSV文件 - [Amazon](500310) Invalid operation: syntax error at or near “INTO” for INSERT into CSV file [Amazon](500310) 无效操作:输入末尾的语法错误 Position: 684; - [Amazon](500310) Invalid operation: syntax error at end of input Position: 684; HugSQL 错误:列“date_answer”是日期类型,但表达式是字符类型不同? - HugSQL Error: column “date_answer” is of type date but expression is of type character varying? [Amazon](500310)无效操作:对表“ fact_spv_commissioned_lot”的FROM子句条目的引用无效; - [Amazon](500310) Invalid operation: invalid reference to FROM-clause entry for table “fact_spv_commissioned_lot”; 使用JDBC的redshift查询的“ java.sql.SQLException:[Amazon](500310)无效的操作:输入结束时语法错误” - “java.sql.SQLException: [Amazon](500310) Invalid operation: syntax error at end of input” for redshift query using JDBC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM