DBWGetStringFieldData2

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Library Reference > Database >

DBWGetStringFieldData2

Description

Same as DBWGetStringFieldData1 but allowing to retrieve also NULL values as results

Syntax

Function DBWGetStringFieldData2(datasource, login, password, table, field_to_read,key, keyvalue, ByRef sResult, isValueNull)

Parameters

datasource

name of a valid datasource or
"@USEDEFAULTDATASOURCE" to force the usage of the default application datasource as returned from constant DBWorksConnectionDSN

login

a valid login to access the datasource in an autheinticated way

password

the password related to the specified login.

table

name of an existing table in the specified datasource.

field_to_read

name of the field from which the value must be taken.

key

field of which the value will be checked to determine the query selection.

keyvalue

value that will be checked to determine which records to read.

Return values

sResult

the result of the query as a string

isValueNull

TRUE: if the returned field value is NULLFALSE: otherwise

The function returns:

TRUE

if the selection found any record matching the query

FALSE

otherwise

Remarks

Use this function to retrieve values from an ODBC linked database.
This command is equivalent to applying an SQL selection query such as "select " & field_to_read & " from " & table &" WHERE " & key &" ='" & keyvalue & "'".

When connecting through file DSN, it's mandatory to use the datasource declared as @USEDEFAULTDATASOURCE.

See also

Get/Set string functions

Example

Sub main()
 DBWInit(TRUE)
 datasource = "@USEDEFAULTDATASOURCE"
 login = DBWorksConnectionUID
 password = DBWorksConnectionPWD
 table = DBWLookUp("NAME_DOCUMENT_TABLE")
 field_to_set = DBWLookup("NAME_FIELD_DESCRIPTION")
 Key = DBWLookup("NAME_FIELD_UNIQUE_ID")
 keyvalue="1991"
 field_to_read = DBWLookup("NAME_FIELD_DESCRIPTION")
 res = DBWGetStringFieldData2(datasource, login, password, table, field_to_read, key, keyvalue, sResult, isValueNull)
 DBWMsgbox "res=" & res & vbcrlf & "isValueNull=" & isValueNull & vbcrlf & "sResult=" & sResult
End Sub

Possible cases of return values:


NULL record found

not NULL record found

no record found

res

TRUE

TRUE

FALSE

isValueNull

TRUE

FALSE

FALSE

sResult


string