我正在尝试使用以下代码创建和分配变量,以便在plsql(11g)中创建对象类型但面临一些错误:
begin
execute immediate 'drop type picu_obj force';
execute immediate 'drop type picu_obj_tab force';
execute immediate 'create type picu_obj as object(Customer_ID varchar2(32767),Customer_Name varchar2(32767),Server_Name varchar2(32767),Time_stamp varchar2(32767))';
execute immediate 'create type picu_obj_tab is table of picu_obj;';
picu_var picu_obj_tab;
picu_var := picu_obj_tab(picu_obj('101','xyz','pro-ssr-qr','12:13'));
end;
The above code gives following errors:
ERROR at line 6:
ORA-06550: line 6, column 10:
PLS-00103: Encountered the symbol "PICU_OBJ_TAB" when expecting one of the
following:
:= . ( @ % ;
The symbol ":=" was substituted for "PICU_OBJ_TAB" to continue.
请在这里建议我做错了什么。
答案 0 :(得分:1)
此代码存在两个问题:
首先:在Oracle 11g中,您无法使用Buildfile: C:\Users\pandabhi\eclipseworkspace\CaptchaTest\build.xml
init:
[delete] Deleting directory C:\Users\pandabhi\eclipseworkspace\CaptchaTest\dist
[mkdir] Created dir: C:\Users\pandabhi\eclipseworkspace\CaptchaTest\dist
build:
[war] Building war: C:\Users\pandabhi\eclipseworkspace\CaptchaTest\dist\captchatest.war
compile:
[javac] Compiling 5 source files to C:\Users\pandabhi\eclipseworkspace\CaptchaTest\WebContent\WEB-INF\classes
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:19: warning: WaveFileWriter is internal proprietary API and may be removed in a future release
[javac] import com.sun.media.sound.WaveFileWriter;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint': class file for javax.validation.Constraint not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'regexp()' in type 'Pattern': class file for javax.validation.constraints.Pattern not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute': class file for javax.validation.OverridesAttribute not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Length.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/ModCheck.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/LuhnCheck.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Mod10Check.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Mod11Check.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/NotBlank.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/SafeHtml.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/ScriptAssert.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'regexp()' in type 'Pattern'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:19: warning: WaveFileWriter is internal proprietary API and may be removed in a future release
[javac] import com.sun.media.sound.WaveFileWriter;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:20: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.ImageFormatException;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:21: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGCodec;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:22: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGImageEncoder;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:17: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGCodec;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:18: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGImageEncoder;
[javac] ^
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint': class file for javax.validation.Constraint not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'regexp()' in type 'Pattern': class file for javax.validation.constraints.Pattern not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute': class file for javax.validation.OverridesAttribute not found
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Email.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Length.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/ModCheck.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/LuhnCheck.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Mod10Check.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/Mod11Check.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/NotBlank.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/SafeHtml.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/ScriptAssert.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'validatedBy()' in type 'Constraint'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'regexp()' in type 'Pattern'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'constraint()' in type 'OverridesAttribute'
[javac] C:\Oracle\Middleware\Oracle_Home\user_projects\domains\DevDomain\lib\hibernate-validator-5.1.3.Final.jar(org/hibernate/validator/constraints/URL.class): warning: Cannot find annotation method 'name()' in type 'OverridesAttribute'
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:20: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.ImageFormatException;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:21: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGCodec;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaTest.java:22: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGImageEncoder;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:17: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGCodec;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:18: error: package com.sun.image.codec.jpeg does not exist
[javac] import com.sun.image.codec.jpeg.JPEGImageEncoder;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:19: warning: WaveFileWriter is internal proprietary API and may be removed in a future release
[javac] import com.sun.media.sound.WaveFileWriter;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\ImageCaptchaServlet.java:32: warning: PixelConverter is internal proprietary API and may be removed in a future release
[javac] import sun.awt.image.PixelConverter.Bgrx;
[javac] ^
[javac] C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CaptchaVerifierServlet.java:45: error: cannot find symbol
[javac] b = CaptchaServiceInstance.getInstance().validateResponseForID( captchaId, inputChars );
[javac] ^
[javac] symbol: variable CaptchaServiceInstance
[javac] location: class CaptchaVerifierServlet
[javac] Note: C:\Users\pandabhi\eclipseworkspace\CaptchaTest\src\com\amgen\sharedservices\CustomListImageCaptchaEngine.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 6 errors
[javac] 49 warnings
BUILD FAILED
C:\Users\pandabhi\eclipseworkspace\CaptchaTest\build.xml:27: Compile failed; see the compiler error output for details.
Total time: 7 seconds
,varchar2(32767)
的最大长度为4000。因此,即使代码 运行,它也不会创建类型。
其次:运行PL / SQL代码时会对其进行验证/编译。但是当您使用动态SQL创建类型时,PL / SQL编译器在尝试编译行时无法看到这些类型:
varchar
这就是你所看到的错误。
在运行使用它们的PL / SQL代码之前,必须先创建类型。