“=”处或附近的语法错误

时间:2017-08-18 05:03:01

标签: database postgresql plpgsql

错误是“=”处或附近的语法错误,即IF trans1.trans_type ='2'       那么pkg_util_bd_logistics_convertopcode(trans1.TRANS_TYPE,trans1.REMARK,       trans1.STD_ID)。函数pkg_util_bd_logistics_convertopcode在那里。代码由ora2pg迁移。有人帮忙吗?

CREATE OR REPLACE FUNCTION BZ_DATA_PROCESSER_bindsftransdatatoso () RETURNS 
VOID AS $body$
DECLARE

    v_soId                     bigint;
    v_shopId                   bigint;
    v_soCode                   varchar(50);
    v_outerOrderCode           varchar(200);
    v_orderCategory            T_SO_DISTINECT_TRANS_HEAD.ORDER_CATEGORY%TYPE := 0;
    v_headCount                bigint := 0;
    v_detailCount              bigint := 0;
    v_distinctTransHeadCount   bigint := 0;
    v_distinctTransDetailCount bigint := 0;
    v_accepTimeCount           bigint := 0;
    v_distinctTransHeadId      bigint;
    v_sltheadId                bigint;
    v_createTimeBefore         timestamp := clock_timestamp() - interval '30 days';
    trans1 RECORD;
  trans RECORD;

BEGIN
    FOR trans1 IN (SELECT std_temp1.TRANS_TYPE,
                          std_temp1.TRACKING_NO,
                          std_temp1.ORDER_ID,
                          std_temp1.STD_ID,
                          std_temp1.ACCEPT_TIME,
                          std_temp1.ACCEPT_ADDRESS,
                          std_temp1.REMARK,
                          std_temp1.OP_CODE,
                          std_temp1.ROOT_ID,
                          std_temp1.SOURCE,
                          std_temp1.BATCH_NO,
                          std_temp1.SIGNER

                     from (SELECT ST.TRANS_TYPE,
                                  ST.MAILNO          TRACKING_NO,
                                  ST.ORDERID         ORDER_ID,
                                  STD.ID             STD_ID,
                                  STD.ACCEPT_TIME,
                                  STD.ACCEPT_ADDRESS,
                                  STD.REMARK,
                                  STD.OP_CODE,
                                  STD.ROOT_ID,
                                  STD.SOURCE,
                                  STD.BATCH_NO,
                                  STD.SIGNER
                             FROM T_MQ_SO_TRANS ST, T_MQ_SO_TRANS_DETAIL STD
                            WHERE ST.ID = STD.SO_TRANS_ID
                              AND STD.IS_SYNCH = 0
                              AND ST.TRANS_TYPE in (1, 2, 3, 4, 5, 6, 8)
                              AND ST.CREATE_TIME between v_createTimeBefore and
                                  clock_timestamp()
                              AND STD.CREATE_TIME between v_createTimeBefore and
                                  clock_timestamp()
                            ORDER BY STD.ID ASC) std_temp1  LIMIT 99999) 
            LOOP

      IF trans1.trans_type = '2'
      THEN pkg_util_bd_logistics_convertopcode(trans1.TRANS_TYPE,
                                            trans1.REMARK,
                                            trans1.STD_ID);
      END IF;
    END LOOP;

    FOR trans IN (SELECT std_temp2.TRANS_TYPE,
                          std_temp2.TRACKING_NO,
                          std_temp2.ORDER_ID,
                          std_temp2.STD_ID,
                          std_temp2.ACCEPT_TIME,
                          std_temp2.ACCEPT_ADDRESS,
                          std_temp2.REMARK,
                          std_temp2.OP_CODE,
                          std_temp2.ROOT_ID,
                          std_temp2.SOURCE,
                          std_temp2.BATCH_NO,
                          std_temp2.SIGNER

                     from (SELECT ST.TRANS_TYPE,
                                  ST.MAILNO          TRACKING_NO,
                                  ST.ORDERID         ORDER_ID,
                                  STD.ID             STD_ID,
                                  STD.ACCEPT_TIME,
                                  STD.ACCEPT_ADDRESS,
                                  STD.REMARK,
                                  STD.OP_CODE,
                                  STD.ROOT_ID,
                                  STD.SOURCE,
                                  STD.BATCH_NO,
                                  STD.SIGNER
                             FROM T_MQ_SO_TRANS ST, T_MQ_SO_TRANS_DETAIL STD
                            WHERE ST.ID = STD.SO_TRANS_ID
                              AND STD.IS_SYNCH = 0
                              AND ST.TRANS_TYPE in (1, 2, 3, 4, 5, 6, 8)
                              AND ST.CREATE_TIME between v_createTimeBefore and
                                  clock_timestamp()
                              AND STD.CREATE_TIME between v_createTimeBefore and
                                  clock_timestamp()
                            ORDER BY STD.ID ASC) std_temp2  LIMIT 99999) LOOP
      v_soId           := 0;
      v_orderCategory  := 0;
      v_shopId         := NULL;
      v_soCode         := NULL;
      v_outerOrderCode := NULL;
      BEGIN
        SELECT SO.ID, SO.SHOP_ID, SO.CODE, SO.OUTER_ORDER_CODE
          INTO STRICT  v_soId, v_shopId, v_soCode, v_outerOrderCode
          FROM T_SO_TB_DELIVERY_INFO TBI, T_SO_SALES_ORDER SO
         WHERE TBI.SO_ID = SO.ID
           AND TBI.TRANS_CODE = trans.TRACKING_NO LIMIT 1 OFFSET 0;
       EXCEPTION
        WHEN NO_DATA_FOUND THEN
          dbms_output.put_line
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;

1 个答案:

答案 0 :(得分:1)

在plpgsql中,一个函数不能单独存在。在pkg_util_bd_logistics_convertopcode( ... );

之前,您需要PERFORM

可能会有更多问题......