[BXSQ0002] calling sql:execute() in BaseX 7.5.1 snapshot
Friday, 11 January 2013 · 2 messages · last reply 14 Jan 2013
CD
Charles Duffy11 Jan 2013 23:47 #
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?CG
Christian Grün14 Jan 2013 13:00 #
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:executeQuoted text · Charles Duffy · 46 lines
> 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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery