`
javathinker
  • 浏览: 227006 次
  • 来自: ...
文章分类
社区版块
存档分类
最新评论

DB2 -314 SQL0314N The host variable XXX is incorrectly 处理

 
阅读更多

SQC


SQL长度超过32K,预编译失败,报错信息如下:


LINE MESSAGES FOR tbl_datamart_trans_log.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
33 SQL0314N The host variable "sSql" is incorrectly declared.
SQL0095N No bind file was created because of previous
errors.
SQL0092N No package was created because of previous
errors.
SQL0091W Precompilation or binding was ended with "3"
errors and "0" warnings.


发生错误是因为 DB2 字符串不应该大于 32672 字节。


SQL0314N错误信息说明:


DB2 V9.5 for Linux, UNIX, and Windows

SQL0314N

不正确地声明了主变量名称

说明

因为下列其中一种原因,未正确地声明主变量名称
  • 指定的类型不是受支持的类型。
  • 长度规范是 0、负数或太大。
  • 使用了初始化程序。
  • 指定了不正确的语法。

变量仍未定义。

用户响应

确保仅正确地指定了数据库管理器支持的声明。

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.messages.sql.doc/doc/msql00314n.html



示例代码:



大小超过 32672 的主机变量示例


#include<stdio.h>

EXEC SQL INCLUDE SQLCA;

int test_ArraySize(void)
{
EXEC SQL BEGIN declare SECTION;
char ResumeData[65533];
EXEC SQL END declare SECTION;

EXEC SQL select RESUME
INTO :ResumeData
FROM EMP_RESUME
WHERERESUME_FORMAT = 'ascii';

return SUCCESS;
}



如果试图像 这样用 db2 prep 预编译器编译此程序,将会返回一个错误。


编译上述程序之后返回的错误:

db2 prep test4.sqc

LINE MESSAGES FOR test4.sqc
--------------------------------------------------------------------------
SQL0060WThe "C" precompiler is in progress.
8 SQL0314NThe host variable "ResumeData" is incorrectly
declared.
SQL0092NNo package was created because of previous
errors.
SQL0091WPrecompilation or binding was ended with "2"
errors and "0" warnings.



发生错误是因为 DB2 字符串不应该大于 32672 字节。任何更长的数据都必须表示为一个 CLOB 数据类型。


处理方法:


要解决这个错误,需要对大于 32672 的主机变量使用以下语法:


用于较大主机变量的语法

EXEC SQL BEGIN declare SECTION;
SQL TYPE IS CLOB (65533) ResumeData;
EXEC SQL END declare SECTION;


然后可以继续操作:

正确声明主机变量之后程序被成功编译

db2 prep test4.sqc

LINE MESSAGES FOR test4.sqc
--------------------------------------------------------------------------
SQL0060WThe "C" precompiler is in progress.
SQL0091WPrecompilation or binding was ended with "0"
errors and "0" warnings.

警告:现在,尽管 DB2 预编译成功了,但是还会碰到编译问题,因为最初的 char *ResumeData 已经被转换为 struct { int length; char *data; } ResumeData;。 必须管理数据和长度属性,这很可能需要更改代码。

分享到:
评论

相关推荐

    微软内部资料-SQL性能优化3

    If a row is locked, SQL Server will apply intent locks at both the page and the table level. If a page is locked, SQL Server will apply an intent lock at the table level. SIX locks imply that we have...

    微软内部资料-SQL性能优化5

    The only source of any storage location information is the sysindexes table, which keeps track of the address of the root page for every index, and the first IAM page for the index or table....

    win10 codeblocks安装mingw-w64时出现the file has been downloaded incorrectly问题解决-附件资源

    win10 codeblocks安装mingw-w64时出现the file has been downloaded incorrectly问题解决-附件资源

    Oracle sqldeveloper without jdk (win+linux)

    - The script to which the character belongs is supported by the JRE installation on which SQL Developer is running � for example, appropriate fonts are available � and - The script does not ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache ...

    Bochs - The cross platform IA-32 (x86) emulator

    The default stepping value is 3. - Added ability to disable MONITOR/MWAIT support through .bochsrc CPUID option. The option is available only if compiled with --enable-monitor-mwait configure ...

    Senfore_DragDrop_v4.1

    This is believed to be a bug in the Windows clipboard and a work around hasn't been found yet. * Asynchronous targets appears to be broken in the current release. * When TDropFileTarget....

    Turbo C++ 3.0[DISK]

    assistance, help is available from the following sources: 1. Type GO BPROGB on the CompuServe bulletin board system for instant access to the Borland forums with their libraries of technical ...

    Turbo C++ 3.00[DISK]

    assistance, help is available from the following sources: 1. Type GO BPROGB on the CompuServe bulletin board system for instant access to the Borland forums with their libraries of technical ...

    MS-DOS 5.0

    Until the upgrade is available, you can either install MS-DOS 5.0 on floppy disks or delete Vfeature partitions by repartitioning your hard disk. To install MS-DOS 5.0 on floppy disks, run Setup ...

    webwizforums 7.7 SQL 版

    functions_date_time_format.asp - the date and time formatting data is now feed into an array to cut down on database calls 4. date_time_configure.asp - updated to support new application level ...

    Git-2.21.0-64-bit.zip

    recorded for the origin of the clone, but this incorrectly used a hardcoded name "origin" to name that remote; it has been corrected to honor the "--origin &lt;name&gt;" option. * "git fetch" into a ...

    acpi控制笔记本风扇转速

    could be incorrectly generated if the parent ResourceTemplate pathname places the template within a different namespace scope than the current scope. (BZ 7212) Fixed a problem where the compiler ...

    BURNINTEST--硬件检测工具

    port locks up in the Operating System, the error is still reported. - Corrected a bug, where in rare cases, the result summary could be duplicated in a log file. - Updated license management, in ...

    DevExpress VCL 12.2.6(v2012vol2.6) 源码-例子-帮助-part1

    Q490502 - Chart View - Stacked column/bar diagrams incorrectly visualize negative values if the diagram AxisValue.MinMaxValues property is set to mmvAuto Q487902 - Documentation - The ...

    DevExpress VCL 12.2.6(v2012vol2.6) 源码-例子-帮助-part2

    Q490502 - Chart View - Stacked column/bar diagrams incorrectly visualize negative values if the diagram AxisValue.MinMaxValues property is set to mmvAuto Q487902 - Documentation - The ...

    DevExpress VCL 13.1.4(v2013vol1.4) 源码-例子-帮助-part2

    B238476 - TcxButton is incorrectly painted in applications run via Remote Desktop if the Office11 paint style is applied and Windows themes are disabled Q524948 - TcxButton plays fading animation if ...

    DevExpress VCL 13.1.4(v2013vol1.4) 源码-例子-帮助-part1

    B238476 - TcxButton is incorrectly painted in applications run via Remote Desktop if the Office11 paint style is applied and Windows themes are disabled Q524948 - TcxButton plays fading animation if ...

    SQLPrompt_7.3.0.651(包含注册机)

    Whitespace at the end of the file is now maintained if "Preserve existing new lines between statements" is checked (UserVoice) Statements inside TRY/CATCH blocks are now formatted the same as BEGIN/...

Global site tag (gtag.js) - Google Analytics