Domino Code Fragment

Code Name*
@DbCommand(ODBC)
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.139.62.103
Description*
Given data source information from the ODBC.INI file, uses this information to activate the appropriate ODBC driver. The driver then locates the specified DBMS, passes the specified command to it for processing, and returns the data retrieved by that command.
Type*
Formula
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
@DbCommand only works with non-Notes databases. You can use it only to retrieve data; @DbCommand can't add, delete, or modify data. @DbCommand is useful for testing a non-equal relationship (such as less­than), or for testing multiple conditions at the same time. To use @DBCommands, you must pass a command to the back­end database for processing. For example, to return data from records where BALANCE >= 1000.00 and DAYS_OVERDUE > 30. You can write the selection statement in SQL, and then use @DbCommand to pass that statement to the DBMS for processing; @DbCommand then returns the requested data.
Files/Graphics attachments (if applicable): Code:
@DbCommand(ODBC : NoCache; data_source; user_ID1 : user_ID2 ; "password1" : "password2"; command_string : null_handling)

Parameters
"ODBC"


"NoCache"
"user_ID1" : "user_ID2"
"password1 : password2"
"command_string"
"null_handling"
Return value
valuesFound
Specifying NoCache
The decision to use NoCache is based on performance issues. Forcing Notes to connect to the database and retrieve the same information again and again takes time, and slows overall performance. However, if you expect data to be changing on a frequent basis, it's worth the extra time to get up­to­date information.

For example, if youre using lookups to a database that stores customer addresses, its generally safe to use caching because you dont expect the addresses to change very often. But if youre using a lookup to a database where stock prices are stored, and that database gets updated hourly, its safer to omit caching and force a new lookup each time.


Specifying the data source
The data source name can contain up to 32 alphanumeric characters.

@DbLookup can access data sources that have already been registered in the ODBC.INI file (or similar registry on platforms on other than Windows). It can also autoregister a data source not present in the registry. For autoregistration, specify the data source as "data_source" : "type" : "path" where data_source is the name to be assigned, type identifies the DBMS (for example, "Oracle7"), and path is a server name, directory, or other string that locates the DBMS.

Specifying IDs and passwords
You only need these arguments if your DBMS requires them.

Instead of storing the IDs in the @DbCommand formula, you can replace them with null strings (""). If an ID is required, the user will be prompted for it. This is useful when you do not want other designers to see IDs, or when you want users to enter their own IDs when accessing external data. However, you must include IDs and passwords in formulas that will run automatically (such as an agent) because these formulas don't prompt for information.

The user IDs and passwords for accessing a data source are required only once per Notes database session as long as that database remains open. If the user opens another Notes database and executes a formula that accesses the same data source, the user ID and password will be required again.

Password parameters are necessary only when ID parameters are specified. Like IDs, passwords can either be stored in the @DbColumn formula, or prompted for by substituting the null string. If the database password is null, you can omit it from the formula.

For example, for the full ID/password specification, enter:


Note For complex connections, additional ID and password parameters may be required to connect to the data source.

Specifying the command string
The "command_string" can be any of the following:


Specifying null handling
To control how null values are handled, specify one of the following, appended to the command_string parameter with a colon:
Caution: NULL value replaced with user-defined value in @Db list
Accessing values found
@DbCommand can return no more than 55K bytes of data. Use the following equations to determine how much of your data can be returned with @DbCommand.
If the user's NOTES.INI file includes the statement

NoExternalApps=1

the @DbCommand formula is disabled. The user will not see an error message; the formula fails to execute. This applies to @DbCommand only when you use it with ODBC.