23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PREFIX<br />

Syntax<br />

PREFIX<br />

Returns the substring of a character string, starting from the position specified by start_pos<br />

and ending before the specified character.<br />

PREFIX ( char_expression , start_pos , char_expression )<br />

char_expression<br />

Evaluates to a character string, typically a character-string literal or column name. If the<br />

expression evaluates to NULL, PREFIX returns NULL.<br />

start_pos<br />

Evaluates to an integer value. PREFIX searches the string specified in the first argument<br />

starting at that position. A value of 1 indicates the first character of the string.<br />

char_expression<br />

Evaluates to a single character. PREFIX returns the substring that ends before that<br />

character. If PREFIX does not find the character, it returns the substring beginning at<br />

start_pos, to the end of the string. If the expression evaluates to more than one character,<br />

PREFIX ignores all but the first character.<br />

Example The following example shows one way to use the PREFIX function:<br />

create table prefix_table<br />

(<br />

colstring varchar(20),<br />

colchar char(1)<br />

);<br />

insert into prefix_table values ('string.with.dots', '.');<br />

insert into prefix_table values ('string-with-dashes', '-');<br />

select colstring, colchar, prefix(colstring, 1, '.') from prefix_table;<br />

COLSTRING COLCHAR prefix(COLSTRING,1,.)<br />

--------------------- --------------------- ----------------------<br />

string.with.dots . string<br />

string-with-dashes - string-with-dashes<br />

select colstring, colchar, prefix(colstring, 1, colchar) from prefix_table;<br />

COLSTRING COLCHAR prefix(COLSTRING,1,COLCHAR)<br />

--------------------- --------------------- ----------------------------<br />

string.with.dots . string<br />

string-with-dashes - string<br />

select colstring, colchar, prefix(colstring, 1, 'X') from prefix_table;<br />

COLSTRING COLCHAR prefix(COLSTRING,1,X)<br />

--------------------- --------------------- ----------------------<br />

string.with.dots . string.with.dots<br />

string-with-dashes - string-with-dashes<br />

113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!