Jump to content
Sign in to follow this  
Efo74

Add Function to Access Geosoft UDF

Recommended Posts

Efo74

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

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
spudw2k

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.