I have a grid with inline editing. When a record gets updated (saved), the onBeforeSQLCommandExecute takes over and executes a stored procedure. The stored procedure does basic business validation and inserts an audit trail record along with the record update.
Within the stored procedure I am doing business rule validation. If a business rule is violated, I want to use a throw command (or raiseerror) back to Alpha to gracefully handle. But Alpha isn't responding as I would hope. For instance, I have this:
ok = cn.Execute("exec Sp_UpdateLibraTickets :TicketNo, :NewOrderNo, :UserName, :Subsidiary", args)
If an error occurs in the stored procedure, ok=.f. (good so far).
But when I try to set e.errorText = e.cn.callresult.text, that value is 'success'... hardly close to any error I would hope to receive.
Can Alpha handle throw and/or RaiseError from SQL Server stored procedures? If so, how? I am providing the entire source for assistance:
args.xml = e.argsXML
args.add("TicketNo", args[3].data)
args.Add("NewOrderNo", args[1].data)
args.Add("UserName", userName)
args.Add("Subsidiary", "AWC")
e.cn.portableSQLEnabled = .t.
ok = cn.Open("::Name::RockTickets_Prod")
if ok then
ok = cn.Execute("exec Sp_UpdateLibraTickets :TicketNo, :NewOrderNo, :UserName, :Subsidiary", args)
if ok then
ok = cn.Close()
flag = .t.
end if
end if
if flag = .t. then
e.flagError =.f.
e.errorText = "There was a problem updating the record. Please check to make sure the sales order field is "
e.lastInsertedIdentityValue = -1
e.rowsAffected = e.cn.affectedRows()
e.SQLToDisplay = ""
e.ArgsToDisplay = ""
else
e.flagError = .t.
e.errorText = e.cn.callresult.text
e.lastInsertedIdentityValue = -1
e.rowsAffected = 0
end if
e.sqlcommandwashandled = .t.
Thanks in advance all.
Within the stored procedure I am doing business rule validation. If a business rule is violated, I want to use a throw command (or raiseerror) back to Alpha to gracefully handle. But Alpha isn't responding as I would hope. For instance, I have this:
ok = cn.Execute("exec Sp_UpdateLibraTickets :TicketNo, :NewOrderNo, :UserName, :Subsidiary", args)
If an error occurs in the stored procedure, ok=.f. (good so far).
But when I try to set e.errorText = e.cn.callresult.text, that value is 'success'... hardly close to any error I would hope to receive.
Can Alpha handle throw and/or RaiseError from SQL Server stored procedures? If so, how? I am providing the entire source for assistance:
args.xml = e.argsXML
args.add("TicketNo", args[3].data)
args.Add("NewOrderNo", args[1].data)
args.Add("UserName", userName)
args.Add("Subsidiary", "AWC")
e.cn.portableSQLEnabled = .t.
ok = cn.Open("::Name::RockTickets_Prod")
if ok then
ok = cn.Execute("exec Sp_UpdateLibraTickets :TicketNo, :NewOrderNo, :UserName, :Subsidiary", args)
if ok then
ok = cn.Close()
flag = .t.
end if
end if
if flag = .t. then
e.flagError =.f.
e.errorText = "There was a problem updating the record. Please check to make sure the sales order field is "
e.lastInsertedIdentityValue = -1
e.rowsAffected = e.cn.affectedRows()
e.SQLToDisplay = ""
e.ArgsToDisplay = ""
else
e.flagError = .t.
e.errorText = e.cn.callresult.text
e.lastInsertedIdentityValue = -1
e.rowsAffected = 0
end if
e.sqlcommandwashandled = .t.
Thanks in advance all.
Comment