Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / August 2006

Tip: Looking for answers? Try searching our database.

DB2 Length Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BP - 30 Aug 2006 18:28 GMT
I'm writting a script that needs to deterimine the length of a char
value...its easy enough to put length ('my data value') which
evalulates to 13, but when I concatonate it, it says...

SQL0440N  No authorized routine named "||" of "FUNCTION" having
compatible arguments was found....

How can I get this to work?

select (space (1) || repeat('0',7) || length ('Some Data String'))
jefftyzzer - 30 Aug 2006 18:58 GMT
|| and its twin CONCATENATE expect a string argument. Just wrap, e.g.,
CHAR around your call to LENGTH (i.e., CHAR(LENGTH('Some Data
String'))) and you should be good-to-go.

--Jeff

> I'm writting a script that needs to deterimine the length of a char
> value...its easy enough to put length ('my data value') which
[quoted text clipped - 6 lines]
>
> select (space (1) || repeat('0',7) || length ('Some Data String'))
jefftyzzer - 30 Aug 2006 19:05 GMT
Note also that when using CHAR, some RTRIMing may be in order, e.g.,

VALUES RTRIM(CHAR(LENGTH('SOME DATA STRING')))||' HELLO, WORLD'

1
------------------------
16 HELLO, WORLD

vs.

VALUES CHAR(LENGTH('SOME DATA STRING'))||'HELLO, WORLD'

1
-----------------------
16         HELLO, WORLD

HTH,

--Jeff

> || and its twin CONCATENATE expect a string argument. Just wrap, e.g.,
> CHAR around your call to LENGTH (i.e., CHAR(LENGTH('Some Data
[quoted text clipped - 12 lines]
> >
> > select (space (1) || repeat('0',7) || length ('Some Data String'))
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.