简体   繁体   English

将数据插入CLOB列

[英]Inserting data into a CLOB column

I'm trying to find a way to insert data on BLOB column. 我试图找到一种在BLOB列上插入数据的方法。

During my research, I found this example on IBM web site, and I don't understand what is a "regular file". 在研究过程中,我在IBM网站上找到了此示例,但我不理解什么是“常规文件”。

The title of this example is "This example shows how to insert data from a regular file referenced by :hv_text_file into a CLOB column" 该示例的标题是“此示例显示了如何将由:hv_text_file引用的常规文件中的数据插入到CLOB列中”

Is :hv_text_file a kind of variable containing the description of the file to insert in blob column? :hv_text_file是一种包含要在blob列中插入的文件说明的变量吗?

strcpy(hv_text_file.name, "/home/userid/dirname/filnam.1");
hv_text_file.name_length = 
strlen("/home/userid/dirname/filnam.1");
hv_text_file.file_options = SQL_FILE_READ; /* this is a ’regular’ 
file */
EXEC SQL INSERT INTO CLOBTAB
VALUES(:hv_text_file);

I assume you're looking at the Db2 SQL Programming reference: IBM i 7.2 > Database > Programming > SQL programming > Processing special data types > Large objects at https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/sqlp/rbafyexampinsertclob.htm 我假设您正在查看Db2 SQL编程参考:IBM i 7.2>数据库>编程> SQL编程>处理特殊数据类型>大对象, 网址https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/sqlp/ rbafyexampinsertclob.htm

This is a program fragment; 这是一个程序片段; it assumes that you have read and understand how to reference a LOB column: IBM i 7.2 > Database > Reference > SQL reference > Language elements > Variables at https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzreferencelob.htm 它假定您已阅读并理解如何引用LOB列:IBM i 7.2>数据库>参考> SQL参考>语言元素>变量位于https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzreferencelob热媒

There, you can see there are two types of LOB references: 1) LOB or XML locator variables 2) LOB of XML file reference variables 在那里,您可以看到两种类型的LOB引用:1)LOB或XML定位器变量2)XML文件引用变量的LOB

It looks like you want to move a stream file into a BLOB via a File reference variable. 看来您想通过File引用变量将流文件移动到BLOB中。 The quick summary is in the second link, but the answer to 'what is meant by regular file' is this bit: 快速摘要在第二个链接中,但是对于“普通文件的含义”的答案是:

File reference variables are currently supported in the root (/), QOpenSys, and UDFS file systems. 根(/),QOpenSys和UDFS文件系统当前支持文件引用变量。 When a file is created, it is given the CCSID of the data that is being written to the file. 创建文件后,将为它提供正在写入文件的数据的CCSID。 Currently, mixed CCSIDs are not supported. 当前,不支持混合CCSID。 To use a file created with a file reference variable, the file should be opened in binary mode. 要使用通过文件引用变量创建的文件,应以二进制模式打开文件。

So, 'regular file' means IFS stream file. 因此,“常规文件”是指IFS流文件。

The 'other half' of the program fragment that might help illustrate the example is in the SQL programming reference: IBM i 7.2 > Database > Programming > SQL programming > Processing special data types > Examples: Using UDTs, UDFs, and LOBs at https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/sqlp/rbafyexplob.htm 可以帮助说明该示例的程序片段的“另一半”位于SQL编程参考中:IBM i 7.2>数据库>编程> SQL编程>处理特殊数据类型>示例:在https上使用UDT,UDF和LOB : //www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/sqlp/rbafyexplob.htm

The keywords you need to keep in mind are 'LOB file reference variable'. 您需要记住的关键字是“ LOB文件参考变量”。

If you're an RPG programmer, look for the SQLTYPE() keyword on the DCL-S statement https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzajp/rzajpirpglobfileref.htm 如果您是RPG程序员,请在DCL-S语句https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzajp/rzajpirpglobfileref.htm上查找SQLTYPE()关键字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM