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?