Method SqlStatement():asString() Foundation
Returns the final SQL statement as a character string.
:asString() -> cSqlStatement
A character string with the final SQL statement.
The method :asString() returns the final SQL statement as it would be sent to the SQL DBMS. This method can only be called after the statement was built. Execution of :asString() without having executed the :build()method results in a runtime error because the final SQL statement was not calculated.
Note that SQL statements such as INSERT/UPDATE/DELETE will not reflected the actual parameter values. Instead, parameter numbers are used as references in the string returned.
#include "dac.ch"
#include "xbp.ch"
PROCEDURE MAIN
LOCAL oStmt
LOCAL oBmp
oStmt := DacSqlStatement():fromChar("SELECT * FROM customers WHERE city==::SearchTerm")
oStmt:SearchTerm := "Berlin"
// Prints: SELECT * FROM customers WHERE city='Berlin'
? oStmt:Build():asString()
oStmt := DacSqlStatement():fromChar("INSERT INTO customers(name,image) VALUES(::name, ::image)")
oStmt:Name := "Peter Pan"
oBmp := XbpBitmap():new():create()
oBmp:loadFile("uranus.png")
oStmt:Image := oBmp:setBuffer(,XBPBMP_FORMAT_PNG)
// Prints: INSERT INTO customers(name,image) VALUES($1, $2)
? oStmt:Build():asString()
WAIT
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.