Oracle ProC插入值((select ...)) [英] Oracle ProC INSERT INTO VALUES ( (select ...) )
问题描述
在Oracle 10g上运行Pro * C.
Running Pro*C on Oracle 10g.
我正在寻找在insert语句values子句中进行子查询的方法.该sql查询完全有效,并且可以在TOAD内正常运行,但是Pro * C无法解析该查询.
I am looking to do a subquery within an insert statement values clause. This sql query is fully valid and runs within TOAD with no problems, but Pro*C fails to parse the query.
EXEC SQL INSERT INTO TARGET_ATTACHMENT
(
TARGET_ID
FILENAME
)
VALUES (
:targetID,
( SELECT CREATED_FLAG from TARGET t where t.TARGET_ID = :targetID ) || '.tif'
)
如果我删除:
( SELECT (CREATED_FLAG || DISPLAY_ID) from TARGET t where t.TARGET_ID = :targetID ) ||**".
Pro * C编译器可以正常工作,并且一切都可以按预期进行编译和运行.
The Pro*C compiler works and everything compiles and runs as expected.
如果我不删除: Pro * C编译器会引发语法错误.
If I DO NOT remove: The Pro*C compiler throws a syntax error.
1>Syntax error at line 128, column 12, file d:\SVN\...\TA.pc:
1>Error at line 128, column 12 in file d:\SVN\...
1>...\TA.pc
1> ( select CREATED_FLAG from target t where t.TARGET_ID = :targetID )
1>...........1
1>PCC-S-02201, Encountered the symbol "CREATED_FLAG" when expecting one of the fol
1>lowing:
1> ( ) * + - / . @ | at, day, hour, minute, month, second, year,
这是个问题,因为我希望Pro * C能够在值范围内编译子查询:
This is a problem, as I expect Pro*C to be able to compile subquerys within a values caluse:
即.
INSERT into table1 (col1) values ( (select t2.singleCol from table2 t2 where t2.priKey = :priKey) )
这是Pro * C的预期行为吗?还是应该在values子句中支持子查询?
Is this expected behaviour of Pro*C? or Should it support subqueries within the values clause?
推荐答案
可能将子查询更改为:
( SELECT CREATED_FLAG || '.tif' from TARGET t where t.TARGET_ID = :targetID )
我认为我从未见过像您所尝试的那样在子查询中附加任何内容.
I dont think I have ever seen something appended to a subquery the way you were attempting.
这篇关于Oracle ProC插入值((select ...))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!