f2s_esql_db_name¶

Applies to: MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

set_attribute f2s_esql_db_name of {DriverID} [{server}] to {database}
get_attribute f2s_esql_db_name of {DriverID} [{server}] to {database}

Parameter

Description

DriverID

The ID of the driver for which this applies. In most cases, you should use _f2s_ActiveDriverID.

server

Optionally passed server name. If a server name is not passed, the current server is used.

database

String, name of the database to get/set

Description

Setting this attribute sets which database is used for esql statements only. Any normal table queries or changes will still use the default database. This ONLY effects esql statements. If none is specified, the default database is used. This can be useful if a certain SQL statement needs to query data from a database not currently being used. NOT SURE WHAT THE NEXT SENTENCE MEANS Note, this only works if the table name is NOT fully qualified in the SQL statement. This attribute must be set before calling f2s_esql_creat_stmt, f2s_esql_set_proc_name or f2s_esql_set_func_name. If it is called after those commands it will not apply to that esql statement.

Lets say you have a program that uses VDFOrders. However, you need to retrieve data from another database, HelpDB, that is on the same server.

This code will throw an error when the f2s_esql_execute_stmt is run (assuming that you have not added a table HelpFile to VDFOrders):

set attribute f2s_esql_db_name of _f2s_ActiveDriverID to "VDFOrders"
f2s_esql_create_stmt "select NewName, Newtype from HelpFile where HelpFileID = ?"
f2s_esql_prepare_stmt
f2s_esql_set_param 1 to 5
f2s_esql_execute_stmt
f2s_esql_move_next
If (Found) Begin
  f2s_esql_get_row vRow
  Showln (SFormat("The new name is %1 and the new type is %2",vRow[0], vRow[1]))
End
f2s_esql_close_stmt

but this code will not:

set attribute f2s_esql_db_name of _f2s_ActiveDriverID to "HelpDB"
f2s_esql_create_stmt "select NewName, Newtype from HelpFile where HelpFileID = ?"
f2s_esql_prepare_stmt
f2s_esql_set_param 1 to 5
f2s_esql_execute_stmt
f2s_esql_move_next
If (Found) Begin
  f2s_esql_get_row vRow
  Showln (SFormat("The new name is %1 and the new type is %2",vRow[0], vRow[1]))
End
f2s_esql_close_stmt

Examples

get_attribute

string sDatabase

get_attribute f2s_esql_db_name of _f2sActiveDriverID (f2s_ConstPointer("MyServer")) to sDatabase

set_attribute

set_attribute f2s_esql_db_name of _f2sActiveDriverID (f2s_ConstPointer("MyServer")) to "HelpDB"

Replaces: Command SQL_USE_DATABASE