pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: John <johnf@jfcomputer.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: understanding select into
Date: Fri, 9 Apr 2010 19:32:51 +0200
Message-ID: <k2z162867791004091032r401ee913r3531742cb8c2871@mail.gmail.com> (raw)
In-Reply-To: <201004091018.37965.johnf@jfcomputer.com>
References: <201004091018.37965.johnf@jfcomputer.com>

Hello

2010/4/9 John <johnf@jfcomputer.com>:
> Hi,
> I am reviewing a function written by some xTuple guys.  What is interesting
> about it is it uses the "INTO" statement like
>
> select something into _p from sometable where somecriteria.
>
> The function contiunes and uses the data retreived
> _p.somefield_name
>
> And then the function ends.
>
>
> Ok my question:
>
> I also thought the select "into" created a real table.  But after running the
> function the table does not exist.  I see no where that a 'drop' is issued.
> In fact the function uses lot's of select into's like (_test, _r, etc..).  So
> would some kind soul explain what is happening.
>

_p is record variable. See some lines before. There will be DECLARE part

DECLARE p RECORD;

There is plpgsql's SELECT INTO and SQL's SELECT INTO with little bit
different syntax. First - target is list of variables or record
variable, second - target is table.

> Could it be that "_p" is drop automaticly when the function ends?  Something
> to do with scope.
>

_p is just variable

regards
Pavel Stehule

> Could it have something to do with the fact the function returns only an
> integer?  And that causes the table to be drop.
>
> As you can see I'm lost here!
>
>
> Johnf
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



view thread (4+ messages)  latest in thread

Message-ID: <k2z162867791004091032r401ee913r3531742cb8c2871@mail.gmail.com>
Permalink:  ../k2z162867791004091032r401ee913r3531742cb8c2871@mail.gmail.com/
Also on:    postgresql.org/message-id/k2z162867791004091032r401ee913r3531742cb8c2871@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pavel.stehule@gmail.com, johnf@jfcomputer.com
  Subject: Re: understanding select into
  In-Reply-To: <k2z162867791004091032r401ee913r3531742cb8c2871@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox