VikramBhalla
Technical User
Below is a part of a script that I am writing and the find works fine but there is problem that the filter record set is always less than the actual record set so when it finishes writing to the spreadsheet the only record then it throws an error. is there a way I can make this run the possibility that I can think of is that I make my sqlquery at run time puting the where clause at run time but I cant figure out how to do it.
row_count = DataTable.GetSheet("Action1".GetRowCount
for r = 1 to row_count
x= DataTable.GetSheet("Action1".GetParameter("Operator".ValueByRow(r)
if x = "=" then
xx = DataTable.GetSheet("Action1".GetParameter("Master_DB_Name".ValueByRow(r)
y = DataTable.GetSheet("Action1".GetParameter("Value".ValueByRow(r)
SQL = xx& "='"&y &"'"
strSQL = "select a.*, b.* from table1 a,table2 b where a.customer_no = b.Customer_No "
if r = 1 then
rst.open strSQL, con,3,3
end if
end if
if r > row_count then
call close_DataBase()
end if
do until rst.eof
rowcount= DataTable.GetSheet("Global".GetRowCount
rst.find(SQL)
for rr=1 to rowcount
x = DataTable.GetSheet("Global".GetParameter("Get_Coll_Rcv_Flds".ValueByRow(rr)
if x = "y" then
db_fld_val= DataTable.GetSheet("Global".GetParameter("Master_DB_Fld_Name".ValueByRow(rr)
local_Param = DataTable.GetSheet("Global".GetParameter("Local_Param_Name".ValueByRow(rr)
field_owner = DataTable.GetSheet("Global".GetParameter("Field_Owner".ValueByRow(rr)
a = rst.fields(db_fld_val)
On Error movelast
datatable(local_Param,field_owner) = a
datatable.setnextrow
end if
next
rst.movenext
loop
next
row_count = DataTable.GetSheet("Action1".GetRowCount
for r = 1 to row_count
x= DataTable.GetSheet("Action1".GetParameter("Operator".ValueByRow(r)
if x = "=" then
xx = DataTable.GetSheet("Action1".GetParameter("Master_DB_Name".ValueByRow(r)
y = DataTable.GetSheet("Action1".GetParameter("Value".ValueByRow(r)
SQL = xx& "='"&y &"'"
strSQL = "select a.*, b.* from table1 a,table2 b where a.customer_no = b.Customer_No "
if r = 1 then
rst.open strSQL, con,3,3
end if
end if
if r > row_count then
call close_DataBase()
end if
do until rst.eof
rowcount= DataTable.GetSheet("Global".GetRowCount
rst.find(SQL)
for rr=1 to rowcount
x = DataTable.GetSheet("Global".GetParameter("Get_Coll_Rcv_Flds".ValueByRow(rr)
if x = "y" then
db_fld_val= DataTable.GetSheet("Global".GetParameter("Master_DB_Fld_Name".ValueByRow(rr)
local_Param = DataTable.GetSheet("Global".GetParameter("Local_Param_Name".ValueByRow(rr)
field_owner = DataTable.GetSheet("Global".GetParameter("Field_Owner".ValueByRow(rr)
a = rst.fields(db_fld_val)
On Error movelast
datatable(local_Param,field_owner) = a
datatable.setnextrow
end if
next
rst.movenext
loop
next