I have used the SQL Actions Code Generator to delete a row from a list. When I hard code the 2 values that determine what record will be deleted, it works. When I try to use Arguments, it doesn't. Here's the code I've been using. (I've indicated the lines that work with "HARD CODED" and the lines what don't with "USING ARGUMENTS".)
This is the case with both a view and a table. Note - I'm not asking about what shows in the list - I know how to refresh a list. I'm asking about underlying table.
I'd appreciate any help.
Thanks,
Rob
Function DeleteLesson as c (e as P)
dim cn as sql::connection
dim flag as l
flag = cn.open("::Name::ZebraHostSwimmingDatabase")
if flag = .f. then
'there was an error
dim errorText as c
errorText = cn.callresult.text
end
end if
'turn on portable SQL
cn.PortableSQLEnabled = .t.
dim SQL as c
sql = "DELETE FROM lessons_copy1 WHERE SWIMMER_NU = :KID and LESSON_NUM = :CLASS"
dim args as sql::arguments
' HARD CODED - args.add("KID",9185)
' HARD CODED - args.add("CLASS",11067)
USING ARGUMENTS - args.add("KID",convert_type(e.datasubmitted.SWIMMER_NU,"N"))
USING ARGUMENTS - args.add("CLASS",convert_type(e.datasubmitted.LESSON_NUM,"N"))
'execute the SQL
flag = cn.execute(sql,args)
if flag = .f. then
'there was an error
dim errorText as c
errorText = cn.callresult.text
cn.close()
end
end if
dim rowsDeleted as n
'get the number of rows that were deleted
rowsDeleted = cn.CallResult.rowsaffected
cn.close()
end function
This is the case with both a view and a table. Note - I'm not asking about what shows in the list - I know how to refresh a list. I'm asking about underlying table.
I'd appreciate any help.
Thanks,
Rob
Function DeleteLesson as c (e as P)
dim cn as sql::connection
dim flag as l
flag = cn.open("::Name::ZebraHostSwimmingDatabase")
if flag = .f. then
'there was an error
dim errorText as c
errorText = cn.callresult.text
end
end if
'turn on portable SQL
cn.PortableSQLEnabled = .t.
dim SQL as c
sql = "DELETE FROM lessons_copy1 WHERE SWIMMER_NU = :KID and LESSON_NUM = :CLASS"
dim args as sql::arguments
' HARD CODED - args.add("KID",9185)
' HARD CODED - args.add("CLASS",11067)
USING ARGUMENTS - args.add("KID",convert_type(e.datasubmitted.SWIMMER_NU,"N"))
USING ARGUMENTS - args.add("CLASS",convert_type(e.datasubmitted.LESSON_NUM,"N"))
'execute the SQL
flag = cn.execute(sql,args)
if flag = .f. then
'there was an error
dim errorText as c
errorText = cn.callresult.text
cn.close()
end
end if
dim rowsDeleted as n
'get the number of rows that were deleted
rowsDeleted = cn.CallResult.rowsaffected
cn.close()
end function
Comment