Re: [SQL] on insert rule with default value

2012-02-22 Thread Ron Peterson
2012-02-21_15:51:30-0500 Ron Peterson : > My rule below does not insert the the same uuid value into the test_log > table as is created in the test table when I insert a new value. I know > I've worked through this before, but I'm not remembering why this is. > What&#x

[SQL] on insert rule with default value

2012-02-21 Thread Ron Peterson
est_log ( anid, value, op, attime ) values ( new.anid, new.value, 'insert', now() ) ); -- Ron Peterson Network & Systems Administrator Mount Holyoke College http://www.mtholyoke.edu/~rpeterso -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

[SQL] create temp table in rule

2006-04-18 Thread Ron Peterson
username = id_temp.username; INSERT INTO id SELECT * FROM id_temp; ); As you can see, I'm trying to create a simple 'insert or update' rule. -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso -

Re: [SQL] mail + rfc822, rfc2822 + schema

2005-01-18 Thread Ron Peterson
you, and if you had > something to recommend. You might want to look at dbmail. http://www.dbmail.org/index.php?page=overview -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso ---(end of broadcast)---

Re: [SQL] simulating row ownership

2005-01-11 Thread Ron Peterson
t; DO INSTEAD nothing; For your example, these rules should say !=, of course... -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso ---(end of broadcast)--- TIP 2: you can get off all lists at o

Re: [SQL] simulating row ownership

2005-01-11 Thread Ron Peterson
RT INTO test ( aname ) VALUES ( 'aaa' ); INSERT INTO test ( aname ) VALUES ( 'yourusername' ); CREATE RULE lock_test_user_update AS ON UPDATE TO test WHERE old.aname = CURRENT_USER DO INSTEAD nothing; CREATE RULE lock_test_user_delete AS ON DELETE TO test WHERE old.aname = CURRENT_USER

Re: [SQL] Question about insert/update RULEs.

