PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • 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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Creates a logical alias of 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.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
// Data Source variable to handle the alias after its creation
OrderCheck is Data Source <description=Order>
// New feature of version 19:
// <description=Order> is used to get the code completion
// for the items found in the Order file

// Create an alias for the "Order" file
IF HAlias(Order, OrderCheck) = True THEN
// "OrderCheck" can now be used in processes.
// It behaves like the "Order" file described in the analysis.
// By default, the name of the associated physical file corresponds to
// the name of the data source, therfore "OrderCheck" in this case
// To handle the same physical file as the initial one, the name must be modified:
   HChangeName(OrderCheck, Order..PhysicalName)
    // To use a file on another database or in another directory,
// you must use HChangeConnection or HChangeDir
ELSE
   Error("Failure creating the alias", HErrorInfo())
   RETURN
END
Order2013 is Data Source
// Create an alias for the "Order" file
IF HAlias(Order, Order2013) = True THEN
// "Order2013" can now be used in processes.
// It behaves like the "Order" file described in the analysis.
// Name of the associated physical file: default name Order2013.
HCreationIfNotFound(Order2013)
END
Syntax
<Result> = HAlias(<Logical Name> [, <Alias Name>])
<Result>: Boolean
  • True if the alias was created,
  • False if a problem occurred. HError is used to identify the error.
<Logical Name>: Character string (with or without quotes)
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 Name>: Optional character string (with quotes) or data source
Name of alias, used to define the alias structure. If this parameter is not specified, all the aliases created for the <Logical Name> file are canceled. The corresponding data files are closed.
To optimize the performance of your applications, we recommend that you use a data source variable (see the example).
OLE DBNative Accesses The <Alias Name> file is using the connection parameters of <Logical Name> file (parameters defined in the analysis).
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.
To associate the alias with a physical data file of different name, you must use HChangeConnection, HChangeName and HChangeDir.

Canceling the aliases of one or more data files

The cancelation 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:
HAlias("*")

Alias and queries

  • If the query was created by 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)

    Note: 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, we recommend that you use a data source variable to declare the alias name before using HAlias.
    For example:
    Orders2000 is Data Source
    HAlias(Orders, Orders2000)

    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")
  • In the window editor or in the page editor, the controls cannot be directly associated with the items of the alias files. You must: Example:
    ControlAlias(Control, srcAlias)
    OR
    ControlAlias(GR_ControlGroup, srcAlias)
    OR
    ControlAlias(WIN_Window, srcAlias)
    OR
    EDT_CustomerName..FileLink = "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 modified by 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.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadWindows MobileUniversal Windows 10 AppJavaAjaxUser code (UMC)External languageHFSQLHFSQL Client/ServerStored proceduresOLE DBNative Accesses

Changing the directory or modifying the connection

If HChangeDir or HConnect have been used with the initial file, these changes are ignored by the <Alias Name> file.
Once an alias was created, we recommend that you use HConnect to define the connection parameters on the alias file.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Windows Mobile wp230hf.dll
Java wd230java.jar
Linux wd230hf.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment