Sign in to follow this  
Followers 0
Efo74

Add Function to Access Geosoft UDF

2 posts in this topic

;*****************************************************************************************************************

Func _accessMaxID($adSource, $adTable)

;*****************************************************************************************************************

$max_val_id = 0

$oADO = 'ADODB.Connection'

If IsObj($oADO) Then

$oADO = ObjGet('',$oADO)

Else

$oADO = _dbOpen($adSource)

EndIf

If IsObj($oADO) = 0 Then Return SetError(1)

If Not IsObj($oADO) Then Return SetError(2, 0, 0)

$oRec = _dbOpenRecordset()

If IsObj($oRec) = 0 Then Return SetError(2)

$oRec.Open ("SELECT MAX(ID) FROM " & $adTable , $oADO, $adOpenStatic, $adLockOptimistic)

$max_val_id = $oRec.Fields(0).Value

$oADO.Close()

return $max_val_id

EndFunc


:rolleyes:

Share this post


Link to post
Share on other sites



I think it would be more efficient to have a "query" function and simply supply the "select max(id)" to it rather than dedicate an entire function for that. Just my two cents.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0