|
Category: ASE: Functions: User, Login and Role Functions
valid_name()
The
system function
valid_name()
is an extension to
T-SQL.
The function validates, if the value specified in the parameter "character_expression" is a valid
identifier,
i.e. a valid name for
variables,
or
procedures,
for example. The system function valid_name returns 0 if the value specified in the
parameter "character_expression" is not a valid identifer, i.e. it contains
illegal characters or the name is longer than 30
bytes
or is contained in the list of
reserved words.
If the value specified in the parameter "character_expression" is a valid identifier,
the return value is not equal to 0, but an arbitrary number.
The optional parameter "maximum_length" (available in ASE® v15.0) specifies the maximum length
of the value in parameter "character_expression". If it is larger than the value given in parameter
"maximum_length", the function valid_name returns 0. If the identifier length is invalid, valid_name
returns a value greater than 0.
Syntax of the System Function valid_name
valid_name(character_expression[, maximum_length])
The parameters of the User Function valid_name()
character_expression
The parameter "character_expression" can be a
column name,
variable
or
constant
and must be of one of the
datatypes
char
varchar
nchar
or
nvarchar.
When using constants, these should be set in quotes.
maximum_length
The parameter "maximum_length" is an optional placeholder for an integer number,
with a range of values from 1 to 255. If the parameter "maximum_length" is not specified,
the default value of 30 is taken.
The parameter "maximum_length" is available in
ASE®
starting with version 15.0
Example for the System Function valid_name
select valid_name("anystring")
go
-----------
1
Returns 1, because the string is a valid identifier.
select valid_name("insert")
go
-----------
0
Returns 0. The identifier "insert" is a reserved word and thus no valid identifier.
See also:
ASE T-SQL - Aggregate Functions, ASE T-SQL - User, mut_excl_roles(), proc_role(), role_contain(), role_id(), role_name(), show_role(), suser_id(), suser_name(), user, user_id(), user_name(), valid_user().
|