Difference between revisions of "SQLCHECKUNIQUE()"

From Lianjapedia
Jump to: navigation, search
(Created page with "''Under Construction'' ==Purpose== Function to check whether a column value is unique ==Syntax== SQLCHECKUNIQUE(<cTable>, <cKeyField>, <cKeyValue>) ==See Also== KEYLOOKUP...")
 
Line 1: Line 1:
''Under Construction''
 
 
 
==Purpose==
 
==Purpose==
Function to check whether a column value is unique
+
Function to check whether a prospective column value is unique
  
 
==Syntax==
 
==Syntax==
SQLCHECKUNIQUE(<cTable>, <cKeyField>, <cKeyValue>)
+
SQLCHECKUNIQUE(<cTable>, <cKeyField>, <cKeyValue>[, <lAllowblank>[, <lAllownull>]])
  
 
==See Also==
 
==See Also==
Line 11: Line 9:
  
 
==Description==
 
==Description==
The SQLCHECKUNIQUE() function checks the uniqueness of a column value.  The function will auto-detect if the specified table is a native Lianja table or a Virtual Table and act accordingly.
+
The SQLCHECKUNIQUE() function checks the uniqueness of a prospective column value.  The function will auto-detect if the specified table is a native Lianja table or a Virtual Table and act accordingly.
  
 
You should always provide a fully qualified database!table if your app is to work in Web/Mobile e.g "southwind!employees".
 
You should always provide a fully qualified database!table if your app is to work in Web/Mobile e.g "southwind!employees".
 +
 +
The numeric return value is 1 if the cKeyValue value already exists and 0 if it does not already exist in the cKeyField table column.
  
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
Line 23: Line 23:
 
|-
 
|-
 
|valign="top"|cKeyValue||Character expression containing the value to be compared against cKeyField.  If this is a character field then enclose it in quotes within quotes: " 'string' ".  If it is a numeric then enclose it like this "1".
 
|valign="top"|cKeyValue||Character expression containing the value to be compared against cKeyField.  If this is a character field then enclose it in quotes within quotes: " 'string' ".  If it is a numeric then enclose it like this "1".
 +
|-
 +
|valign="top"|lAllowblank||Logical expression specifying whether blank values should be ignored.
 +
|-
 +
|valign="top"|lAllownull||Logical expression specifying whether null values should be ignored.
 
|-
 
|-
 
|}
 
|}
Line 28: Line 32:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
 
+
// Character cKeyfield
 +
nCustIDUnique = sqlcheckunique("southwind!customers","customerid","'ALFKI'")
 +
// Numeric cKeyfield
 +
nEmpIDUnique = sqlcheckunique("southwind!employees","employeeid","3")
 
</code>
 
</code>
  

Revision as of 04:48, 24 April 2020

Purpose

Function to check whether a prospective column value is unique

Syntax

SQLCHECKUNIQUE(<cTable>, <cKeyField>, <cKeyValue>[, <lAllowblank>[, <lAllownull>]])

See Also

KEYLOOKUP(), LOOKUP(), RLOOKUP(), SEEK(), SET RELATION, SQLLOOKUP()

Description

The SQLCHECKUNIQUE() function checks the uniqueness of a prospective column value. The function will auto-detect if the specified table is a native Lianja table or a Virtual Table and act accordingly.

You should always provide a fully qualified database!table if your app is to work in Web/Mobile e.g "southwind!employees".

The numeric return value is 1 if the cKeyValue value already exists and 0 if it does not already exist in the cKeyField table column.

Keywords Description
cTable Character expression to specify the table to be checked (native or Virtual Table).
cKeyField Character expression to specify the column in the table to be checked.
cKeyValue Character expression containing the value to be compared against cKeyField. If this is a character field then enclose it in quotes within quotes: " 'string' ". If it is a numeric then enclose it like this "1".
lAllowblank Logical expression specifying whether blank values should be ignored.
lAllownull Logical expression specifying whether null values should be ignored.

Example

// Character cKeyfield
nCustIDUnique = sqlcheckunique("southwind!customers","customerid","'ALFKI'")
// Numeric cKeyfield
nEmpIDUnique = sqlcheckunique("southwind!employees","employeeid","3")