All you need is a function that traverses the tree upwards and returns the
root's id.
create or replace function get_root_name(dept text) returns text as $$
declare
parent text := '';
prev_parent text;
begin
while( parent is not null ) loop
prev_parent := parent;
sele
On Wed, Jan 20, 2010 at 10:13 PM, Andreas wrote:
> Thanks a whole lot and some :)
>
> It's great that you actually did a working script.
> I find it tremendosly easier to learn with a working example than with some
> links to other documentation which makes or does not make sense.
>
> I've got a
on_id
---
1
2
3
2
4
5
(6 rows)
Best regards,
On Wed, Jan 20, 2010 at 11:15 AM, Gurjeet Singh wrote:
> You need a recursive lookup, and I guess 8.4's WITH RECURSIVE construct can
> help here. But if you are on an older version of Postgres,
You need a recursive lookup, and I guess 8.4's WITH RECURSIVE construct can
help here. But if you are on an older version of Postgres, you will have to
write recursive functions to do it.
I tried my hands on it, and attached is an implementation of such a
recursive function. It returns the expecte
It should be \copy . This is a psql command; if you have direct access to
database host machine, you might want to use the SQL command COPY for it's
performance.
http://www.postgresql.org/docs/8.3/interactive/app-psql.html
http://www.postgresql.org/docs/8.3/interactive/sql-copy.html
Best regards,
On Wed, Oct 1, 2008 at 6:37 AM, Rafael Domiciano <[EMAIL PROTECTED]
> wrote:
> Hi there,
> The operation "on_duplicate_key_update" is in implementation on the new
> version of Postgres :)
> The only way (or, at least, the best way... I think) to do what you want is
> using a temporary table... let
On Wed, May 21, 2008 at 8:33 AM, Karl Denninger <[EMAIL PROTECTED]> wrote:
> Gurjeet Singh wrote:
>
> On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]>
> wrote:
>
>> Gurjeet Singh wrote:
>>
>>> On Tue, May 20, 2008 at 11:4
On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]> wrote:
> Gurjeet Singh wrote:
>
>> On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>>
>> assuming the following schema:
>>
On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> wrote:
> assuming the following schema:
>
> create table access (name text, address ip)
>
> I want to construct a SELECT statement which will return ONLY tuples
> containing IP and name pairs IF there is an IP that has two o
On Wed, May 14, 2008 at 5:24 AM, Gavin 'Beau' Baumanis <
[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> After spending some time searching through our good friend Mr. Google and
> the mailing list I found a post that provided me with a query that does just
> what I need.
>
> However, the query takes
On Sun, May 11, 2008 at 11:47 PM, Craig Ringer <[EMAIL PROTECTED]>
wrote:
> Mag Gam wrote:
>
> >
> >ts | size| Diff
> > ---+-+--
> > 2002-03-16| 11 | 0
> >
> > 2002-03-17| 15 | 4
> > 2002-03-18| 18 | 3
> > 2002-03-19|
On Sun, May 11, 2008 at 11:07 PM, Mag Gam <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a view that generates output similar to this.
>
> select * from foo.view;
>
>ts | size
> ---+-
> 2002-03-16| 11
> 2002-03-17| 16
>
> 2002-03-18|
On Tue, Apr 29, 2008 at 4:05 AM, Dana Huggard - Navarik <
[EMAIL PROTECTED]> wrote:
> Hello,
>
> What would be the best method to truncate a table once it reaches a
> certain size.
>
> For instance, a table named log. I can check the size of the log;
>
> db=# select pg_relation_size('log');
>
On Tue, Apr 22, 2008 at 3:24 PM, Nacef LABIDI <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am using Postgres in a Delphi application through ODBC. I am having an
> issue with updating records.
>
> When I create a dataset to get the records in a table then after I update
> one of these records and th
On Thu, Apr 3, 2008 at 7:14 AM, Otniel Michael <[EMAIL PROTECTED]> wrote:
> Hi All..
>
> Anybody knows what is "GO" (SQL Server) on Postgres?
>
If you are using the interactive terminal psql, then you can use \g meta
command
select 1+2
\g
expect results here.
Remember that this is a
On Thu, Mar 20, 2008 at 7:08 PM, Joe <[EMAIL PROTECTED]> wrote:
> Gurjeet Singh wrote:
> > Except that it doesn't work... Did you try to execute that query; I am
> > assuming not.
> Of course I did,
My bad... I did not run your query either, and based my assumptio
On Thu, Mar 20, 2008 at 5:40 PM, Joe <[EMAIL PROTECTED]> wrote:
> Gavin 'Beau' Baumanis wrote:
> >
> > The copy is inside the same table, so I don't understand why it (the
> > required query ) would require any joins.
> >
> > Ie. I want to copy the contents of a row (but for the id column - of
> >
On Thu, Mar 20, 2008 at 5:35 PM, Craig Ringer <[EMAIL PROTECTED]>
wrote:
>
> craig=# explain update x set val = foundrow.val from ( select val from x
> where id = 4123 ) as foundrow where id = 5912 ;
>
Thats nifty.
--
[EMAIL PROTECTED]
[EMAIL PROTECTED] gmail | hotmail | indiatimes | yahoo }.
l the data from 'scott' row on to 'greg' row, but keep
the id (id obviously being your unique identifier).
UPDATE emp
SET (salary, name) = ( (select salary from emp where id = 21 ),
(select name from emp where id = 21) )
where id = 31;
HTH
On Thu, Mar 20, 2008 at 4:19 PM, A. Kretschmer <
[EMAIL PROTECTED]> wrote:
> am Thu, dem 20.03.2008, um 20:57:53 +1100 mailte Gavin 'Beau' Baumanis
> folgendes:
> > Hi Everyone,
> >
> > I have asked our DBA at work and h is not too sure either... so I
> > thought it best to on the list.
> >
> > B
20 matches
Mail list logo