Reputation: 55
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
Upvotes: 0
Views: 2067
Reputation: 441
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
Upvotes: 0
Reputation: 4174
Double quotes on embedded SQL string literal? Maybe.
Try commenting blocks of code and narrowing the error location better. I don't trust the locations you are being given right now.
The only thing that makes me wonder (besides missing end if or other syntax error) is your first database operation you used double quotes instead of single quotes for a string literal.
I'm guessing PB might interpret the "U" as a database table or column name and not a string literal like you were expecting.
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;
Just for fun you could turn off the option that tells PB to check database statements when compiling and see what happens. Instructions from PB help below.
Disabling database connection when compiling and building
When PowerBuilder compiles an application that contains embedded SQL, it connects to the database profile last used in order to check for database access errors during the build process. For applications that use multiple databases, this can result in spurious warnings during the build since the embedded SQL can be validated only against that single last-used database and not against the databases actually used by the application. In addition, an unattended build, such as a lengthy overnight rebuild, can stall if the database connection cannot be made.
To avoid these issues, you can select the Disable Database Connection When Compiling and Building check box on the general page of the System Options dialog box.
Upvotes: 0
Reputation: 2397
Looks like you are missing an END IF. See Below:
//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
Upvotes: 3
Reputation: 6215
It’s difficult to troubleshoot this remotely, but eyeballing it, I’d bet it’s your comments. PowerBuilder has two types of comment delimiters:
I’m guessing your //**** is being interpreted as the start of a /* set. Maybe try a space to break it up, like // ****, to avoid misinterpretation.
Upvotes: 0