Rx_
Nothing In Moderation
- Local time
- Today, 09:04
- Joined
- Oct 22, 2009
- Messages
- 2,803
Note: I was not getting good results - Please see new post in DB Theory & Practice area
http://www.access-programmers.co.uk/forums/showthread.php?p=1283919#post1283919
See attathment. Created a Table valued function that allows a parameter. This returns a recordset to Access so some business logic can evaluate it to a True or False.
1. How do I call the vRule_001 (prefer DAO) and pass the parameter
2. How does the small Recordset get returned?
In Access, there is a function: Public Function R_001(ID_Well) As Boolean
Here is working code to call the SQLServer View R_01. But, it is slow.
Here is what I want to replace with the Table-Valued Function and the records it returns.
SQLExclude = "SELECT R_01.ID_Wells, R_01.State_Abrv from R_01 " & _
" WHERE (((R_01.ID_Wells)=" & ID_Well & ") AND ((R_01.State_Abrv) In('UT')));"
Set rstExclude = CurrentDb.OpenRecordset(SQLExclude, dbOpenForwardOnly)
The R_01 is a linked View in SQL Server. The Where clause is taking way too long to return data from a view.
The goal is to return the Table Value View and treat it like the rstExclude recordset inside my function.
The problem is that about 20 Functions like this one, must be run on about 10,000 rows. It is a Rule Based Report. Lots of processing. So Every milisecond counts.
I know that if I could write a Stored Procedure. A SP would all run faster. Problem is, it will take me more time to write SP.
Some of the logic is very involved. The Rule definition is a work in progress.
So, having the Rule Logic in VBA allows me to put off learning combinations of nested TSQL case statements (for now).
20 Columns of different rules x 10,000 rows is taking about 45 mintues to run.
So, my hope is that a Table-Valued Function in SQL Server and some type of Pass-through query will speed things up.
http://www.access-programmers.co.uk/forums/showthread.php?p=1283919#post1283919
See attathment. Created a Table valued function that allows a parameter. This returns a recordset to Access so some business logic can evaluate it to a True or False.
1. How do I call the vRule_001 (prefer DAO) and pass the parameter
2. How does the small Recordset get returned?
In Access, there is a function: Public Function R_001(ID_Well) As Boolean
Here is working code to call the SQLServer View R_01. But, it is slow.
Here is what I want to replace with the Table-Valued Function and the records it returns.
SQLExclude = "SELECT R_01.ID_Wells, R_01.State_Abrv from R_01 " & _
" WHERE (((R_01.ID_Wells)=" & ID_Well & ") AND ((R_01.State_Abrv) In('UT')));"
Set rstExclude = CurrentDb.OpenRecordset(SQLExclude, dbOpenForwardOnly)
The R_01 is a linked View in SQL Server. The Where clause is taking way too long to return data from a view.
The goal is to return the Table Value View and treat it like the rstExclude recordset inside my function.
The problem is that about 20 Functions like this one, must be run on about 10,000 rows. It is a Rule Based Report. Lots of processing. So Every milisecond counts.
I know that if I could write a Stored Procedure. A SP would all run faster. Problem is, it will take me more time to write SP.
Some of the logic is very involved. The Rule definition is a work in progress.
So, having the Rule Logic in VBA allows me to put off learning combinations of nested TSQL case statements (for now).
20 Columns of different rules x 10,000 rows is taking about 45 mintues to run.
So, my hope is that a Table-Valued Function in SQL Server and some type of Pass-through query will speed things up.
Attachments
Last edited: