HP3000-L Archives

December 2004, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Cathlene Mc Rae <[log in to unmask]>
Reply To:
Cathlene Mc Rae <[log in to unmask]>
Date:
Fri, 24 Dec 2004 10:38:04 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (97 lines)
Your question on trim for allbase/sql:


With the G3 release of ALLBASE/SQL and IMAGE/SQL, the supported SQL syntax
has been enhanced to include the following string manipulation functions:
UPPER, LOWER, POSITION, INSTR, TRIM, LTRIM and RTRIM. These string
functions allow you to manipulate or examine the CHAR and VARCHAR values
within the SQL syntax, allowing for more sophisticated queries and data
manipulation commands to be formed. These string functions were designed to
be compatible with functions specified in the ANSI SQL '92 standard and
functions used in ORACLE. In cases where the ANSI SQL '92 standard and the
ORACLE functions were not compatible (such as the LTRIM and RTRIM in ORACLE
versus TRIM in the ANSI standard), both versions where implemented. The
specifications for each of these functions follows.

Ltrim

LTRIM function trims the characters specified in charset from the beginning
of the string stringexpr .

Syntax

[ LTRIM ( stringexpr, charset )]

Rtrim

RTRIM function trims the characters specified in charset from the end of
the string stringexpr .

Syntax

[ RTRIM (stringexpr, charset )]

Trim

TRIM function allows you to strip the characters specified in charset from
the beginning and/or the end of the string stringexpr . If charset is not
specified, then blank characters would be stripped from stringexpr .

Syntax

[ TRIM ({ LEADING | TRAILING | BOTH} (charset FROM stringexpr)]

Examples:

Example 1

 SELECT LOWER (OWNER) || '.' || LOWER (NAME)
 FROM SYSTEM.TABLE
 WHERE NAME = UPPER ('vendors');

Returns "purchdb .vendors "

Example 2

 SELECT POSITION ('world' IN 'hello world')
 FROM SYSTEM.TABLE
 WHERE NAME = UPPER('vendors');

Returns the numeric value 7

Example 3

 SELECT INSTR ('hello world hello world', 'world', 5, 2)
 FROM SYSTEM.TABLE
 WHERE NAME = UPPER('vendors');

Returns the numeric value 19 (starting position of the second occurrence of
the string 'world')

Example 4

 SELECT * FROM SYSTEM.TABLE
 WHERE NAME = LTRIM ('VENDORS?*???***','?*')
 AND OWNER = 'PURCHDB';

Returns the system table entry for PURCHDB.VENDORS

Example 5

 SELECT TRIM (BOTH '?*' FROM '??**?*hello ?* world???*')
 FROM SYSTEM.TABLE
 WHERE NAME = 'VENDORS';

Returns 'hello?* world'.


the 6.0 communicator has more details:
http://docs.hp.com/en/30216-90269/index.html

hope this helps..
Cathlene Mc Rae
HP Response Center

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2