Method SqlStatement():fromChar() Foundation
Creates an SQL statement object from a character string.
:fromChar( <cStatement> ) -> oSqlStatement
This method returns an SQL statement object which can be used for statement building and execution.
The SqlStatement() class supports a named parameter syntax, which simplifies the handling of parameters passed to the SQL backend and allows statement reuse. To utilize this feature, simply use <::symbolName> instead of the parameter value in your SQL statement. The SqlStatement() class then automatically creates a member variable with the name "symbolName". Any value that is assigned to this member variable is inserted into the SQL statement when calling the :build() method. This procedure is outlined below. Additional examples can be found in the documentation of the :asString() method.
#include "pgdbe.ch"
PROCEDURE main
LOCAL oSess, oStmt
oSess := DacSession():new("DBE=pgdbe;SERVER=localhost;DB=northwind;UID=postgres;PWD=postgres;")
oStmt:= DacSqlStatement():fromChar( "SELECT * FROM customers WHERE country=::country" )
oStmt:country := "Germany"
oStmt:build():query()
Browse()
oStmt:country := "USA"
oStmt:build():query()
Browse()
RETURN
PROCEDURE DbeSys
DbeLoad("pgdbe")
DbeSetDefault("pgdbe")
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.