AndrewMozley
Programmer
I am transferring records (for a specific nominal account, selected by range of dates) from TableA into a cursor Cursor1 for reporting, and while doing this I gather further descriptive information from another table, either Customer or Supplier. I am doing this in a way that I am familiar with, but I wonder whether I ought to be using SQL more comprehensively. I do use SQL a little, but am not very familiar with it.
Here, in essence is my code; TableA is ordered by date within nominal account
I feel that I may be doing too much SELECTing in this code!. If anyone has a more elegant way of achieving the task, I would be grateful.
I have given the basic structure of the code - there are one or two complications - for example there is in fact a TableB, similar to table A, which is also scanned to gather information forCursor1, but the core of my concern is whether there is a neater way of gathering the account name information from Customer and Supplier.
Here, in essence is my code; TableA is ordered by date within nominal account
Code:
* Nom_account and Start_date have been established
SELECT TableA
SEEK Nom_Account
SCAN FOR Tran_date >= start_date WHILE TableA.account = Nom_account
SELECT Cursor1
APPEND BLANK
REPLACE thisfield WITH TableA.Thisfield, Thatfield With TableA.ThatField . . .
DO CASE
CASE TableA.RecType = “C”
SELECT Customer
SEEK TableA.Related_Account
lcName = Customer.account_name
CASE TableA.RecType = “S”
SELECT Supplier
SEEK TableA.Related_Accont
lcName = Supplier.account_name
ENDCASE
SELECT Cursor1
REPLACE cName WITH lcName
* maybe replace some other fields in Cursor1
ENDSCAN
I feel that I may be doing too much SELECTing in this code!. If anyone has a more elegant way of achieving the task, I would be grateful.
I have given the basic structure of the code - there are one or two complications - for example there is in fact a TableB, similar to table A, which is also scanned to gather information forCursor1, but the core of my concern is whether there is a neater way of gathering the account name information from Customer and Supplier.