Difference between revisions of "TABLEMETADATAVERSION()"

From Lianjapedia
Jump to: navigation, search
(Created page with "==Purpose== ==Syntax== TABLEMETADATAVERSION() ==See Also== ACLASS(), ADDPROPERTY(), AMEMBERS(), COLUMNMETADATA(), COMPOBJ(), CREATEOBJECT(), DATAB...")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
+
Function to return a table's metadata version
  
 
==Syntax==
 
==Syntax==
TABLEMETADATAVERSION()
+
TABLEMETADATAVERSION([<cTable> | <nWorkarea>])
  
 
==See Also==
 
==See Also==
[[ACLASS()]], [[ADDPROPERTY()]], [[AMEMBERS()]], [[COLUMNMETADATA()]], [[COMPOBJ()]], [[CREATEOBJECT()]], [[DATABASEMETADATA()]], [[DEFINE CLASS]], [[DISPLAY CLASSES]], [[DODEFAULT()]], [[FOREACH]], [[JSON_DECODE()]], [[JSON_DECODE_FILE()]], [[JSON_ENCODE()]], [[LIST CLASSES]], [[LOADOBJECT()]], [[METADATA_DECODE()]], [[METADATA_ENCODE()]], [[METADATA_FINDTYPE()]], [[NEWOBJECT()]], [[OBJECT()]], [[PRINT_JSON()]], [[PRINT_HTML()]], [[PRINT_R()]], [[PRINT_XML()]], [[REMOVEPROPERTY()]], [[REQUIRE_ONCE()]], [[SAVEOBJECT()]], [[SQL SELECT]], [[SOCKET_CLOSE()]], [[SOCKET_LASTERROR()]], [[SOCKET_OPEN()]], [[SOCKET_PEEK()]], [[SOCKET_READ()]], [[SOCKET_SERVER()]], [[SOCKET_WRITE()]], [[TABLEMETADATA()]], [[WITH]], [[XML_DECODE_FILE()]]
+
[[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==
 
==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. 
 +
 +
{| class="wikitable" width="100%"
 +
!width="25%"|Argument||width="75%"|Description
 +
|-
 +
|valign=top|<cTable>||A character string reference to one of the following:<br>- alias name of a currently open table<br>- name of a table in the currently open database<br>- 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==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
 +
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())
 +
// ...
 
</code>
 
</code>
  
Line 21: Line 64:
 
[[Category:Lianja VFP Extensions]]
 
[[Category:Lianja VFP Extensions]]
 
[[Category:VFP Function Extensions]]
 
[[Category:VFP Function Extensions]]
 +
[[Category:Lianja v3.4]]

Latest revision as of 10:09, 5 April 2017

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())
// ...