Howdy --
I have the following code, which worked perfectly with BaseX 7.3:
declare function sqlimport:load-sql-source-raw($config as element(config), $sql_source as element(sql-source)) { let $handle := sql:connect( concat($sql_source/@uri, "/", $sql_source/@schema/string()), $sql_source/@username, $sql_source/@password) let $all_column_names := sql:execute( sql:prepare( $handle, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=?"), sql:parameters sql:parameter type='string'{$sql_source/@schema/string()}</sql:parameter> sql:parameter type='string'{$sql_source/@table/string()}</sql:parameter> </sql:parameters> )/sql:column[@name="COLUMN_NAME"] let $column_names := $all_column_names/text()[not(.=$sql_source/ignore-column/text())] return sql:execute($handle, concat("SELECT ", string-join($column_names, ", "), " FROM ", $sql_source/@table/string())) };
With BaseX 7.5 and current snapshots of 7.5.1, however, it yields the following error:
[BXSQ0002] No opened connection with id 1
...positioned at the sql:execute() call.
I would understand sql:connect() failing -- but having the connection appear to take place without errors, followed by a failure with the execution, is surprising.
Guidance?
Dear Charles,
with 7.5, the signatures of our SQL functions were slightly updated [1]. You’ll need to use sql:execute-prepared() for prepared statements.
Hope this helps, Christian
[1] http://docs.basex.org/wiki/SQL#sql:execute ___________________________
I have the following code, which worked perfectly with BaseX 7.3:
declare function sqlimport:load-sql-source-raw($config as element(config), $sql_source as element(sql-source)) { let $handle := sql:connect( concat($sql_source/@uri, "/", $sql_source/@schema/string()), $sql_source/@username, $sql_source/@password) let $all_column_names := sql:execute( sql:prepare( $handle, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=?"), sql:parameters sql:parameter type='string'{$sql_source/@schema/string()}</sql:parameter> sql:parameter type='string'{$sql_source/@table/string()}</sql:parameter> </sql:parameters> )/sql:column[@name="COLUMN_NAME"] let $column_names := $all_column_names/text()[not(.=$sql_source/ignore-column/text())] return sql:execute($handle, concat("SELECT ", string-join($column_names, ", "), " FROM ", $sql_source/@table/string())) };
With BaseX 7.5 and current snapshots of 7.5.1, however, it yields the following error:
[BXSQ0002] No opened connection with id 1
...positioned at the sql:execute() call.
I would understand sql:connect() failing -- but having the connection appear to take place without errors, followed by a failure with the execution, is surprising.
Guidance?
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de