VS:DBSQLExecuteDSN: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
mNo edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<desc> | <desc> | ||
Executes a SQL | Executes a SQL query the specified DSN. It is not necessary to be registered in the ODBC manager. '''Note!''' The resultSetInstance have to be deleted with call to [[VS:DBSQLExecuteDelete|DBSQLExecuteDelete]] | ||
</desc> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
Line 55: | Line 56: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark></remark> | <remark> | ||
CMP: DSN param appears to need a POSIX path | |||
</remark> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
Latest revision as of 14:36, 23 October 2017
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Executes a SQL query the specified DSN. It is not necessary to be registered in the ODBC manager. Note! The resultSetInstance have to be deleted with call to DBSQLExecuteDelete
FUNCTION DBSQLExecuteDSN(
dsn :DYNARRAY[] of CHAR;
userName :DYNARRAY[] of CHAR;
password :DYNARRAY[] of CHAR;
SQLQuery :DYNARRAY[] of CHAR;
VAR outColumnCnt :LONGINT;
VAR outResultSetInst :LONGINT) : BOOLEAN;
def vs.DBSQLExecuteDSN(dsn, userName, password, SQLQuery): return (BOOLEAN, outColumnCnt, outResultSetInst)
Parameters
dsn DYNARRAY[] of CHAR userName DYNARRAY[] of CHAR password DYNARRAY[] of CHAR SQLQuery DYNARRAY[] of CHAR outColumnCnt LONGINT outResultSetInst LONGINT
Remarks
CMP: DSN param appears to need a POSIX path
Example
PROCEDURE Test; VAR res : BOOLEAN; colCnt, resSetInst, colIndex, rowIndex : LONGINT; colName, colValue : DYNARRAY [] OF CHAR; BEGIN res := DBSQLExecuteDSN( 'My Building', '', '', 'SELECT * FROM Spaces', colCnt, resSetInst ); AlrtDialog( Concat( 'Execute: res=', res, ' colCnt=', colCnt, ' resSetInst=', resSetInst ) ); rowIndex := 1; REPEAT FOR colIndex := 1 TO colCnt DO BEGIN res := DBSQLExecuteGet( resSetInst, colIndex, colName, colValue ); AlrtDialog( Concat( 'Result: row=', rowIndex, ' col=', colIndex, ' colName=', colName, ' colValue=', colValue ) ); END; rowIndex := rowIndex + 1; UNTIL NOT DBSQLExecuteNext( resSetInst ); DBSQLExecuteDelete( resSetInst ); END; RUN(Test);
Python
def Test(): res, colCnt, resSetInst = vs.DBSQLExecuteDSN( 'My Building', '', '', 'SELECT * FROM Spaces' ) vs.AlrtDialog( vs.Concat( 'Execute: res=', res, ' colCnt=', colCnt, ' resSetInst=', resSetInst ) ) rowIndex = 1 dbNext = True while dbNext: for colIndex in range(1, colCnt): res, colName, colValue = vs.DBSQLExecuteGet( resSetInst, colIndex ) vs.AlrtDialog( Concat( 'Result: row=', rowIndex, ' col=', colIndex, ' colName=', colName, ' colValue=', colValue ) ) rowIndex = rowIndex + 1 dbNext = vs.DBSQLExecuteNext( resSetInst ) vs.DBSQLExecuteDelete( resSetInst ) Test()
Version
Availability: from Vectorworks 2011
See Also
VS:DBSQLExecuteGet | VS:DBSQLExecuteNext | VS:DBSQLExecuteDelete
[[VS:DBSQLExecuteGet]] | [[VS:DBSQLExecuteNext]] | [[VS:DBSQLExecuteDelete]]