Sql informix中的updatequery语句
关于我在Sql informix中的updatequery语句,sql,hibernate,informix,Sql,Hibernate,Informix,关于我在Infomix中的sql语句,我希望得到大家的帮助。请在下面找到我的代码。我将加入5个表,并用主键链接。我需要的是,我必须根据export\u flag='N'和country='MA'将export\u flag列更新为Y 但现在我遇到了这样的语法错误 13:34:12[更新-0行,0.000秒][错误代码:-201,SQL 状态:42000]发生语法错误 我找不到SQL中哪里有问题 update a set a.export_flag ='Y' FROM sc_ob_
Infomix
中的sql语句,我希望得到大家的帮助。请在下面找到我的代码。我将加入5个表,并用主键链接。我需要的是,我必须根据export\u flag='N'
和country='MA'
将export\u flag列更新为Y
但现在我遇到了这样的语法错误
13:34:12[更新-0行,0.000秒][错误代码:-201,SQL
状态:42000]发生语法错误
我找不到SQL中哪里有问题
update a set a.export_flag ='Y'
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country= b.sc_orig_country
OUTER JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
OUTER JOIN sc_ob_prod_group AS d, JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
AND b.sc_orig_country= d.sc_orig_country
AND b.sc_prod_cont_group_code = d.sc_prod_group_code
WHERE a.sc_orig_country ='MY'
AND a.export_flag='N';
Informix不支持这种带有连接的更新—请参阅更新部分的语法。当遇到无法识别的语法时,它会给出错误-201
如果Informix不支持updatewithjoin,那么如何连接表呢?无论如何,稍后我必须将此查询转换为Hibernate 我现在想进入休眠状态,拜托…你是说,你想让我解释你的查询并找出如何做?没有表的模式(主键、外键特别相关!)?你一定要在Hibernate中修复它;我从来没用过 这是您的查询,已重新格式化,以提高可读性
UPDATE a
SET a.export_flag ='Y'
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country= b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d -- ON clause missing (but there was a comma here)
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
AND b.sc_orig_country= d.sc_orig_country -- Part of missing ON clause?
AND b.sc_prod_cont_group_code = d.sc_prod_group_code -- Part of missing ON clause?
WHERE a.sc_orig_country ='MY'
AND a.export_flag='N';
在我未经训练的眼中,这似乎是一种极其复杂的写作方式:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
然而,假设所有的连接都做了一些有用的事情,以某种方式限制了更新的行集。所以,我们可以猜测它的意思是:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
AND sc_primary_key IN -- Guessed at column; no schema for the DB; no keys!
(SELECT a.sc_primary_key
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country = b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d
ON b.sc_orig_country = d.sc_orig_country
AND b.sc_prod_cont_group_code = d.sc_prod_group_code
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
)
如果事实上,sc\u ob\u temp\u audit
表上没有单列主键,则必须使用与EXISTS相关的子查询:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
AND EXISTS
(SELECT * -- It does not matter what you list here in an EXISTS sub-query
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country = b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d
ON b.sc_orig_country = d.sc_orig_country
AND b.sc_prod_cont_group_code = d.sc_prod_group_code
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
WHERE a.pk_column1 = sc_ob_temp_audit.pk_column1
AND a.pk_column2 = sc_ob_temp_audit.pk_column2
AND ...
)
我认为这是一个工作的机会;子查询上的WHERE子句应使用
a
标识子查询中的审核表,并使用全名标识UPDATE语句中的审核表。但是考虑到夜晚的时间,我可能会有一个错误的想法。Informix不支持使用连接的那种更新-请参阅更新部分的语法。当遇到无法识别的语法时,它会给出错误-201
如果Informix不支持updatewithjoin,那么如何连接表呢?无论如何,稍后我必须将此查询转换为Hibernate 我现在想进入休眠状态,拜托…你是说,你想让我解释你的查询并找出如何做?没有表的模式(主键、外键特别相关!)?你一定要在Hibernate中修复它;我从来没用过 这是您的查询,已重新格式化,以提高可读性
UPDATE a
SET a.export_flag ='Y'
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country= b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d -- ON clause missing (but there was a comma here)
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
AND b.sc_orig_country= d.sc_orig_country -- Part of missing ON clause?
AND b.sc_prod_cont_group_code = d.sc_prod_group_code -- Part of missing ON clause?
WHERE a.sc_orig_country ='MY'
AND a.export_flag='N';
在我未经训练的眼中,这似乎是一种极其复杂的写作方式:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
然而,假设所有的连接都做了一些有用的事情,以某种方式限制了更新的行集。所以,我们可以猜测它的意思是:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
AND sc_primary_key IN -- Guessed at column; no schema for the DB; no keys!
(SELECT a.sc_primary_key
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country = b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d
ON b.sc_orig_country = d.sc_orig_country
AND b.sc_prod_cont_group_code = d.sc_prod_group_code
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
)
如果事实上,sc\u ob\u temp\u audit
表上没有单列主键,则必须使用与EXISTS相关的子查询:
UPDATE sc_ob_temp_audit
SET export_flag = 'Y'
WHERE sc_orig_country = 'MY'
AND export_flag = 'N'
AND EXISTS
(SELECT * -- It does not matter what you list here in an EXISTS sub-query
FROM sc_ob_temp_audit AS a
JOIN sc_ob_allocation AS b
ON a.sc_ob_profile_code = b.sc_ob_profile_code
AND a.sc_orig_country = b.sc_orig_country
LEFT JOIN sc_fac_group AS f
ON b.sc_orig_country = f.sc_orig_country
AND b.sc_orig_sf_group_code = f.sc_fac_group_code
LEFT JOIN sc_ob_prod_group AS d
ON b.sc_orig_country = d.sc_orig_country
AND b.sc_prod_cont_group_code = d.sc_prod_group_code
JOIN gbl_produce AS e
ON d.sc_prod_cont_code = e.gp_cnt_cd
WHERE a.pk_column1 = sc_ob_temp_audit.pk_column1
AND a.pk_column2 = sc_ob_temp_audit.pk_column2
AND ...
)
我认为这是一个工作的机会;子查询上的WHERE子句应使用
a
标识子查询中的审核表,并使用全名标识UPDATE语句中的审核表。但考虑到夜晚的时间,我有可能会想错了。->外接sc_ob_prod_组为d,外接gbl_product组为e->外接sc_ob_prod_组为d,外接gbl_product组为e,外接gbl_product组为e,外接gbl_product组为e,外接gbl_product组为e,因为eHe也使用了外接
,但没有指定它是否为,RIGHT
或FULL
外部联接。如果支持一般的表示法,这将是一个问题;不是,所以没关系。我猜只支持更新(选择…使用连接查询…)x SET x.export\u flag='Y'
语法,对吗?@Ypercurit应该在左外侧JOIN@JonathanLeffler如果informix不支持Update with join,那么如何连接表?无论如何,我以后必须将此查询转换为hibernate。他还使用外部连接
,但没有指定它是否为左侧
,RIGHT
或FULL
外部联接。如果支持一般的表示法,这将是一个问题;不支持,所以没关系。我猜只支持更新(选择…使用连接查询…)x SET x.export\u flag='Y'
语法,对吗?@ypercube其假设位于左外侧JOIN@JonathanLeffler如果informix不支持Update with join,那么如何连接表呢?无论如何,稍后我必须将此查询转换为hibernate。