Santosh_mali
13th April 2018, 14:20
Hi All,
I am doing update operation using dynamic SQL.
Parsing and all is happening correct but db.update is returning value 509.
Please help if anybody knows how to resolve this issue.
Here is the code,
function dynamic.table.update( domain tcmcs.str8 inp.table,
domain tcmcs.long inp.index,
domain tcmcs.str8 inp.key1,
domain tcmcs.str4 inp.field,
domain tcmcs.str4 new.value)
{
string sql.string(512), str1(100)
long sql, var1, ret
db.retry.point()
sql.string = "select " & strip$(inp.table) & "." & strip$(inp.field) & " " &
"from " & strip$(inp.table) & " for update " &
"where " & strip$(inp.table) & "._index" & str$(inp.index) & " = { :1 }"
if (not sql) then
sql = sql.parse(sql.string)
endif
sql.where.bind(sql, 1, inp.key1)
sql.exec(sql)
while(true)
on case(sql.fetch(sql))
case eendfile:
break
case enorec:
break
case 0:
str1 = strip$(inp.table) & "." & strip$(inp.field) & ":=" & str$(new.value)
var1 = expr.compile(str1)
s.expr$(var1)
ret = db.update(sql, db.retry) |# on this line ret = 509
if ret = 0 then
commit.transaction()
endif
endcase
break
endwhile
sql.break(sql)
sql.close(sql)
sql = 0
}
I am doing update operation using dynamic SQL.
Parsing and all is happening correct but db.update is returning value 509.
Please help if anybody knows how to resolve this issue.
Here is the code,
function dynamic.table.update( domain tcmcs.str8 inp.table,
domain tcmcs.long inp.index,
domain tcmcs.str8 inp.key1,
domain tcmcs.str4 inp.field,
domain tcmcs.str4 new.value)
{
string sql.string(512), str1(100)
long sql, var1, ret
db.retry.point()
sql.string = "select " & strip$(inp.table) & "." & strip$(inp.field) & " " &
"from " & strip$(inp.table) & " for update " &
"where " & strip$(inp.table) & "._index" & str$(inp.index) & " = { :1 }"
if (not sql) then
sql = sql.parse(sql.string)
endif
sql.where.bind(sql, 1, inp.key1)
sql.exec(sql)
while(true)
on case(sql.fetch(sql))
case eendfile:
break
case enorec:
break
case 0:
str1 = strip$(inp.table) & "." & strip$(inp.field) & ":=" & str$(new.value)
var1 = expr.compile(str1)
s.expr$(var1)
ret = db.update(sql, db.retry) |# on this line ret = 509
if ret = 0 then
commit.transaction()
endif
endcase
break
endwhile
sql.break(sql)
sql.close(sql)
sql = 0
}