跳到主要内容 跳到补充内容

Load

LOAD 语句可以加载以下来源的字段:文件、脚本中定义的数据、预先载入的输入表格、网页、后续 SELECT 语句产生的结果或自动生成的数据。

语法:  

LOAD [ distinct ] fieldlist

[( from file [ format-spec ] |

from_field fieldassource [format-spec]

inline data [ format-spec ] |

resident table-label |

autogenerate size )]

[ where criterion | while criterion ]

[ group_by groupbyfieldlist ]

[order_by orderbyfieldlist ]

参数:  

Load arguments
Argument Description
distinct

You can use distinct as a predicate if you only want to load unique records. If there are duplicate records, the first instance will be loaded.

If you are using preceding loads, you need to place distinct in the first load statement, as distinct only affects the destination table.

fieldlist fieldlist ::= ( * | field {, field } )

A list of the fields to be loaded. Using * as a field list indicates all fields in the table.

field ::= ( fieldref | expression ) [as aliasname ]

The field definition must always contain a literal, a reference to an existing field, or an expression.

fieldref ::= ( fieldname |@fieldnumber |@startpos:endpos [ I | U | R | B | T] )

fieldname is a text that is identical to a field name in the table. Note that the field name must be enclosed by straight double quotation marks or square brackets if it contains e.g. spaces. Sometimes field names are not explicitly available. Then a different notation is used:

@fieldnumber represents the field number in a delimited table file. It must be a positive integer preceded by "@". The numbering is always made from 1 and up to the number of fields.

@startpos:endpos represents the start and end positions of a field in a file with fixed length records. The positions must both be positive integers. The two numbers must be preceded by "@" and separated by a colon. The numbering is always made from 1 and up to the number of positions. In the last field, n is used as end position.

  • If @startpos:endpos is immediately followed by the characters I or U, the bytes read will be interpreted as a binary signed (I) or unsigned (U) integer (Intel byte order). The number of positions read must be 1, 2 or 4.
  • If @startpos:endpos is immediately followed by the character R, the bytes read will be interpreted as a binary real number (IEEE 32-bit or 64 bit floating point). The number of positions read must be 4 or 8.
  • If @startpos:endpos is immediately followed by the character B, the bytes read will be interpreted as a BCD (Binary Coded Decimal) numbers according to the COMP-3 standard. Any number of bytes may be specified.

expression can be a numeric function or a string function based on one or several other fields in the same table. For further information, see the syntax of expressions.

as is used for assigning a new name to the field.

from

from is used if data should be loaded from a file.

file ::= [ path ] filename

  • absolute

    示例: c:\data\

  • relative to the QlikView document path.

    示例: data\

  • URL address (HTTP or FTP), pointing to a location on the Internet or an intranet. The URL must be URL encoded, for example, if it contains space characters.

    示例: http://www.qlik.com

    示例: http://www.enterprise.com/project%20files (http://www.enterprise.com/project files)

If the path is omitted, QlikView searches for the file in the directory specified by the Directory statement. If there is no Directory statement, QlikView searches in the working directory, which is usually the directory in which the QlikView file is located.

信息注释In a QlikView server installation, the default working directory is C:\ProgramData\QlikTech\Documents. The default working directory can be modified in the QlikView 管理控制台.

The filename may contain the standard DOS wildcard characters ( * and ? ). This will cause all the matching files in the specified directory to be loaded.

format-spec ::= ( fspec-item { , fspec-item } )

The format specification consists of a list of several format specification items, within brackets.

Directory

From

from_field from_field is used if data should be loaded from a previously loaded field.

fieldassource::=(tablename, fieldname)

The field is the name of the previously loaded tablename and fieldname.

format-spec ::= ( fspec-item {, fspec-item } )

The format specification consists of a list of several format specification items, within brackets.

inline inline is used if data should be typed within the script, and not loaded from a file.

data ::= [ text ]

通过 inline 子句输入的数据必须用特定字符括起来 - 方括号、引号或反引号。括号之间的文本以同一方式被解释为文件的内容。因此,当您需要在文本文件中插入新的一行时,您应该在 inline 子句文本中重复该操作:键入脚本时按压输入键。

