【发布时间】:2023-01-10 12:35:26
【问题描述】:
What I am trying is to loop through the following records from the subquery and assign the ID from the ARINVT table as the first column value for the Inert query. The other two values will be consistently hard keyed. I think the problem is that my subquery returns all the rows from the ARINVT but I need to loop through each one of those rows one at a time when inserting rows to the FGMULTI table. I don't know how to do that although I suspect somehow, I could have a variable be assigned the ID value of the current row I am on in the loop? Just not sure how to proceed.
Begin
For v in (
Select
ID
From ARINVT
Left Join ARINVT inv on inv.ID = br.ARINVT_ID
and inv.CLASS = 'WP')
Loop
Insert Into FGMULTI (ARINVT_ID, LOC_ID, AUTO_DISPO_DEFAULT_LOC)
VALUES
((Select ID FROM ARINVT WHERE CLASS='WP'),27052, 'Y')
End Loop ;
End ;
完整脚本返回以下错误: 开始
对于 v 在 (
选择 ID 来自 ARINVT 在 inv.ID = br.ARINVT_ID 上左加入 ARINVT inv 和 inv.CLASS = 'WP')
环形
插入 FGMULTI(ARINVT_ID、LOC_ID、AUTO_DISPO_DEFAULT_LOC)
价值观 ((Select ID FROM ARINVT WHERE CLASS='WP'),27052, 'Y')
结束循环;
结尾 ; - 好的。 [ 0.0080 秒] 0 行受影响
- 失败的: [FireDAC][Phys][Ora] ORA-06550:第 18 行,第 3 列: PL/SQL: ORA-00933: SQL 命令未正确结束 ORA-06550:第 13 行,第 1 列: PL/SQL:SQL 语句被忽略 ORA-06550:第 21 行,第 5 列: PLS-00103: 遇到符号“;”当期望出现以下情况之一时:
环形
手动 SQL 语句 -> 已完成,出现 1 个错误。
下标返回以下错误:
插入 FGMULTI(ARINVT_ID、LOC_ID、AUTO_DISPO_DEFAULT_LOC)
价值观 ((Select ID FROM ARINVT WHERE CLASS='WP'),27052,'Y') - 好的。 [ 0.0190 秒] 0 行受影响
- 失败的: [FireDAC][Phys][Ora] ORA-01427:单行子查询返回多行
手动 SQL 语句 -> 已完成,但有 1 个错误。
【问题讨论】:
标签: sql sql-insert