invantive-dokumentationen del af invantive cloud
Invantive Support ForumsLog ind / Tilmeld dig

SQL_VARIANT

Syntaks

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> SQL_VARIANT[SQL_VARIANT]:::quoted
    SQL_VARIANT --> End((END))

Formål

The SQL_VARIANT SQL function gets a property of a value, similar to the SQL_VARIANT_PROPERTY function of SQL Server. The following properties are available:

  • DotnetDataType: the .NET data type of the value.
  • BaseType: the database data type of the value.
  • Precision: the precision of the value.
  • Scale: the scale of the value.
  • TotalBytes: the number of bytes of the value.
  • MaxLength: the maximum length of the value in bytes.

Parametre:

  • Value (ANY): the value to get the property of.
  • Property (varchar2): the name of the property. Must be a constant.

Returns: the value of the property; the data type depends on the property.

Eksempler

The following example retrieves the precision of an integer value:

select sql_variant(5, 'Precision')

-------------------
0

The following example retrieves the precision of a date/time value:

select sql_variant(sysdate, 'Precision')

-------------------
23

The following example retrieves the number of a bytes of true:

select sql_variant(true, 'TotalBytes')

-------------------
1