是什么导致我的PowerBuilder C0031 Synax错误?

时间:2018-01-16 20:00:31

标签: syntax-error powerbuilder

我对Powerbuilder和编程还很陌生。我在尝试保存此代码时遇到两个语法错误,我无法弄明白。第一个错误显示为代码“// *****”中的第一个错误,第二个错误显示在“END CHOOSE”。任何援助将不胜感激。     // ********* ******************************     //事件:ue_run_script     //     //描述:两部分脚本的第一部分,它将允许关闭外部SF 252,SF 1442,SF 33或SF 26表格创建的外部交货订单。     //脚本的第一部分创建一个临时表来插入只有obj_type为'52D','42D','26D','33D'的文档。     //然后相应地将这些obj_types更新为'DEL'或'B5M'。然后更新dsk_obj&使用新的obj_type proc_object,以便它们可以被关闭     //
    //第二部分是ue_run_script2,它恢复原始的obj_types并删除临时表。     //     //参数:无     //
    //返回:1     //     //程序员日期评论     // ----------- ----- ---------     // N.Liappis 1/15/18初步开发080117-0057-LN     // ********* *********

string s_doc_nmbr, s_doc_type, s_doc_lst_nmbr, s_drop
long l_proc_obj_id, l_rtn, l_table_exists, l_TMP_count
long l_origin_obj_id, l_err
int m_rtn


select obj_id, origin_obj_id
into :l_proc_obj_id, :l_origin_obj_id
from proc_object
where proc_object.obj_id = :gx_l_doc_obj_id
using SQLCA;



SELECT obj_usr_num, obj_type
INTO :s_doc_nmbr, :s_doc_type
FROM dsk_obj
Where obj_id = :gx_l_doc_obj_id
using SQLCA;


IF s_doc_type = '52D' or s_doc_type = '42D' or s_doc_type = '26D' or s_doc_type = '33D' THEN

    //Check for presence of the doc_list table
    select count(*)
    into :l_table_exists
    from dbo.sysobjects
    where dbo.sysobjects.type = "U"
    and name = "doc_list"
    using sqlca;


    CHOOSE CASE l_table_exists
    CASE 0
        //doc_list doesn't exist, so we can create it.
        l_rtn = This.Event ue_create_temp_table()
        IF l_rtn = -1 THEN
            gx_stop_run = "No"
            RETURN -1

        Else
            INSERT INTO doc_list(obj_id, obj_usr_num, orig_obj_type)
            VALUES (:l_proc_obj_id, :s_doc_nmbr, :s_doc_type)
            USING SQLCA;

            //Confirms that the table successfully got populated.
            select count (*)
            into :l_TMP_count
            from dbo.doc_list
            using sqlca;

                IF l_TMP_count = 0 then
                messagebox (gx_s_app_name, "The temp table was not populated correctly. Please contact SPS Help Desk for assistance", StopSign!)
                gx_stop_run = "No"
                return -1

                ELSE

                update doc_list
                set new_obj_type = 'DEL'
                where orig_obj_type like '__D'
                using sqlca;

                update doc_list
                set new_obj_type = 'B5M'
                where orig_obj_type like '__M'
                 or orig_obj_type like '__N'
                using sqlca;

                update dsk_obj
                set d.obj_type = dl.orig_obj_type
                from dsk_obj d, doc_list dl
                where d.obj_id = dl.obj_id
                using sqlca;                 

                update proc_object
                set p.obj_type = dl.orig_obj_type
                from proc_object p, doc_list dl
                where p.obj_id = dl.obj_id
                using sqlca;

                Return 1
            end if
        End IF

    CASE 1
        SELECT obj_usr_num
        INTO :s_doc_lst_nmbr
        FROM doc_list
        using SQLCA;

        //temp table exist.  Further investigation should be had.
        m_rtn = Messagebox(gx_s_app_name, s_doc_lst_nmbr + " was previously updated to allow closeout.  Please confirm document has been closed " +&
        "Once Confirmed, Please click OK to remove document from Temp Table", Information!, OKCancel!, 1)

        IF m_rtn = 1 THEN

                update dsk_obj
                set d.obj_type = dl.new_obj_type
                from dsk_obj d, doc_list dl
                where d.obj_id = dl.obj_id
                using sqlca;                 

                update proc_object
                set p.obj_type = dl.new_obj_type
                from proc_object p, doc_list dl
                where p.obj_id = dl.obj_id
                using sqlca;

                //drop doc_list
                s_drop = "drop table dbo.doc_list"
                EXECUTE IMMEDIATE :s_drop USING SQLCA;

                l_err = SQLCA.uf_sqlerrcheck("w_pdutl107_main", "ue_run_script", FALSE)
                IF l_err < 0 THEN 
                MessageBox("SQL Error", string(l_err)) 
                end if
                //doc_list doesn't exist, so we can create it.
                l_rtn = This.Event ue_create_temp_table()
                IF l_rtn = -1 THEN
                gx_stop_run = "No"
                RETURN -1

        Else
            INSERT INTO doc_list(obj_id, obj_usr_num, orig_obj_type)
            VALUES (:l_proc_obj_id, :s_doc_nmbr, :s_doc_type)
            USING SQLCA;

            //Confirms that the table successfully got populated.
            select count (*)
            into :l_TMP_count
            from dbo.doc_list
            using sqlca;

            IF l_TMP_count = 0 then
                messagebox (gx_s_app_name, "The temp table was not populated correctly. Please contact SPS Help Desk for assistance", StopSign!)
                gx_stop_run = "No"
                return -1

            ELSE

                update doc_list
                set new_obj_type = 'DEL'
                where orig_obj_type like '__D'
                using sqlca;

                update doc_list
                set new_obj_type = 'B5M'
                where orig_obj_type like '__M'
                 or orig_obj_type like '__N'
                using sqlca;

                update dsk_obj
                set d.obj_type = dl.orig_obj_type
                from dsk_obj d, doc_list dl
                where d.obj_id = dl.obj_id
                using sqlca;                 

                update proc_object
                set p.obj_type = dl.orig_obj_type
                from proc_object p, doc_list dl
                where p.obj_id = dl.obj_id
                using sqlca;

                Return 1
            end if
        End IF

        //This.EVENT ue_revert_back()
        //gx_stop_run = "No"
        //Return -1
    END CHOOSE  

