Proc对join的支持问题

来源:互联网 发布:淘宝累计销量没有了 编辑:程序博客网 时间:2024/06/05 15:41

自己在使用proc的过程中,发现使用join的时候会报语法错误,例如:

“PCC-S-02201, 出现符号 "left"在需要下列之一时:

 ; , for, union, connect,
   group, having, intersect, minus, order, start, where, with,


经过网上搜索,应该是老版本的proc不支持该语法的原因,在11g之后是支持ANSI 99的SQL语法的,之前版本的,可以通过动态语句来变通实现。


问:Is it possible to use INNER JOIN's with Pro*C? I'm currently getting this error:
INNER JOIN t_diagnosis b ON a.sak_diag = b.sak_diag

PCC-S-02201, Encountered the symbol "INNER" when expecting one of the following:
; , for, union, connect, group, having, intersect, minus,
order, start, where, with,
The query runs fine via SQL Developer. My version of Pro*C is Pro*C/C++: Release 10.2.0.3.0.
Thanks,
Matthew


答:Unfortunately the Pro*C precompiler does not understand "new" syntax/keywords... this falls into the same category as using analytics discussed here:
http://forums.oracle.com/forums/thread.jspa?threadID=664180&tstart=0
You would need to use dynamic sql as described in the programmer's guide to do this.


Support for all the ANSI 99 sql syntax (including joins) has been added in 11gw ith the new precompiler option common_parser. You can precompile your proc program containig join sqls as follows:
proc common_parser=yes proc_file.pc
For release 10.2 and earlier you would to workaround by using dynamic sqls as Mark suggested


在Proc(Release 10.2.0.1.0)中是没有common_parser这个选项的,

但是在Proc(Release 11.2.0.1.0)就有:

选项名称       当前值         说明

common_parser  否             使用 Common SQL Front End 进行语法分析

原创粉丝点击