|
|
|
|
|
- Physical data file associated with an alias
- Canceling the aliases of one or more data files
- Alias and queries
- Handling the alias file and its items
- Changing the directory or modifying the connection
- Previous versions
HAlias (Function) In french: HAlias
Not available with this kind of connection
Creates a logical alias of a data file (or query) or cancels all existing aliases. The alias can also be canceled by HCancelAlias. Reminder: An alias allows you to work on different physical data files that have the same logical description. For a data file for example, the file description is performed in the analysis and HAlias is used to create the file alias. Remark: This help page explains how to create an alias with HAlias. Starting with version 27, you can use Alias variables. This type of variable makes it easier to create and handle aliases.
OrderCheck is Data Source <description=Order>
IF HAlias(Order, OrderCheck) = True THEN
HChangeName(OrderCheck, Order.PhysicalName)
ELSE
Error("Failure creating the alias", HErrorInfo())
RETURN
END
Syntax
<Result> = HAlias(<Data file> [, <Alias>])
<Result>: Boolean - True if the alias was created,
- False if a problem occurs. HError is used to identify the error.
<Data file>: Character string Logical name of data file (defined in the analysis) or name of query (created with the query editor). If this parameter corresponds to "*", all the aliases defined in the current application are canceled. The corresponding data files are automatically closed. <Alias>: Optional character string or data source Name of alias, used to define the alias structure. If this parameter is not specified, all the aliases created for <Data file> are canceled. The corresponding data files are closed. To optimize your applications, it is recommended to use a variable of type Data source (see example). Remarks Physical data file associated with an alias By default, the name specified for the alias is assigned to the physical data file corresponding to the alias. Canceling the aliases of one or more data files The cancellation of an alias ( HCancelAlias) closes the associated data file. To cancel the aliases of a data file, all you have to do is use HAlias without specifying the alias name. To cancel all the aliases defined on all the data files of current project, all you have to do is use the following syntax: Alias and queries - If the query was created through programming (HExecuteSQLQuery), all you have to do is create the alias query with this same function while specifying the alias name.
- If the query was created by the report editor, to create an alias, you must:
- run the initial query.
- use HAlias and specify the query name as well as the alias name.
- use HExecuteQuery with the alias query. The alias is initialized.
For example:
QueryAlias is Data Source
HAlias(QRY_Query1, QueryAlias)
HExecuteQuery(QueryAlias)
Remark: When creating the alias, the initial query must have been run. Example:
QueryAlias is Data Source
IF HExecuteQuery(QRY_Query1) = False THEN
Error(HError(hErrCurrent))
ELSE
HReadFirst(QRY_Query1)
Trace(QRY_Query1.City)
HAlias(QRY_Query1, QueryAlias)
IF HExecuteQuery(QueryAlias) = False THEN
Error(HError(hErrCurrent))
ELSE
FOR EACH AliasQuery
Trace(QueryAlias.City)
END
END
END
Handling the alias file and its items - To avoid the "Unknown identifier" error when using an alias file and its items, it is recommended to use a Data source variable to declare the name of the alias before using HAlias.
For example:
Order2018 is Data Source
HAlias(Order, Order2018)
Caution: the Extern keyword can be used but it slows down the execution significantly. - In HReadSeek, HReadFirst, HReadNext, ... the name of the alias item cannot be used directly: the name of the item must be enclosed in quotes.
For example:
HReadSeekFirst(srcAlias, "KeyItem", "Sought Value")
- The name of the data source must not be used in quotation marks, if Automatic naming of data sources is enabled in the project description window.
- In the window or page editor, controls cannot be directly bound to the items of the alias files. You must:
- assign a value to each control in the code.
- use the ControlAlias function or the DataBinding property before calling:
Example:
ControlAlias(Control, srcAlias)
OR
ControlAlias(GR_ControlGroup, srcAlias)
OR
ControlAlias(WIN_Window, srcAlias)
OR
EDT_CustomerName.DataBinding = "SrcAlias.CustomerName"
- The alias files can be handled by HListItem and HListKey. The alias files can be re-indexed.
- By default, the password of an alias file is identical to the password of the initial data file. This password can be changed using HPass. The name of the data file used in this function corresponds to the name of the alias.
- The automatic modification of the data files can be applied to the alias files.
- The locks performed on the data files or on the records are effective between the aliases of the same instance of an application.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|