Thread: using string functions on plpgsql

using string functions on plpgsql

From
"Marcelo Edgardo Paniagua Lizarraga"
Date:
I'm starting to create my firsts plpgsql functions, and I was
wondering how to use the string function 'length' in the code of the
fuction. I have tried so far and I get an error. I'm trying this:

declare   i integer;
begin...
  i =  length(texto)

...

where texto is a varchar(200) I pass as a parameter to the function calling.

Any help will help.

Thanks!!!


Re: using string functions on plpgsql

From
Tom Lane
Date:
"Marcelo Edgardo Paniagua Lizarraga" <mpaniagua18@gmail.com> writes:
> I'm starting to create my firsts plpgsql functions, and I was
> wondering how to use the string function 'length' in the code of the
> fuction. I have tried so far and I get an error.

There's nothing obviously wrong with what you posted, so the problem
is somewhere in what you left out.

If you want useful help, it's generally advisable to show a complete
example of what you did and exactly what error message you got.
        regards, tom lane


Re: using string functions on plpgsql

From
Craig Ringer
Date:
Marcelo Edgardo Paniagua Lizarraga wrote:

> declare
>     i integer;
> begin
>  ...
> 
>    i =  length(texto)      ^^^

i := length(texto)

--
Craig Ringer


Re: using string functions on plpgsql

From
Craig Ringer
Date:
Craig Ringer wrote:
> Marcelo Edgardo Paniagua Lizarraga wrote:
> 
>> declare
>>     i integer;
>> begin
>>  ...
>>
>>    i =  length(texto)
>       ^^^
> 
> i := length(texto)

Whoops, I spoke too soon - it seems both are valid for assignment. Has 
that always been true?

The one time I don't write a small test before posting....

--
Craig Ringer


Re: using string functions on plpgsql

From
Tom Lane
Date:
Craig Ringer <craig@postnewspapers.com.au> writes:
> i =  length(texto)
>> ^^^
>> 
>> i := length(texto)

> Whoops, I spoke too soon - it seems both are valid for assignment. Has 
> that always been true?

Yeah, it's not documented, but AFAIK plpgsql has always taken both.
        regards, tom lane