在简单的内联加载中,列的数量由第一行定义。

format-spec ::= ( fspec-item {, fspec-item } )

You can customize the inline load with many of the same format specification items that are available for other loaded tables. These items are listed in brackets. For more information, see 格式规格项目.

For more information about inline loads, see 从内联表加载数据.

resident 如果需要从之前加载的表格加载数据,则使用 resident 语句。

table label is a label preceding the LOAD or SELECT statement(s) that created the original table. The label should be given with a colon at the end.

When using a combination of distinct and resident load statements in QlikView 12.00 or later, the data load order is different from QlikView 11.20. To define a desired load order, add a order by clause.

从之前加载的表格中加载数据

表格标签

autogenerate autogenerate is used if data should be automatically generated by QlikView.

size ::= number

Number is an integer indicating the number of records to be generated. The field list must not contain expressions which require data from a database. Only constants and parameter-free functions (such as rand() or recno()), are allowed in the expressions.

extension

You can load data from analytic connections. You need to use the extension clause to call a function defined in the server-side extension (SSE) plugin, or evaluate a script.

You can send a single table to the SSE plugin, and a single data table is returned. If the plugin does not specify the names of the fields that are returned, the fields will be named Field1, Field2, and so on.

Extension pluginname.functionname( tabledescription );

  • Loading data using a function in an SSE plugin

    tabledescription ::= (table { ,tablefield} )

    If you do not state table fields, the fields will be used in load order.

  • Loading data by evaluating a script in an SSE plugin

    tabledescription ::= ( script, table { ,tablefield} )

Data types are automatically detected in analytic connections. If the data has no numeric values and at least one non-NULL text string, the field is considered as text. In any other case it is considered as numeric.

You can force the data type by wrapping a field name with String() or Mixed().

  • String() forces the field to be text. If the field is numeric, the text part of the dual value is extracted, there is no conversion performed.
  • Mixed() forces the field to be dual.

String() or Mixed() cannot be used outside extension table field definitions, and you cannot use other QlikView functions in a table field definition.

For creating an analytic connection in QlikView Server or QlikView Desktop, see: Analytic connections

You can read more about analytic connections in the GitHub repository. qlik-oss/server-side-extension

where where is a clause used for stating whether a record should be included in the selection or not. The selection is included if criterion is True.

criterion is a logical expression.

while

while is a clause used for stating whether a record should be repeatedly read. The same record is read as long as criterion is True. In order to be useful, a while clause must typically include the IterNo( ) function.

criterion is a logical expression.

group_by

group by 是用于定义应聚合(组合)的字段的子句。 The aggregation fields should be included in some way in the expressions loaded. No other fields than the aggregation fields may be used outside aggregation functions in the loaded expressions.

groupbyfieldlist ::= (fieldname { ,fieldname } )

order_by order by is a clause used for sorting the records of a resident table before they are processed by the load statement. The resident table can be sorted by one or more fields in ascending or descending order. The sorting is made primarily by numeric value and secondarily by national collation order. This clause may only be used when the data source is a resident table.

The ordering fields specify which field the resident table is sorted by. The field can be specified by its name or by its number in the resident table (the first field is number 1).

orderbyfieldlist ::= fieldname [ sortorder ] { , fieldname [ sortorder ] }

sortorder is either asc for ascending or desc for descending. If no sortorder is specified, asc is assumed.

fieldname, path, filename and aliasname are text strings representing what the respective names imply. Any field in the source table can be used as fieldname. However, fields created through the as clause (aliasname) are out of scope and cannot be used inside the same load statement.

If no source of data is given by means of a from, inline, resident, from_field or autogenerate clause, data will be loaded from the result of the immediately succeeding SELECT or LOAD statement. The succeeding statement should not have a prefix.

前置 LOAD

示例:  

了解详情

 

本页面有帮助吗?

如果您发现此页面或其内容有任何问题 – 打字错误、遗漏步骤或技术错误 – 请告诉我们!

加入分析现代化计划

Remove banner from view

使用分析现代化计划实现现代化,同时不损害您宝贵的 QlikView 应用程序。 单击此处 了解更多信息或联系: ampquestions@qlik.com