Pervasive PSQL内连接有问题

时间:2018-02-27 14:51:17

标签: sql pervasive

error

CREATE VIEW "V_BACKLOG" 
    AS SELECT JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX, JOB_OPERATIONS.SEQ, JOB_OPERATIONS.PART, JOB_OPERATIONS.DESCRIPTION, JOB_OPERATIONS.ROUTER_SEQ, JOB_OPERATIONS.FLAG_CLOSED, JOB_OPERATIONS.WORK_STARTED, JOB_HEADER.SALES_ORDER, JOB.HEADER.SALES_ORDER_LINE, JOB.HEADER.DATE_OPENED, JOB_HEADER.CUSTOMER_PO, JOB_HEADER.DATE_DUE, JOB_HEADER.QTY_ORDER, JOB_HEADER.CUSTOMER, JOB_HEADER.DESCRIPTION 
    FROM JOB_OPERATIONS  
    INNER JOIN JOB_HEADER WHERE JOB_OPERATIONS.JOB = JOB_HEADER.JOB AND JOB_OPERATIONS.SUFFIX = JOB_HEADER.SUFFIX
    ORDER BY JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX, JOB_OPERATIONS.SEQ

在这里创建一个联接,我一直在试图弄清楚为什么引擎不会解析它。我通过测试除了1个相似品质之外的其他查询来进行缓慢消除,但是如果有人能照亮我,我会很感激。

修改

CREATE VIEW "testing" 
AS SELECT JOB_OPERATIONS.JOB,
    JOB_OPERATIONS.SUFFIX,
    JOB_OPERATIONS.PART,
    JOB_HEADER.QTY_ORDER,
    JOB_HEADER.CUSTOMER

FROM JOB_OPERATIONS

LEFT JOIN JOB_HEADER ON 
    (JOB_OPERATIONS.JOB = JOB_HEADER.JOB AND
    JOB_OPERATIONS.SUFFIX = JOB_HEADER.SUFFIX)

ORDER BY JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX

这是有效的

CREATE VIEW "V_BACKLOG" 
AS SELECT JOB_OPERATIONS.JOB, 
    JOB_OPERATIONS.SUFFIX, 
    JOB_OPERATIONS.SEQ, 
    JOB_OPERATIONS.PART, 
    JOB_OPERATIONS.DESCRIPTION, 
    JOB_OPERATIONS.ROUTER_SEQ, 
    JOB_OPERATIONS.FLAG_CLOSED, 
    JOB_OPERATIONS.WORK_STARTED, 
    JOB_HEADER.SALES_ORDER, 
    JOB.HEADER.SALES_ORDER_LINE, 
    JOB.HEADER.DATE_OPENED, 
    JOB_HEADER.CUSTOMER_PO, 
    JOB_HEADER.DATE_DUE, 
    JOB_HEADER.QTY_ORDER, 
    JOB_HEADER.CUSTOMER, 
    JOB_HEADER.DESCRIPTION 

FROM JOB_OPERATIONS

LEFT JOIN JOB_HEADER ON 
    (JOB_OPERATIONS.JOB = JOB_HEADER.JOB AND 
    JOB_OPERATIONS.SUFFIX = JOB_HEADER.SUFFIX)

ORDER BY JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX, JOB_OPERATIONS.SEQ

但这不,我发现令人困惑

3 个答案:

答案 0 :(得分:0)

你需要不同的条款"其中 - >上"

CREATE VIEW "V_BACKLOG" 
AS SELECT JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX, JOB_OPERATIONS.SEQ, JOB_OPERATIONS.PART, JOB_OPERATIONS.DESCRIPTION, JOB_OPERATIONS.ROUTER_SEQ, JOB_OPERATIONS.FLAG_CLOSED, JOB_OPERATIONS.WORK_STARTED, JOB_HEADER.SALES_ORDER, JOB.HEADER.SALES_ORDER_LINE, JOB.HEADER.DATE_OPENED, JOB_HEADER.CUSTOMER_PO, JOB_HEADER.DATE_DUE, JOB_HEADER.QTY_ORDER, JOB_HEADER.CUSTOMER, JOB_HEADER.DESCRIPTION 
FROM JOB_OPERATIONS  
INNER JOIN JOB_HEADER on JOB_OPERATIONS.JOB = JOB_HEADER.JOB AND JOB_OPERATIONS.SUFFIX = JOB_HEADER.SUFFIX
ORDER BY JOB_OPERATIONS.JOB, JOB_OPERATIONS.SUFFIX, JOB_OPERATIONS.SEQ

答案 1 :(得分:0)

Pervasive遇到的问题是我在同一视图中有两个名为“描述”的列。

答案 2 :(得分:0)

一切看起来都很完美,你说选择的长度会掩盖错误信息中的错误。所以这就是我想要的。从您的测试查询开始,一次添加一个元素,直到您遇到错误。通过这种方式,您将知道错误的位置,并在必要时删除元素,直到您有足够短的查询来查看实际错误。

同样作为第一个测试,查看具有该名称的视图是否已存在。如果是,则无法在不先删除视图的情况下创建视图。