[英]execute immediate - ORA-00904: STRING: invalid identifier
I get the error我收到错误
ORA-00904: ggCategory: invalid identifier.
ORA-00904: ggCategory: 无效标识符。
If I run the select normally, it works without any problems and returns the correct values.如果我正常运行选择,它可以正常工作并返回正确的值。 Does anyone know where the syntax error is?
有谁知道语法错误在哪里?
execute immediate 'create table TEST_TABLE as (
select
category.name l_category,
u.*
from
User u
inner join listtext_view category on u.categoryID=category.ID and category.ident='||'ggCategory'||'
)';
What is ggcategory
?什么是
ggcategory
? I presume it is a variable (or a parameter);我认为它是一个变量(或参数); if so, it shouldn't be enclosed into single quotes, ie
如果是这样,则不应将其括在单引号中,即
execute immediate 'create table TEST_TABLE as (
select
category.name l_category,
u.*
from User u inner join listtext_view category on
u.categoryID=category.ID and category.ident=' || ggCategory ||')';
----------
Besides, table name certainly isn't User
as it is reserved word for Oracle's function.此外,表名当然不是
User
因为它是Oracle 功能的保留字。
If ggCategory
is meant to be a string literal then:如果
ggCategory
是字符串文字,则:
execute immediate 'create table TEST_TABLE as (
select
category.name l_category,
u.*
from
User u
inner join listtext_view category on u.categoryID=category.ID and category.ident=''ggCategory''
)';
If it is meant to be a variable then:如果它是一个变量,那么:
execute immediate 'create table TEST_TABLE as (
select
category.name l_category,
u.*
from
User u
inner join listtext_view category on u.categoryID=category.ID and category.ident='||ggCategory||'
)';
Assuming, in this later case, that it is a number or something else that does not need quoting;假设,在后一种情况下,它是一个数字或其他不需要引用的东西; or, if it does need quoting:
或者,如果确实需要引用:
execute immediate 'create table TEST_TABLE as (
select
category.name l_category,
u.*
from
User u
inner join listtext_view category on u.categoryID=category.ID and category.ident='''||ggCategory||'''
)';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.