需要帮助的错误,在Oracle SQL查询



这是查询:

SELECT DISTINCT pprom.pk
FROM
(
    SELECT
      item_t0.SourcePK as pk
    FROM
      links item_t0
    WHERE (? =  item_t0.TargetPK   AND  item_t0.SourcePK  in (?,?))
    AND (item_t0.TypePkString=? )
    UNION
    SELECT
      item_t1.TargetPK as pk
    FROM
      cat2prodrel item_t1
    WHERE ( item_t1.SourcePK  in (? )  AND  item_t1.TargetPK  in (?,?))
    AND (item_t1.TypePkString=? )
) AS pprom

错误如下:

ORA-00933: SQL command not properly ended

你知道有什么问题吗?

编辑:

问号被相应项目的PKs代替:

values = [PropertyValue:8802745684882, PropertyValue:8796177006593, PropertyValue:8796201713665, 8796110520402, PropertyValue:8796125954190, PropertyValue:8796177006593, PropertyValue:8796201713665, 8796101705810]

编辑2:

这个查询是在一些专有软件系统的深处执行的,所以我不知道运行它的确切代码。

编辑3:

我发现了一个更短的查询,但结果相同的错误信息:

SELECT DISTINCT pprom.pk 
FROM 
( 
    SELECT  
        item_t0.SourcePK  as pk 
    FROM 
        links item_t0 
    WHERE (? =  item_t0.TargetPK  AND  item_t0.SourcePK  in (?)) 
        AND (item_t0.TypePkString=? )  
) AS pprom

使用以下值:

values = [PropertyValue:8799960601490, PropertyValue:8796177006593, 8796110520402]

编辑4

我发现的SQL代码是发送到数据库后替换值:

SELECT DISTINCT pprom.pk 
FROM 
( 
    SELECT  
        item_t0.SourcePK  as pk 
    FROM 
        links item_t0 
    WHERE (8801631769490 =  item_t0.TargetPK   AND  item_t0.SourcePK  in (8796177006593)) 
        AND (item_t0.TypePkString=8796110520402 )  
) AS pprom

我还尝试执行内部SELECT语句,单独运行ok并返回单个PK作为结果。

我在您的查询中找不到任何明显的语法错误,所以我认为问题是您用于将?占位符转换为实际值的客户端库。您的问题编辑显示一种转储,其中有8个整数,但只有6个PropertyValue项。确保这不是问题:IN (?, ?)需要2个参数。

<标题>编辑

当您为子查询分配别名时,尝试删除AS关键字:

SELECT DISTINCT pprom.pk 
FROM 
( 
    SELECT  
        item_t0.SourcePK  as pk 
    FROM 
        links item_t0 
    WHERE (8801631769490 =  item_t0.TargetPK   AND  item_t0.SourcePK  in (8796177006593)) 
        AND (item_t0.TypePkString=8796110520402 )  
) AS pprom
  ^^

相关内容

  • 没有找到相关文章

最新更新