ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • 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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Creates a logical alias of a data file (or a query). The alias can be canceled using HCancelAlias.
Reminder An alias allows you to work on different physical data files with the same logical description. For a data file for example, the file description is performed in the analysis and <Source>.Alias is used to create the file alias.
Note This help page describes how to create an alias using the function <Source>.Alias. Starting with version 27, you can use Alias variables. This type of variable makes it easier to create and handle aliases.
Example
// Variable source de données pour manipuler l'alias après sa création
CommandeVerification is Data Source <description=Commande>
// Nouveauté de la version 19 : 
// <description=Commande> permet d'obtenir la complétion de code 
// pour les rubriques du fichier de données Commande

// Création d'un alias du fichier de données "Commande"
IF Commande.Alias(CommandeVerification) = True THEN
	// "CommandeVerification" peut maintenant être utilisé dans les traitements.
	// Il se comporte comme le fichier "Commande" décrit dans l'analyse.
	// Par défaut, le nom du fichier physique associé correspond 
	// au nom de la source de données donc ici "CommandeVerification"
	// Pour manipuler le même fichier physique que celui d'origine, il faut modifier le nom :
    CommandeVerification.ChangeNom(Commande.NomPhysique)
    	// Pour utiliser un fichier sur une autre base de données ou dans un autre répertoire,
	// il faut ensuite utiliser la fonction <Source>.ChangeConnexion ou la fonction <Source>.ChangeRep
ELSE
    Error("Echec de la création de l'alias", HErrorInfo())
    RETURN
END
Syntax
<Result> = <Source>.Alias([<Alias>])
<Result>: Boolean
  • True if the alias was created,
  • False if a problem occurs. HError is used to identify the error.
<Source>: Type corresponding to the specified source
Logical name of data file (defined in the analysis) or name of query (created with the query editor).
<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 <Source> 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).
Native Connectors (Native Accesses) The <Alias> file uses the connection parameters of <Source> (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 <Source>.ChangeConnection, <Source>.ChangeName and <Source>.ChangeDir.

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 <Source>.Alias without specifying the alias name.

Alias and queries

  • If the query was created through programming (<Source>.ExecuteSQLQuery), 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 <Source>.Alias and specify the query name as well as the alias name.
    • use <Source>.ExecuteQuery with the alias query. The alias is initialized.
    For example:
    AliasRequête is Data Source
    REQ_Requête1.Alias(AliasRequête)
    AliasRequête.ExecuteQuery()

    Note When creating the alias, the initial query must have been executed.
    Example:
    AliasRequête is Data Source 
    IF REQ_Requête1.ExécuteRequête() = False THEN
    	Error(HError(hErrCurrent)) 
    ELSE
    	REQ_Requête1.LitPremier()
    	Trace(REQ_Requête1.Ville)
    	REQ_Requête1.Alias(AliasRequête)
    	IF AliasRequête.ExecuteQuery() = False THEN
    		Error(HError(hErrCurrent)) 
    	ELSE
    		FOR EACH AliasRequête
    			Trace(AliasRequête.Ville)
    		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 <Source>.Alias.
    For example:
    Commande2018 is Data Source
    Commande.Alias(Commande2018)

    Warning: use of the keyword External keyword is possible, but causes a significant slowdown at runtime.
  • In functions <Source>.ReadSeek, <Source>.ReadFirst, <Source>.ReadNext, ... the alias field name cannot be used directly: the field name must be enclosed in quotation marks.
    For example:
    srcAlias.ReadSeekFirst("RubriqueClé", "Valeur Recherchée")
  • 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: Example:
    ControlAlias(Champ, srcAlias)
    OR
     ControlAlias(GR_GroupeDeChamp, srcAlias)
    OR
     ControlAlias(FEN_Fenêtre, srcAlias)
    OR
     SAI_NomClient.LiaisonFichier = "SrcAlias.NomClient"
  • The alias files can be handled by <Source>.ListItem and <Source>.ListKey. 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 <Source>.Password. 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.
iPhone/iPadIOS WidgetMac CatalystStored procedures

Changing the directory or modifying the connection

If <Source>.ChangeDir or HConnect have been used with the initial data file, these changes are ignored for the <Alias> data file.
Once an alias was created, we recommend that you use <Source>.ChangeConnection to define the connection parameters on the alias file.
Component: wd300hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/04/2024

Send a report | Local help