help
am 02.07.2003 22:51:11 von yanping huang
Hi,
I am learning postgreSQL. Why I can't get a correct result using LPAD?
select LPAD('Hello',3); not -> ' Hello'
lpad
------
Hel
select LPAD('ello',3,'H'); not -> 'HHHello'
lpad
------
ell
select LPAD('hen', 1, '^');
lpad
------
h
How can I put a '^' befor a variable of VARCHAR type in a function?
Yanping
--
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: help
am 03.07.2003 13:22:52 von Bruno Wolff III
On Wed, Jul 02, 2003 at 16:51:11 -0400,
yanping huang wrote:
> Hi,
> I am learning postgreSQL. Why I can't get a correct result using LPAD?
You are getting a correct result. If you review the documentation on LPAD
you will see that the length is the total length of the resulting string,
not the number of times to repeat the fill string.
>
> select LPAD('Hello',3); not -> ' Hello'
> lpad
> ------
> Hel
>
> select LPAD('ello',3,'H'); not -> 'HHHello'
> lpad
> ------
> ell
>
> select LPAD('hen', 1, '^');
> lpad
> ------
> h
>
>
> How can I put a '^' befor a variable of VARCHAR type in a function?
>
> Yanping
> --
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Re: help
am 03.07.2003 20:51:21 von akopciuch
> How can I put a '^' befor a variable of VARCHAR type in a function?
>
Is this what you are looking for ... the concatentation operator?
select '^' || 'sometext'::varchar;
If you are asking about doing that in the function call :
select myfunction( '^' || var);
Andy
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org