ORACLE:无法绑定参数以创建 table AS 子查询
ORACLE: Cannot bind parameter to create table AS subquery
CREATE PRIVATE TEMPORARY TABLE ORA$PTT_collection_ids
ON COMMIT PRESERVE DEFINITION AS (
SELECT
DISTINCT cms3_dc_language.collection_id AS "collection_id"
FROM
cms3_dc_language
WHERE
cms3_dc_language.language = :language)
$sth->bindParam(":language", $language);
尝试绑定时出错:语言...
OCIBindByName: ORA-01036: 非法变量 name/number
如果绑定参数不是创建 table AS 子查询的一部分,则绑定有效,例如
SELECT
DISTINCT cms3_dc_language.collection_id AS "collection_id"
FROM
cms3_dc_language
WHERE
cms3_dc_language.language = :language
$sth->bindParam(":language", $language);
如果你做同样的事情using execute immediate你可以看到真正的问题:
ORA-01027: bind variables not allowed for data definition operations
尽管允许绑定变量作为查询的一部分(很明显),但此处查询是次要因素,问题在于 DDL。例如,使用普通 non-temporary、table 或视图时,您会遇到相同的错误。
CREATE PRIVATE TEMPORARY TABLE ORA$PTT_collection_ids
ON COMMIT PRESERVE DEFINITION AS (
SELECT
DISTINCT cms3_dc_language.collection_id AS "collection_id"
FROM
cms3_dc_language
WHERE
cms3_dc_language.language = :language)
$sth->bindParam(":language", $language);
尝试绑定时出错:语言...
OCIBindByName: ORA-01036: 非法变量 name/number
如果绑定参数不是创建 table AS 子查询的一部分,则绑定有效,例如
SELECT
DISTINCT cms3_dc_language.collection_id AS "collection_id"
FROM
cms3_dc_language
WHERE
cms3_dc_language.language = :language
$sth->bindParam(":language", $language);
如果你做同样的事情using execute immediate你可以看到真正的问题:
ORA-01027: bind variables not allowed for data definition operations
尽管允许绑定变量作为查询的一部分(很明显),但此处查询是次要因素,问题在于 DDL。例如,使用普通 non-temporary、table 或视图时,您会遇到相同的错误。