Обсуждение: using string functions on plpgsql

Поиск
Список
Период
Сортировка

using string functions on plpgsql

От
"Marcelo Edgardo Paniagua Lizarraga"
Дата:
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

От
Tom Lane
Дата:
"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

От
Craig Ringer
Дата:
Marcelo Edgardo Paniagua Lizarraga wrote:

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

i := length(texto)

--
Craig Ringer


Re: using string functions on plpgsql

От
Craig Ringer
Дата:
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

От
Tom Lane
Дата:
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