Re: Insert and limit - Mailing list pgsql-general

From Richard Huxton
Subject Re: Insert and limit
Date
Msg-id 002b01c0f5a1$cdea5480$1001a8c0@archonet.com
Whole thread Raw
In response to Insert and limit  ("Matteo Centenaro" <gente_che_mixa@hotmail.com>)
Responses Re: Insert and limit  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
From: "Matteo Centenaro" <gente_che_mixa@hotmail.com>


> Hi all,
>  is possible that the limit statement dosen't run correctly in this case:
>
> Insert into temp
> Select * from tab1
> Where cod = xxxx
> Limit yyy;
>

[follow-up message said Matteo was interested in plpgsql]

Still seems OK.

richardh=> create function copy_foo() returns int as '
richardh'> begin
richardh'>   insert into foo2 select * from foo limit 1;
richardh'>   return 1;
richardh'> end;' language 'plpgsql';
CREATE
richardh=> select copy_foo();
 copy_foo
----------
        1
(1 row)

richardh=> select * from foo2;
 a |                b
---+----------------------------------
 4 | Jack Smith
(1 row)


You weren't using SELECT INTO were you - there is a different form for
plpgsql.

- Richard Huxton


pgsql-general by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: Insert and limit
Next
From: will trillich
Date:
Subject: OT: Apache::Session::DBI vs postgresql? --help