2005-01-10 Thread Ron Peterson
; INSERT INTO foo_bar ( foo_id, c ) VALUES ( currval( 'foo_foo_id_seq' ), ... ); ); (Which would mean there's no reason for view 'bar' to display foo_id) Hmm, just noticed you defined foo.foo_id to be type 'serial', so you could omit foo_id in the f

Re: [SQL] insert rule doesn't see id field

2003-01-13 Thread Ron Peterson
On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > CREATE RULE person_insert AS > > ON INSERT TO person > > DO > > INSERT INTO person_log ( name_last, name_first, mod_type, person_id ) > > VAL

Re: [SQL] noupcol code cleanup

2003-01-10 Thread Ron Peterson
elog (ERROR, "noupcols: bad argument to SPI_modifytuple\n"); } if (SPI_result == SPI_ERROR_NOATTRIBUTE) { elog (ERROR, "noupcols: bad attribute value passed to SPI_modifytuple\n"); } pfree (oldcolvals); pfree (newcolval); pfree (colindi

Re: [SQL] insert rule doesn't see id field

2003-01-10 Thread Ron Peterson
On Thu, Jan 09, 2003 at 11:53:42PM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote: > >> colindices = (int *) malloc (ncols * sizeof (int)); > > > Of course we should verify that

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
On Thu, Jan 09, 2003 at 04:50:56PM -0500, Ron Peterson wrote: > colindices = (int *) malloc (ncols * sizeof (int)); Of course we should verify that malloc succeeded... if (colindices == NULL) { elog (ERROR, "noupcol: malloc failed\n"); SPI_finish();

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
pfree (oldcolvals); free (colindices); SPI_finish (); if (SPI_result == SPI_ERROR_ARGUMENT) { elog (ERROR, "noupcols: bad argument to SPI_modifytuple\n"); return PointerGetDatum (NULL); } if (SPI_result == SPI_ERROR_NOATTRIBUTE) { elog (ERROR, &qu

Re: [SQL] insert rule doesn't see id field

2003-01-09 Thread Ron Peterson
On Wed, Jan 08, 2003 at 01:13:03PM -0500, Ron Peterson wrote: > On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > > > > I thought that the idea behind noup was to protect single columns from > > > update. However, when I apply the noup trigger as above, I

Re: [SQL] insert rule doesn't see id field

2003-01-08 Thread Ron Peterson
n when the sequence hits that ID, it will crap out. Maybe just try again, but what if that happened to a bunch of records? Could be a pain. So that's the problem I'd like to prevent, for which I think this function would be useful. So I'll hack at it and see what I

Re: [SQL] insert rule doesn't see id field

2003-01-07 Thread Ron Peterson
BTW, PostgreSQL 7.2.1-2woody2 on Debian. -- Ron Peterson -o) Network & Systems Manager /\\ Mount Holyoke College_\_v http://www.mtholyoke.edu/~rpeterso ---(end of broadcast)--- T

[SQL] insert rule doesn't see id field

2003-01-07 Thread Ron Peterson
the intended behaviour? e.g. directory=# select * from person; name_last | name_first | id ---++ Peterson | Ronald | 1 Humbert | Humbert| 2 (2 rows) directory=# update person set name_first='Ron' where name_first='Ronald'

Re: [SQL] graphical interface - admin

2002-06-27 Thread Ron Peterson
On Thu, Jun 27, 2002 at 07:50:09PM +0800, q u a d r a wrote: > > What's the best open source GUI for DB administration? (postgres) Emacs. ;) -- Ron Peterson -o) 87 Taylor Street /\\ Granby, MA 01033 _\_v https://www.yel

[SQL] Re: Recursive select

2001-05-23 Thread Ron Peterson
Don't drive yourself crazy ( like me ;). You'll have to write some procedural code - sorry. I believe IBM's DB/2 supports recursive queries as defined by SQL3. Oracle provide a couple of non SQL standard clauses (CONNECT BY, LEVELS) to provide similar funcionality. -Ron- GPG and other info at:

[SQL] Re: Is there anything like DESCRIBE?

2001-01-25 Thread Ron Peterson
Mike D'Agosta wrote: > > Hi, > >I have a number of empty tables and I want to get the column names and > data types with an SQL statement. I want to do this procedurally, not > interactively (so I can't use \d in psql). Postgres doesn't > support DESCRIBE... is there any other way to do thi

[SQL] finding foreign keys

2001-01-23 Thread Ron Peterson
Can anyone suggest a more elegant way of finding foreign keys than parsing the tgargs value returned by this query? I'd really rather do pure SQL, sans string parsing, if possible. -- Find tables and foreign keys CREATE VI

[SQL] sql99 / sql3

2001-01-02 Thread Ron Peterson
I just recieved SQL in a Nutshell from O'Reilly. I bought the book because it covers the SQL99 standard. It's my understanding that this is the most recent SQL standard. Am I correct about this? What is the current status of SQL standards? What is the most recent approved standard, and what a

Re: [SQL] Looking for comments

2001-01-02 Thread Ron Peterson
Thomas SMETS wrote: > > > ISBN's have a checkdigit; it would be sensible to provide a > function to be used in a CHECK constraint to ensure that the > ISBN is valid. > Here's a URL with more information:http://www.isbn.spk-berlin.de/html/userman/usm4.htm. I've written a similar algorithm in

Re: [SQL] How to represent a tree-structure in a relational database

2000-12-29 Thread Ron Peterson
Stuart Statman wrote: > > I would suggest, instead, to create a table that represents your hierarchy > without adding columns. For example : > > create table Category ( > CategoryID int4 not null primary key, > ParentCategoryID int4 not null REFERENCES Category (CategoryID), > Category

Re: [SQL] How to represent a tree-structure in a relational database

2000-12-29 Thread Ron Peterson
Ron Peterson wrote: > > CREATE TABLE category_edge ( > parent INTEGER > NOT NULL > REFERENCES category_node(id), > > child INTEGER > NOT NULL > REFERENCES category_node(id) >

Re: [SQL] Tree structure table normalization problem (do I need a trigger?)

2000-12-29 Thread Ron Peterson
Frank Joerdens wrote: > > In a recent thread (How to represent a tree-structure in a relational > database) I asked how to do a tree structure in SQL, and got lots of > suggestions (thanks!), of which I chose the one below: > > create table Category ( > CategoryID int4 not null primary k

Re: [SQL] Compiling "C" Functions

2000-12-29 Thread Ron Peterson
Tulio Oliveira wrote: > > I appreciate any "C" Function complete samples, including de command > line for > the compiler. I've attached a generic GNU make snippet for compiling .so files. Adjust to suite your tastes. Like my math textbooks used to say "writing the C code is trivial, and is lef

[SQL] system catalog info

2000-12-29 Thread Ron Peterson
The HTML programming documentation (e.g. http://www.postgresql.org/devel-corner/docs/programmer/pg-system-catalogs.htm) indicates that more extensive information about the system catalogs can be found in the "Reference Manual". Where can this reference manual be found? Or where can more extensiv

Re: [SQL] How to represent a tree-structure in a relational database

2000-12-28 Thread Ron Peterson
Ron Peterson wrote: > > This structure is more 'normal' in the sense that nodes without children > (in a tree, the leaf nodes) don't have records in the edge table. Phghpth. Should have had my coffee first. The first data structure given would only have a null parent i