# 22. Virtuoso Functions Guide - name_part

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
__any_grants
close
collation_define
complete_table_name
delay
end_result
exec
exec_next
exec_result
exec_result_names
identity_value
name_part
registry_get
registry_get_all
registry_name_is_pro...
registry_remove
registry_set
result
result_names
row_count
sequence_get_all
sequence_next
sequence_remove
sequence_set
set_identity_column
set_row_count
set_user_id
signal
sinv_create_inverse
sinv_create_key_mapp...
sinv_drop_inverse
sys_stat_analyze
sys_stat_histogram
table_drop_policy
table_set_policy
username
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## name_part

Returns portion of dotted name such as a fully qualified table name.
varchar name_part (in string varchar, in idx integer);
Description

The name_part() can be used to disecting parts of a three part names (string where items are divided by dots ".") such as table names or columns names. The table name "DB"."DBA"."SYS_USERS" contains three parts which can be extracted individually using this function providing the correct index from a 0 base: 0 would return "DB", 1 would return "DBA", 2 would return "SYS_USERS".

Parameters
string – The string to be disected.
idx – The part index starting from 0.
Return Types

A string will be returned containing the text from the specified index.

Errors

SQLState | Error Code | Error Text | Description
--- | --- | --- | ---
22023 | SR014 | Function name_part needs a string as argument 1, not an arg of type [type] |
22023 | SR008 | Function name_part needs an integer as argument 2, not an arg of type [type] |

Examples
Using the name_part() function

This simple example shows the 3 parts of a table name being retrieved using the name_part() function from ISQL.

    SQL> select name_part('"DB"."DBA"."SYS_TABLES"', 0);
    callret
    VARCHAR
    __________________________________________________________

    "DB"

    1 Rows. -- 20 msec.
    SQL> select name_part('"DB"."DBA"."SYS_TABLES"', 1);
    callret
    VARCHAR
    __________________________________________________________

    "DBA"

    1 Rows. -- 30 msec.
    SQL> select name_part('"DB"."DBA"."SYS_TABLES"', 2);
    callret
    VARCHAR
    __________________________________________________________

    SYS_TABLES"

    1 Rows. -- 20 msec.