Else
    MessageBox(gx_s_app_name, "This Document is not eligible for closeout conversion by this script, Please report this message to the SPS Help Desk.", Stopsign!, OK!)
    gx_stop_run = "No"
    Return -1
END IF

4 个答案:

答案 0 :(得分:2)

看起来你错过了END IF。见下文:

            //doc_list doesn't exist, so we can create it.
            l_rtn = This.Event ue_create_temp_table()
            **IF** l_rtn = -1 **THEN**
            gx_stop_run = "No"
            RETURN -1
            **THERE IS NO END IF HERE**
    Else

答案 1 :(得分:0)

很难远程解决这个问题,但是眼睛看它,我敢打赌这是你的意见。 PowerBuilder有两种类型的注释分隔符:

  1. //到该行的末尾,
  2. / * to * /。
  3. 我猜你的// ****被解释为/ *集的开头。也许尝试一个空间来分解它,比如// ****,以避免误解。

答案 2 :(得分:0)

嵌入式SQL字符串文字的双引号?也许

尝试评论代码块并更好地缩小错误位置。我不相信你现在被给予的位置。

唯一令我惊讶的事情(除了缺少结束if或其他语法错误)是你的第一个数据库操作,你使用双引号而不是字母文字的单引号。

我猜PB可能会将“U”解释为数据库表或列名,而不是像您期望的那样将字符串文字解释为。

select count(*)
into :l_table_exists
from dbo.sysobjects
where dbo.sysobjects.type = "U"  // PB probably interprets this as DB column
and name = "doc_list"  // use single quotes here
using sqlca;

只是为了好玩,你可以关闭告诉PB在编译时检查数据库语句的选项,看看会发生什么。来自PB的说明如下。

在编译和构建时禁用数据库连接

当PowerBuilder编译包含嵌入式SQL的应用程序时,它会连接到上次使用的数据库配置文件,以便在构建过程中检查数据库访问错误。对于使用多个数据库的应用程序,这可能会在构建期间导致虚假警告,因为嵌入式SQL只能针对该单个最后使用的数据库进行验证,而不能针对应用程序实际使用的数据库进行验证。此外,如果无法建立数据库连接,无人参与的构建(例如冗长的隔夜重建)可能会停止。

要避免这些问题,可以在“系统选项”对话框的常规页面上选中“在编译和构建时禁用数据库连接”复选框。

答案 3 :(得分:0)

替换它:

        MessageBox("SQL Error", string(l_err)) 
        end if
        //doc_list doesn't exist, so we can create it.
        l_rtn = This.Event ue_create_temp_table()
        IF l_rtn = -1 THEN
        gx_stop_run = "No"
        RETURN -1

为此:

        MessageBox("SQL Error", string(l_err)) 
        end if
        //doc_list doesn't exist, so we can create it.
        l_rtn = This.Event ue_create_temp_table()
        IF l_rtn = -1 THEN
        gx_stop_run = "No"
        RETURN -1
        End If   // << This is what's new