DbGetFieldNumeric

ODBC function.

The DbGetFieldNumeric function retrieves the value of a numeric field (integer) within the current record for the dataset in use. Not available in WinTask Lite.

Syntax

DbGetFieldNumeric(<field_name>,<value>)
or
Ret=DbGetFieldNumeric(<field_name>,<value>)

Parameters

<field_name>, string, name of the field to retrieve.

<value>, numeric, a variable which will contain the value of the field.

Return value

Ret, numeric return code. If the retrieval has been done, the function returns 0, otherwise use this return code for error management.

Example

 

DbConnect("DSN=gpao;PWD=SILOG") ' connection to ODBC database called gpao

DbSelect("SELECT * FROM Business",DYNASET) ' select all records in table Business.

#Ignorerrors=0 ' error management inside the script.

While not DbEof() ' while there are still records to read.

Err=DbGetFieldNumeric("Value",num) ' num contains the numeric value in field Value.

If err<>0 then ' if an error occurs during retrieval.

Goto gesterr ' call an error routine.

endif

msgbox(str$(num)) ' display the value of the field.

DbMovenext() ' move to next record.

Wend

Example code

'Declare first in system configuration, ODBC databases, your target ODBC database

'in this script, we have called it DBASE

 

sub display_enreg()

'It displays in one long string the retrieved fields.

mes$="ID : "+str$(id)

mes$=mes$+"\n\"+"SiteCode : "+sitecode$

mes$=mes$+"\n\"+"RequestNumber : "+requestnumber$

mes$=mes$+"\n\"+"Notes : "+notes$

mes$=mes$+"\n\"+"Address : "+address$

mes$=mes$+"\n\"+"City : "+city$

mes$=mes$+"\n\"+"State : "+state$

mes$=mes$+"\n\"+"Zip : "+zip$

 

msgbox(mes$,64,"Record "+str$(i+1))&#9;&#9;

 

endsub

'------------------------------------------

sub extract()

nbenreg=DbRecordCount() 'get total records

if nbenreg > 0 then

msgbox(str$(nbenreg)+ " records(s) to process")

DbMoveFirst()

i=0

repeat

DbGetFieldNumeric("ID",id)

DbGetFieldString("SiteCode",sitecode$)

DbGetFieldString("RequestNumber",requestnumber$)

DbGetFieldString("Notes",notes$)

DbGetFieldString("Address",address$)

DbGetFieldString("City",city$)

DbGetFieldString("State",state$)

DbGetFieldString("Zip",zip$)

display_enreg()

DbMoveNext()

i=i+1

until i=nbenreg

else

msgbox("No record to process")

endif

endsub

'************************************

 

res=dbconnect("DSN=DBASE")

res=dbselect("SELECT * FROM Table1",DYNASET)

extract()