f2s_esql_get_stmt

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

Syntax

f2s_esql_get_stmt {variable} using {variant}

Parameter

Description

variable

The string variable that will receive the set SQL Statement attached to the interface.

variant

The required variant type variable that will receive a statement interface.

Description

This command returns the last embedded SQL statement that was executed into a string. Optional parameters can be passed to specify what character to start the string at and also the maximum number of characters to allow for the string.

The required “using” syntax allows you to pass around the interface created by this command. The variable passed MUST be a variant. This allows for multiple statements to be active concurrently in some cases. If you use the “using” syntax, it must be used on all subsequent commands. Mixing the using syntax is not supported. So for instance, if you plan on having multiple statements active concurrently, all active statements must make use of the using syntax.

SQL statements can end up being very long and complicated in some cases. Working with these large statements can be cumbersome in DataFlex because of line continuation syntax. This can also hinder readability. To make things easier, you can use the ImageToString function in the cMertechImageParser.pkg package to allow loading of SQL statements from DataFlex images. See the example below for this use.

Example
     Variant vStat
     Variant[] vRow
     String sVal

     f2s_esql_create_stmt "Select * from sys.databases" using vStat
     f2s_esql_set_cursor_type f2s_olecursor_server using vStat
     f2s_esql_prepare_stmt using vStat

     f2s_esql_execute_stmt using vStat
     f2s_esql_move_next using vStat
     If (Found) Begin
         f2s_esql_get_row vRow using vStat
         // Do Something
     End

     f2s_esql_get_stmt sVal using vStat
     Showln "Get Statement Value: " sVal
     f2s_esql_close_stmt using vStat
     inkey windowIndex

Related Commands

Replaces: Commands SQL_GET_STATEMENT