TABLEMETADATAVERSION()

From Lianjapedia
Jump to: navigation, search

Purpose

Function to return a table's metadata version

Syntax

TABLEMETADATAVERSION([<cTable> | <nWorkarea>])

See Also

ACLASS(), ADDPROPERTY(), ALTER TABLE, AMEMBERS(), COLUMNMETADATA(), COMPOBJ(), CREATE TABLE, CREATEOBJECT(), DATABASEMETADATA(), DEFINE CLASS, DISPLAY CLASSES, DODEFAULT(), FOREACH, JSON_DECODE(), JSON_DECODE_FILE(), JSON_ENCODE(), Lianja MetaData API, LIST CLASSES, LOADOBJECT(), MetaData Editor, METADATA_DECODE(), METADATA_ENCODE(), METADATA_FINDTYPE(), NEWOBJECT(), OBJECT(), PRINT_JSON(), PRINT_HTML(), PRINT_R(), PRINT_XML(), REMOVEPROPERTY(), REQUIRE_ONCE(), SAVEOBJECT(), SQL SELECT, TABLEMETADATA()

Description

The TABLEMETADATAVERSION() function returns the metadata version for the current table as an integer. A table's metadata version is incremented by 1 each time a change is made to its metadata using the ALTER TABLE command or the MetaData Editor. If no metadata has been applied to the table or there is no table open in the current workarea, TABLEMETADATAVERSION() returns 0.

If the optional <cTable> | <nWorkarea> is specified, then the function will return the version from the specified table.

Argument Description
<cTable> A character string reference to one of the following:
- alias name of a currently open table
- name of a table in the currently open database
- database!table, which can be used whether the database is open or not
<nWorkarea> An integer workarea reference.

TABLEMETADATAVERSION() returns 0 if no metadata has been applied to the specified table or the table or workarea reference is not valid.

Example

open database southwind
use customers alias cust in 1
// Current table
? tablemetadataversion()
select 0
// By workarea
? tablemetadataversion(1)
// By alias
? tablemetadataversion("cust")
select cust
use
// Table in current database
? tablemetadataversion("customers")
close database
// Table in specified database
? tablemetadataversion("southwind!customers")
 
// setupUI.prg
// Compare to section.metaDataVersion
parameter id
local osection = Lianja.getElementByID(id)
 
// check to see if UI section attributes are same version as last time applied
// and if so do nothing (improves performance)
if osection.metaDataVersion = tableMetaDataVersion()
    return
endif
osection.metaDataVersion = tableMetaDataVersion()
local omd = metadata_decode(tableMetaData())
// ...