Create a Struct from a Table


Structs in DataFlex can created simple. As example:

Struct tWebAppServerProps
    String  Key
    Date    CreateDate
    String  CreateTime
    Date    ExpiresDate
    String  ExpiresTime
    Integer Locked
    Date    LockedDate
    String  LockedTime
    Integer Page
    Integer Pages
    String  Data

It’s simple. Right? But what if you have to create a structure for a table with many columns? DataFlex incorporate a Query Tester that allows to script SQL queries like in Microsoft SQL Server Management Studio and generates the Struct automatically.

  1. First open the Query Tester.
  2. Write the SQL query for a requested table.
  3. Then press Struct generator that creates the follow:
Struct tWebAppSession
    { Name="SessionKey" }
    String  sSessionKey
    { Name="CreateDate" }
    Date    dCreateDate
    { Name="CreateTime" }
    String  sCreateTime
    { Name="LastAccessDate" }
    Date    dLastAccessDate
    { Name="LastAccessTime" }
    String  sLastAccessTime
    { Name="UseCount" }
    Integer iUseCount
    { Name="RemoteAddress" }
    String  sRemoteAddress
    { Name="LoginName" }
    String  sLoginName
    { Name="Active" }
    String  sActive

or disabling Use type prefix:

Struct tWebAppSession
    String  SessionKey
    Date    CreateDate
    String  CreateTime
    Date    LastAccessDate
    String  LastAccessTime
    Integer UseCount
    String  RemoteAddress
    String  LoginName
    String  Active
This post is licensed under CC BY 4.0 by the author.

Trending Tags