Re: design/copying a bunch of records

From: M Spreij <nemo(at)mechintosh(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: design/copying a bunch of records
Date: 2003-07-24 20:47:14
Message-ID: a05210602bb45f12e6c1f@[192.168.1.12]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


> > So I figured the best way was to copy the records from the
>> admin-set to user-sets (but suggestions for other ways are very
>> welcome!), and was wondering if there is a 'good' way to copy about
>> 50 records to different tables every time you add a user account -
>> the only way I can think of is write some loops in PHP. Better ways?
>> TIA!
>
>Yes ... the better way is to just have all products in one big table with a
>column to indicate what user they belong to. And then to modify the PHP
>query for each user so that it always includes both his and the admin's
>products. The same approach should be used with other "user specific"
>tables.

I forgot to mention there were a few differences needed between the
admin and user sets, so I already had gone with the two tables.
Now I'm trying to get this nifty postgresql code to work for me.. can
anyone point out what I'm doing wrong? Trying to copy the records
from the first groups into cgroups:
-------------------------
$sql = "
DECLARE
tRecord RECORD;
BEGIN
FOR tRecord IN (SELECT id, kind, name, col_1, col_2, col_3, display
FROM groups) LOOP
INSERT INTO cgroups (id, kind, name, col_1, col_2, col_3,
display, user_id)
VALUES (tRecord.id, tRecord.kind, tRecord.name,
tRecord.col_1, tRecord.col_2, tRecord.col_3, tRecord.display,
$user_id);
END LOOP;
END;
";

pg_query($sql);
-------------------------
-> PostgreSQL query failed: ERROR: parser: parse error at or near "record"

PHP 4.1.2, PostgreSQL 7.1

TIA!

Regards,

Martin
--
<mailto:mac(dot)com(at)nemo>
<http://www.mechintosh.com/>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Avi Schwartz 2003-07-24 20:55:13 Re: Questions about Exists-Not exists clause
Previous Message M Spreij 2003-07-24 20:46:36 Re: Questions about Exists-Not exists clause