Resetting File Pointer After A DeleteRow

I’ve written a LotusScript agent that builds a result set from a physical file on an AS/400, reads through that result set, and for each record it retrieves, it might update several Notes documents, and then delete the record from the AS/400.

The agent works perfectly if I run it from my client. If there are 9 records in the physical file, is processing all 9 one-by-one and deletes all records one-by-one once they have been processed; i.e. once the corresponding Notes documents have been updated.

The problem is that if I all my Domino server to execute the agent, it only reads the first record, updates the corresponding Notes documents, and then deletes that first record. It doesn’t process any additional records. It seems as though the DeleteRow method is leaving the file pointer at end-of-file so that my subsequent NextRow returns false. I’ve tried numerous things, but none have worked. I’ve tried using FirstRow after the delete thinking I need to reposition to the first row now that the original first row has been deleted. That didn’t work either.

Below is my code without all the declarations:

Status% = con.ConnectTo(“ALPHA”, user, pswd)

Set qry.Connection = con

qry.Sql = “select * from plcustf.tlfrompl”

Set res.Query = qry

Status% = res.Execute

Status% = res.FirstRow

While Status% = True

key = res.GetValue(“UNIQID”)

aYear = res.GetValue(“VHEXYR”)

aMonth = res.GetValue(“VHEXMN”)

Set collection = view.GetAllDocumentsByKey

(key)

If collection.count >= 0 Then

For i = 1 To collection.count

  Set doc = collection.GetNthDocument(i)

  doc.AccountingYear = aYear

  doc.AccountingMonth = aMonth

  Call doc.Save (True, True)

Next

End If

res.deleteRow(“plcustf.tlfrompl”)

Status% = res.NextRow

Wend

res.close (db_close)

con.disconnect

Subject: Resetting File Pointer After A DeleteRow

There might be some difference in how the different versions handle this, if your server is a different version from your client.

I might suggest that you use the LC LSX instead of ODBC classes. Then you can activate the Writeback property of a connection to allow you to delete the record just read without spoiling your result set.

Subject: RE: Resetting File Pointer After A DeleteRow

I’ve never used the LC LSX. What is it and where would I get information on how to modify my agent to use it instead of the ODBC classes??

Subject: RE: Resetting File Pointer After A DeleteRow

It’s installed along with the Domino server code. It’s documented in the Domino Designer help. Look in the table of contents for “Lotus Connectors”.

To program with the LC LSX, you must have installed your Notes client with Domino Enterprise Connection Services (DECS) enabled.

If you want to use ODBC, you can do it with the LC LSX, but you should use the Merant/DataDirect ODBC drivers. But this system also contains specific code for DB2 (as well as other daabases), so you don’t have to use ODBC if you have the DB2 client or if the DB2 database is running locally on the server.

Subject: RE: Resetting File Pointer After A DeleteRow

Interesting. You wouldn’t happen to have a sample script that uses LC LSX to update an AS/400 physical file?? I’m thinking if I had an actual script to refer to, and that script did one or more basic database functions, that would be beneficial.

I’ll definitely give this a read in the help text. Thanks for the info.

Subject: RE: Resetting File Pointer After A DeleteRow

The help contains several code examples, and in addition there are numerous samples at http://www.lotus.com/products/eibu_knowbase.nsf – follow the Lotus Connector LotusScript Extension link, then LotusScript Samples using the LCLSX. Don’t worry about getting AS400 specific examples – the whole point of the Lotus Connectors is to provide a generic interface that lets you use essentially the same code no matter what kind of database you’re using.

Subject: Resetting File Pointer After A DeleteRow

I’m going to post some additional information to my own posting.

If I replace the DeleteRow with another SQL that does “delete from plcustf.tlfrompl”, that works, but I don’t understand why I have to run another query instead of simply using the DeleteRow method.

I mentioned in the original posting that if I run this agent from my client, it works perfectly. Well I took that one step further. If I schedule it to run locally instead of running on the server, and then let my client run it locally, it also runs perfectly.

I’m not thinking that the difference here is a result of client vs. server. I’m actually thinking that the difference here is a result of my client accessing the AS/400 file via a Client Access ODBC Data Source vs. when my Domino For iSeries server runs it, it accesses the physical file natively…but that’s just a theory.

Hope someone can provide some insight.