Search code examples
syntax-errorpowerbuilder

What is causing my PowerBuilder C0031 Synax error?


I'm still pretty new to Powerbuilder and programming. I'm getting two syntax errors when trying to save this code and I can't figure it out. The first error shows up as the first thing in the code "//*****" and the second error is at the "END CHOOSE". Any assistance would be much appreciated. //****************************************************************************** // Event: ue_run_script // // Description: First part of two-part script which will allow External Delivery Orders created with the External SF 252, SF 1442, SF 33 or SF 26 forms to be closed out. // The first part of the script creates a temp table to insert the documents with only obj_type of '52D', '42D', '26D', '33D'. // and then updates those obj_types to 'DEL' or 'B5M' accordingly. Then updates dsk_obj & proc_object with the new obj_type so that they can be closed out //
// Second part is ue_run_script2, which restores the original obj_types and drops the temp table. // // Arguments: None //
// Returns: 1 // // Programmer Date Comments // ----------- ----- --------- // N.Liappis 1/15/18 Initial Development 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

Solution

  • Replace this:

            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
    

    For this:

            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