ORA-00907:在字符串查询中缺少右括号

时间:2013-09-16 18:34:33

标签: sql oracle

我不熟悉Oracle语法,但是当我将此字符串传递给.Net Oracle Command然后它尝试填充数据适配器时,我得到了一个错误的右括号错误。

 string cT = "SELECT 'PRODUCT' AS ItemType, 'x' || CAST(LPROD.QUANTITY AS VARCHAR2(50)), " +
                  "PNAME.NAME || ' (' || CAST((PRODS.\"SIZE\" AS VARCHAR2(50))) || ' ' || PRODS.MEASURE || ')' AS Name, " +
                  "PRODS.PRODUCT_ID as ProductSizeID, PRODS.UPC_CODE as BarCode FROM ORDERS ORDR, LI_PROD LPROD, PRODUCT_NAME PNAME, " +
                  "PRODUCT PRODS WHERE ORDR.INV_NUM = :Invoice_Num AND ORDR.ORDER_NUM = LPROD.ORDER_NUM " +
                  "AND LPROD.PRODUCT_ID = PRODS.PRODUCT_ID AND PRODS.PRODUCT_NAME_ID = PNAME.ID";

有人能发现可能导致此错误的错误吗?谢谢你的帮助。

2 个答案:

答案 0 :(得分:3)

尝试:

cast(prods."SIZE" as varchar2(50))

而不是:

cast((prods."SIZE" as varchar2(50)))

答案 1 :(得分:0)

我最近提出了完全相同的问题,但找不到解决方案。最终发生的事情是我从SQLServer获得了以下代码,我试图将其转换为Oracle。

CAST(col AS NVARCHAR(250)) AS col_name,

我能够通过将其更改为

来修复它
CAST(col AS NVARCHAR2(250)) AS col_name,