Oracle access to RTF documents in Delphi

Source: Internet
Author: User

relational databases provide storage and extraction of large documents. For video materials, audio materials, image data and other large documents, generally need to open up a field to store summary information, so in query and retrieval without access to big segments, but only in the storage and extraction of characters before operation.

For example, you cannot query for a like preposition in a long raw type in Oracle, and you cannot use the equal sign "=" Query. This is very inconvenient for storing large pieces of text (more than 2K) while requiring full-text search. This article describes how to access and query large segments of text using the string data type of the database. This is an example of Oracle database and Delphi applications, highlighting how to access RTF documents in a database.

For plain text, you can simply split it into several strings and store it in the varchar (2000) field. You can use like comparisons when querying to achieve full-text search purposes. In order to preserve paragraph information such as newline, the carriage return line (#13 #10) should also be saved as part of the string. Data entry can provide memo control (not dbmemo) for input, and then sequentially connected to each row, when connected to a string of 2000 characters (Single-byte characters) length, save a record, and then repeat the operation on the remaining rows. In this way, the plain text is eventually saved in a varchar (2000) field that has no more than 2000 lengths. There needs to be a separate field. Used to store text numbers and sub ordinals to distinguish between different text and to connect all substrings sequentially when reading text. When you query plain text, you can use like or use the equal sign "=" (almost no use) as you would query a normal varchar field. It is important to note that the keywords that may be provided by the user are stored in a different substring and are not queried. Therefore, you should consider storing duplicate strings at design time. For example, only the first 1900 characters in each substring are valid characters, and the last 100 characters are used to store the first 100 characters of the next substring. This avoids the case where the keyword is separated. The only disadvantage is that the query keyword must be restricted to 100 characters (50 characters), but this is normal and not enough.

In fact, this technique can also be used to access and query RTF documents. At this point, the RichEdit control (not dbrichedit) is used to enter and display RTF documents, and is no longer a memo control. Access to RTF documents cannot be manipulated as plain text through memo properties Lines.strings[index] (although the RichEdit control has the same properties), because it cannot save the document's format. There are two ways to take advantage of RichEdit: SaveToFile and LoadFromFile. It is important to understand that the RTF file uses a plain character to describe the various formatting and content information, such as font, font size, text, and so on. As a result, storage and extraction can be manipulated as plain text. But for the query, it can not be directly with like add keyword way. Because each Chinese character in an RTF document is stored with a special representation, only single-byte characters are stored as-is. Therefore, when the query to the keyword processing to be used in query statements.

Before testing This example, you must have the following data structure, which is given in the form of an Oracle SQL statement to create a table:

(*
CREATE TABLE TEST( { 表名为 TEST }
DOCID NUMBER NOT NULL, { 文档编号 }
DOCNAME VARCHAR(40) NOT NULL, { 文档标题 }
SUBID NUMBER NOT NULL, { 文档子编号 }
TEXT VARCHAR(2000) NOT NULL, { 子文档内容 }
PRIMARY KEY(DOCID, SUBID)); { 联合主键 }
*)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.