Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » System Procedures » System procedures

sa_snapshots system procedure Next Page

sa_split_list system procedure


Takes a string of values, separated by a delimiter, and returns a set of rows—one row for each value.

Syntax

sa_split_list(
str
[, delim
[, maxlen ] ]
)

Arguments
Result set
Column nameData typeDescription
line_num INTEGERSequential number for the row.
row_valueCHARValue from the string, truncated to maxlen if required.
Remarks

The sa_split_list procedure can be used within other procedures to restrict a query to the result set of sa_split_list.

Permissions

None

Side effects

None

Examples

The following call formats the string 'yellow##blue##red' so that individual items appear on separate lines in the result set.

CALL sa_split_list( 'yellow##blue##red', '##', 3 );
line_numrow_value
1yel
2 blu
3red

In the following example, a procedure called ProductsWithColor is created. When called, the ProductsWithColor procedure uses sa_split_list to parse the color values specified by the user, looks in the Color column of the Products table, and returns the name, description, size, and color for each product that matches one of the user-specified colors.

The result of the procedure call below is the name, description, size, and color of all products that are either blue or white.

CREATE PROCEDURE ProductsWithColor( IN color_list LONG VARCHAR )
BEGIN
  SELECT Name,Description,Size,Color
  FROM Products
  WHERE Color IN ( SELECT row_value FROM sa_split_list( color_list ) )
END
GO

CALL ProductsWithColor( 'white, blue' )