Oracle ProC 插入值((选择 ...))

Oracle ProC INSERT INTO VALUES ( (select ...) )(Oracle ProC 插入值((选择 ...)))
本文介绍了Oracle ProC 插入值((选择 ...))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Oracle 10g 上运行 Pro*C.

Running Pro*C on Oracle 10g.

我希望在插入语句值子句中执行子查询.此 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 能够在值 caluse 内编译子查询:

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 插入值((选择 ...))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)