Skip to content

MvOPENVIEW#


Opens an SQL VIEW on the NAMEed database based on the results of the query string. and are used to navigate the view.

Syntax
<MvOPENVIEW NAME = "string: {  expression } | literal"
            VIEW = "string: {  expression } | literal"
            QUERY = "string: {  expression } | literal"
            FIELDS = "{ expression } | variable list"> 

Attributes#

Attribute Description
NAME Optional Database alias. When a database is opened with MvOPEN, the database is referenced by the alias. If omitted, the primary database is assumed. The database must be open.
VIEW Required. Query records alias. When records are selected by the QUERY attribute, they are referenced in the navigation commands <MvGO>, or <MvSKIP> by the VIEW alias, NOT the NAME.
QUERY Required. The Query string used to access the records. For field variables used in the string, the question mark (e.g. ?) can be used as a placeholder, for FIELDS.
FIELDS Optional. A comma delimited list of literal field variables used in the QUERY string. For each ? found, a field variable will be substituted in sequence. (e.g. FIELDS = "l.var1, l.var2") Also a variable containing a list of literal field names can be used. (e.g. FIELDS = "{ l.fieldlist }")

Examples#

This example opens a MySQL database, opens a view that selects a particular table and record based on a product_code.

Notice: The records are accessed using the VIEW name (e.g. <MvOPENVIEW VIEW="Products"...) instead of the name used in the MvOpen Tag. (e.g. <MvOPEN NAME = "Merchant"...).

<MvOPEN NAME = "Merchant" DATABASE = "mydatabasefile@localhost" TYPE = "mysql"
        USERNAME = "{ l.username }" PASSWORD = "{ l.password }">

<MvASSIGN NAME = "l.query"
          VALUE = "{ 'SELECT * FROM Products WHERE code = ?' }">

<MvOPENVIEW NAME = "Merchant" VIEW = "Products" QUERY = "{ l.query }" FIELDS = "l.product_code">

<MvEVAL EXPR="{ 'Product Code: ' $ Products.d.code $ ' <br>' }">
<MvEVAL EXPR="{ 'Product Name: ' $ Products.d.name $ ' <br>' }">

In this example all active products are displayed in code order.

<MvASSIGN NAME = "l.query"
          VALUE = "{ 'SELECT * FROM Products WHERE active = 1 ORDER BY code ASC' }">

<MvOPENVIEW NAME = "Merchant" VIEW = "Products" QUERY = "{ l.query }">

<MvWHILE EXPR = "{ NOT Products.d.EOF }">
    <MvASSIGN NAME = "l.product_count" VALUE = "{ l.product_count + 1 }">
    <MvEVAL EXPR="{ 'Product Code: ' $ Products.d.code $ ', ' }">
    <MvEVAL EXPR="{ 'Product Name: ' $ Products.d.name $ ' <br>' }">

    <MvSKIP NAME = "Merchant" VIEW = "Products" ROWS = 1>
</MvWHILE>