Unix Technical Forum

MAX NUMBER

This is a discussion on MAX NUMBER within the Oracle Miscellaneous forums, part of the Oracle Database category; --> ok ... im using the foll: code.... Function AssignNextval() As Long Dim db As Database Dim LPassThrough As QueryDef ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-08-2008, 11:13 AM
Reiro
 
Posts: n/a
Default Re: MAX NUMBER


ok ... im using the foll: code....


Function AssignNextval() As Long

Dim db As Database
Dim LPassThrough As QueryDef
Dim Lrs As dao.Recordset
Dim LSQL As String

On Error GoTo Err_Execute

Set db = CurrentDb()

'Create a temporary passthrough query to retrieve the NextVal from
an Oracle sequence
Set LPassThrough = db.CreateQueryDef("qryTemp")

'Use {Microsoft ODBC for Oracle} ODBC connection
LPassThrough.Connect =
"ODBC;DSN=cssmam_main;UID=mam4;PWD=mam4;SERVER =jhb-cssmamapp"
LPassThrough.SQL = "Select access_asset.nextval as NV From Dual"
LPassThrough.ReturnsRecords = True

Set Lrs = LPassThrough.OpenRecordset(dbOpenSnapshot)

'Retrieve NextVal from Oracle sequence
If Lrs.EOF = False Then
AssignNextval = Lrs("NV")
Else
AssignNextval = 0
End If

'Remove query definition when done
CurrentDb.QueryDefs.Delete "qryTemp"

Exit Function

Err_Execute:

'Remove query definition when done
CurrentDb.QueryDefs.Delete "qryTemp"

'Return 0 if an error occurred
AssignNextval = 0

End Function


nw im tryin to assign this value to a textbox on my access form

text12 = AssignNextval ()..... says function not allowed ......

and if go to the textbox > properties > data > default value =
AssignNextval () .. on form load i get #NAME?


how can i know assign this value to a text box...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-08-2008, 11:13 AM
DA Morgan
 
Posts: n/a
Default Re: MAX NUMBER

Reiro wrote:
> ok ... im using the foll: code....
>
>
> Function AssignNextval() As Long
>
> Dim db As Database
> Dim LPassThrough As QueryDef
> Dim Lrs As dao.Recordset
> Dim LSQL As String
>
> On Error GoTo Err_Execute
>
> Set db = CurrentDb()
>
> 'Create a temporary passthrough query to retrieve the NextVal from
> an Oracle sequence
> Set LPassThrough = db.CreateQueryDef("qryTemp")
>
> 'Use {Microsoft ODBC for Oracle} ODBC connection
> LPassThrough.Connect =
> "ODBC;DSN=cssmam_main;UID=mam4;PWD=mam4;SERVER =jhb-cssmamapp"
> LPassThrough.SQL = "Select access_asset.nextval as NV From Dual"
> LPassThrough.ReturnsRecords = True
>
> Set Lrs = LPassThrough.OpenRecordset(dbOpenSnapshot)
>
> 'Retrieve NextVal from Oracle sequence
> If Lrs.EOF = False Then
> AssignNextval = Lrs("NV")
> Else
> AssignNextval = 0
> End If
>
> 'Remove query definition when done
> CurrentDb.QueryDefs.Delete "qryTemp"
>
> Exit Function
>
> Err_Execute:
>
> 'Remove query definition when done
> CurrentDb.QueryDefs.Delete "qryTemp"
>
> 'Return 0 if an error occurred
> AssignNextval = 0
>
> End Function
>
>
> nw im tryin to assign this value to a textbox on my access form
>
> text12 = AssignNextval ()..... says function not allowed ......
>
> and if go to the textbox > properties > data > default value =
> AssignNextval () .. on form load i get #NAME?
>
>
> how can i know assign this value to a text box...


Don't do this in whatever front-end product you are using .. do
this in the database and if you need to know the value use the
INSERT statement's RETURNING clause.

Demos in Morgan's Library at www.psoug.org under SEQUENCE and
INSERT.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:14 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com