converting my app to SQL, i have lots of update scripts to switch from dbf to sql so i want to make sure before i go ahead and start the work that i am on the right track and have the most efficient way of doing this.
All updates are run in the afterupdate event of a dialog or grid.
this is the type of script i am changing
this is what i have converted it to - this partuclar one needs an if, then, else but not all of them do
do i need to keep opening and closing the connection if this is run from a grid/dialog?
is there a way i can improve this for ease or efficiency?
All updates are run in the afterupdate event of a dialog or grid.
this is the type of script i am changing
Code:
'set progress values dim tbl as p tbl = table.open("[PathAlias.ADB_Path]\progress.dbf") 'Find the record that has to be edited query.filter = "caseref = " +quote(session.caseref) query.order = "" query.options = "" qry = tbl.query_create() nrecs = qry.records_get() if nrecs > 0 then tbl.change_begin() if totmths1 > 35 then tbl.comp_res1 = "Completed" else tbl.comp_res1 = "Not Completed" end if end if tbl.change_end(.t.) qry.close() tbl.close()
Code:
dim cn as sql::Connection flagresult = cn.open("::Name::MMLocal") dim args as sql::Arguments args.set("caseref",session.caseref) args.set("COMP_RES1","Completed") args.set("COMP_RES1NC","Not Completed") if totmths1>35 then dim sql_update as c sql_update = "UPDATE progress SET COMP_RES1 = :COMP_RES1 WHERE caseref = :caseref" dim flag as l flag = cn.Execute(sql_update,args) cn.close() else dim sql_update as c sql_update = "UPDATE progress SET COMP_RES1 = :COMP_RES1NC WHERE caseref = :caseref" dim flag as l flag = cn.Execute(sql_update,args) cn.close() end if
is there a way i can improve this for ease or efficiency?
Comment