×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Camel Case...?

Camel Case...?

Camel Case...?

(OP)
Good morning,

Is there perhaps a function in pervasive where I could convert a string to camel case? That is,

Original: HELLO MARY WHITE
becomes: Hello Mary White

I've searched the Pervasive 13 manual and did not find anything... just trying my luck in case I missed it.

As always, thank you.

RE: Camel Case...?

I'm not aware of many Databases that have that kind of function built-in and Actian / Pervasive doesn't have it either. You could always use whatever programming language you're using to build a function to convert it or you could write a DB function to do it.
This might work (I haven't tested it other than to see if it compiled and returned the correct value for one test):

CODE

CREATE FUNCTION GetFirstLetterCapital(:str varchar(8000)) RETURNS varchar(8000)
AS
BEGIN
DECLARE :n INT;
SET :n = 1;
DECLARE :pos INT 
SET :pos = 1;
DECLARE :sub VARCHAR(8000);
SET :sub = '';
DECLARE :proper VARCHAR(8000);
SET :proper = '';

if (length(rtrim(ltrim(:str))) > 0) then
begin
    WHILE (:pos > 0) DO
        set :pos = locate(' ',rtrim(ltrim(:str)),:n);
        if (:pos = 0) then
            set :sub = lower(rtrim(ltrim(substring(rtrim(ltrim(:str)),:n))));
        else
        	set :sub = lower(rtrim(ltrim(substring(rtrim(ltrim(:str)),:n, :pos - :n))));
        end if;

        set :proper = concat(concat(:proper, concat(upper(left(:sub,1)),substring(:sub,2))), ' ');
        set :n = :pos + 1;
    END WHILE;
end;
else
  set :proper = '';
end if;

RETURN :proper;
END; 

Mirtheil
http://www.mirtheil.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close