Re: [SQL] Why is PostgreSQL 7.0 SQL semantics different from Oracle's?

2000-05-24 Thread Jan Wieck
Thomas Holmgren wrote: > > Hello everyone! :) > > This little problem is bothering me a lot! It seems that PostgreSQL 7.0 > uses different semantics than Oracle when evaluting SQL?! Not that much, but ... > [...] > > I have defined two views, viewA and viewB. They are defined as follow: > >

Re: [SQL] constraint

2000-05-29 Thread Jan Wieck
Bernie Huang wrote: > Hi, > > I am a newbie to SQL. Could someone please explain why do I need a > contraint, and how do I use it in SQL? An example is needed. Thanks Constraints are used to have the database engine ensure the integrity of the data. It'l like teaching the database it

[SQL] Re: Deferral of primary key constraint

2000-06-02 Thread Jan Wieck
Kyle Bateman wrote: > Is it possible to defer the check on a primary key constraint (or a > check constraint, for that matter). Here is an example that shows why > it would be nice to be able to do so. We have a real-life scenario that > is similar (but much more complex). Not yet. Only

Re: [SQL] Benchmark

2000-06-02 Thread Jan Wieck
Nikolaj Lundsgaard wrote: > Is there anywhere I can find some benchmark test for postgres. The reason is that I >want to use it for a site that could have several simultanous users querying the >database and I want to be sure that it is stable (and fast) enough to handle that >kind of (ab)use.

Re: [SQL]

2000-06-08 Thread Jan Wieck
Michael Fork wrote: > CREATE INDEX idx_radacct_1 ON radacct (username,acctstatustype,tstamp); > CREATE INDEX idx_radacct_2 ON radacct (username,acctstatustype); > CREATE INDEX idx_radacct_3 ON radacct (username,tstamp); > CREATE INDEX idx_radacct_4 ON radacct (acctstatustype,tstamp); > CREATE INDE

Re: [SQL] ORDER BY in definition of views

2000-06-09 Thread Jan Wieck
Niall Smart wrote: > Guys, > > Does anyone know if this is on the radar for 7.1? Yes, it is not. Jan -- #==# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me.

Re: [SQL] sql foregein key

2000-06-13 Thread Jan Wieck
GANESH KUMAR wrote: > > sir , > > i am working 6.5.2 postgresql > in creation foregein key in table > > syntax i am writing is > 1)create table gk > (sno int primary key); > > 2)create table kk > (sno int references gk, > sname varchar(2)); > i am getting message like this foregein key is not

Re: [SQL] Which procedural language to use for functions.

2000-07-05 Thread Jan Wieck
Saltsgaver, Scott wrote: > Which procedural language is best for writing PostgreSQL functions: > 'PL/pgSQL', 'PL/perl', or 'PL/Tcl'? > > I know that I can't do table creates in 'PL/pgSQL'? > > Is there an obvious choice as far speed and size? PL/Tcl has the advantage that it can do the table

[SQL] Re: [GENERAL] lztext and compression ratios...

2000-07-06 Thread Jan Wieck
Tom Lane wrote: > [EMAIL PROTECTED] (Jan Wieck) writes: > > One thing to keep in mind is that the LZ algorithm you're > > thinking of must be distributable under the terms of the BSD > > license. If it's copyrighted or patented by any third party

Re: [SQL] confused by select.

2000-07-06 Thread Jan Wieck
Brett W. McCoy wrote: > On Thu, 6 Jul 2000, John wrote: > > > I would like to get the id's where the customer has purchased an item of a > > specific type. > > > > Problem A: most people order more than one item at a time. > > So the 'items' field is a colon delimitted text field containing t

Re: [SQL] Re: [GENERAL] lztext and compression ratios...

2000-07-06 Thread Jan Wieck
Tom Lane wrote: > [EMAIL PROTECTED] (Jan Wieck) writes: > >> As long as you brought it up: how sure are you that the method you've > >> used is not subject to any patents? > > > Now that you ask for it: I'm not sure. Could be. > > >> If you

Re: [SQL] Opposite of LOCK

2000-07-12 Thread Jan Wieck
Antti Linno wrote: > Is there any possibility to unlock tables after they've been locked? The > manual part of lock was fuzzy, so I ask from experts instead. MySQL > uses lock and unlock. Yes, COMMIT/ROLLBACK. The transactional concept implies that you hold each lock you accquired si

Re: [SQL] Median

2000-07-18 Thread Jan Wieck
omid omoomi wrote: > Hi, > I'll be glad if you describe more details about the problem. Is it a kind of > statistical analysis or what? > Omid Omoomi Sorry to respond that slow. It's something, Ulf Mehlig described to me a couple of months ago. The median is the value, below and

Re: [SQL] using OID as primary key

2000-07-21 Thread Jan Wieck
Markus Wagner wrote: > Hi, > > are there any disadvantages of using OID as the primary key for any > table? > What about referencing external tuples using their OIDs? > > e. g.: > CREATE TABLE thistable > ... > field NUMERIC REFERENCES OtherTable (oid) > > Which data type should I use to reference

Re: [SQL] Why do I need to set UPDATE permissions for fkey check?

2000-07-22 Thread Jan Wieck
Jon Lapham wrote: > On Fri, Jul 21, 2000 at 02:00:00PM -0700, Stephan Szabo wrote: > > > > It's a known problem in the foreign key code. The reason is that > > the fk triggers use SELECT FOR UPDATE to select the matching > > rows that it is checking and the reason for using FOR UPDATE is > > to l

Re: [SQL] create function - user permissions

2000-07-22 Thread Jan Wieck
Markus Wagner wrote: > Hi, > > one of my users wants to create functions using the C language, but pgs > says "no permission". > > How can I permit the user to do this, while avoiding to give him root > access rights? Assuming with "root" access you mean "DB-superuser" rights. No way!

[SQL] Re: [BUGS] problem with view and case - please help

2000-07-21 Thread Jan Wieck
Ange Michel POZZO wrote: > I repost my message because it seems that my previous post don't go on > > i use [PostgreSQL 6.5.2 on i686-pc-linux-gnu, compiled by gcc 2.95.2] > rpm version of Linux Mandrake 7.02 > That's definitely the problem. I cannot recreate it with current CVS sour

Re: [SQL] TCL updates

2000-07-24 Thread Jan Wieck
Kyle wrote: > Jan wrote: > > Beginning with Tcl 8.0, dual ported objects got used to deal > >with values. These have (amongst performance issues) alot of > >benefits. Changing all the call interfaces would make it > >impossible to use PL/Tcl with a pre 8.0 Tcl installation

Re: [SQL] Large text insertion

2000-07-27 Thread Jan Wieck
Vladimir Terziev wrote: > >Can anybody tell me, how I can insert text data larger then 20k in database > wihtout using large objects? > 7.1 will be able to hold megabytes in the "text" data type. It's already in the CURRENT sources and works well. Jan -- #===

Re: [SQL] Conditional rule?

2000-07-27 Thread Jan Wieck
Tom Lane wrote: > "=?iso-8859-1?B?QW5kcukgTuZzcw==?=" <[EMAIL PROTECTED]> writes: > > I wish to make rule looking something like this: > > create rule newsrule as > > on insert to news do > > if new.publishtime is not null insert into news_unpublished > > values(new.id); > > > I.e. "On an in

Re: [SQL] 8K Limit, whats the best strategy?

2000-08-21 Thread Jan Wieck
Poul L. Christiansen wrote: > Jan Wieck wrote: > > > Poul L. Christiansen wrote: > > > I've just split the text up (in 8 pieces), so it fits into 8K rows. But thats > > > only a viable solution if your text is less than a couple of 100K's. > > >

Re: [SQL] 8K Limit, whats the best strategy?

2000-08-21 Thread Jan Wieck
Poul L. Christiansen wrote: > I've just split the text up (in 8 pieces), so it fits into 8K rows. But thats > only a viable solution if your text is less than a couple of 100K's. > > You could try to be a daredevil and use the Toast code, even if it's beta. But > I don't know how far the Toast pro

Re: [SQL] Continuous inserts...

2000-08-22 Thread Jan Wieck
Stephan Szabo wrote: > Wierd, I've not seen that behavior really, although I've never > done time sensitive stuff. It might be the time before the > shared cache updates? Not sure really. If you do the rule > inline with your inserts (rather than a second transaction) > does it still wait?

Re: [SQL] Using SETOF in plpgsql function

2000-08-23 Thread Jan Wieck
hlefebvre wrote: > Hello, > > I'd like to return a set of integer in an pl/pgsql function. How can I > do that ? You can't. Not with PL/pgSQL nor with any other PL or C. The problem is nested deeper and requires the planned querytree redesign to get solved. Before you ask: T

Re: [SQL] Using SETOF in plpgsql function

2000-08-23 Thread Jan Wieck
Tom Lane wrote: > Jan Wieck <[EMAIL PROTECTED]> writes: > > hlefebvre wrote: > >> I'd like to return a set of integer in an pl/pgsql function. How can I > >> do that ? > > > You can't. Not with PL/pgSQL nor with any other PL or C. T

Re: [SQL] RE: Create table in functions

2000-08-31 Thread Jan Wieck
Andreas Tille wrote: > On Thu, 24 Aug 2000, Hiroshi Inoue wrote: > > > Hmm,Andreas's original function seems to contain other statements. > > If the function contains DML statements for the table Temp_Num_Table, > > it wouldn't work properly. i.e 1st call would work but 2nd call woudn't. > That's

Re: [SQL] pg_hba.conf

2000-09-04 Thread Jan Wieck
Craig May wrote: > I've renamed the file to "pg_hba.conf". It's owner and groug are now postgres. > The file is located in /usr/lib/pgsql/. I'm still receiving the same error. Network setup? Contents of pg_hba.conf? How should someone tell you what's wrong with the information you

[SQL] Re: [GENERAL] function

2000-08-30 Thread Jan Wieck
Normunds wrote: > Hi all, > > how can I write function which takes text from one field, replaces > some characters and puts it in other field? I have array with old and > new values. > > For example: > old array = {'r', 'Z', 'o'} > new array = {'s', 'm', 't'} > old field value = 'Zorro' > new fiel

[SQL] Re: [HACKERS] foreign key introduces unnecessary locking ?

2000-10-23 Thread Jan Wieck
Mikheev, Vadim wrote: > Try this for both FK tables: > > create table tmp2(idx2 int4, col2 int4, constraint > tmpcon2 foreign key(col2) references tmp1(idx) INITIALLY DEFERRED); > > This will defer constraint checks till transaction commit... > though constraint triggers should use SnapshotDirty i

Re: [SQL] Re: Requests for Development

2000-11-17 Thread Jan Wieck
KuroiNeko wrote: > > I wonder if there couldn't borrowed some code from Interbase which has > > full featured stored procedures - at least it was told to me that it has > > ... > > Well, I have some hands-on experience with IB, don't know whether this is > perfectly relevant, but here goes

Re: [SQL] Requests for Development

2000-11-17 Thread Jan Wieck
Josh Berkus wrote: > Tom, Bruce, Jan, etc.: > > [...] > > The rest of these requests apply to 7.2: > > 2. Stored Procedure functionality, i.e. outputting a full recordset from > a function (or new structure, if functions are hard to adapt) based on > the last SELECT statement passed to the functio

Re: [SQL] problem with keyword 'old'

2000-12-03 Thread Jan Wieck
Basilis Kladis wrote: [Charset iso-8859-7 unsupported, filtering to ASCII...] > I am ussing Postgresql v. 6.3 in a RedHat Linux system. I try to create a > rule to log the deletes on table 'filter' ussing the following: First of all, the rule system up to version 6.3 is known to be bro

[HACKERS] Re: [SQL] Rules with Conditions: Bug, or Misunderstanding

2000-12-03 Thread Jan Wieck
Tom Lane wrote: > "Joel Burton" <[EMAIL PROTECTED]> writes: > > create rule dev_ins as on update to dev_col_comments where > > old.description isnull do instead insert into pg_description ( objoid, > > description) values (old.att_oid, new.description); > > > create rule dev_upd as on update to de

[HACKERS] Re: [SQL] Rules with Conditions: Bug, or Misunderstanding

2000-12-04 Thread Jan Wieck
Tom Lane wrote: > Jan Wieck <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Hm. Perhaps the "cannot update view" test is too strict --- it's not > >> bright enough to realize that the two rules together cover all cases, > >> so it com

Re: [SQL] Strange slow behavior in backend

2000-12-14 Thread Jan Wieck
Tom Lane wrote: > Kyle <[EMAIL PROTECTED]> writes: > > This worked great until I put a real big file in (about 5M). Then, when > > I tried to fetch the file, it seemed really slow (about 60 seconds). I > > tried reassembling the file in the frontend instead and my time dropped > > to about 6 sec

Re: [SQL] Strange slow behavior in backend

2000-12-14 Thread Jan Wieck
Kyle wrote: > I'm using 7.0.1 with a TCL frontend. > > I have a schema that splits large files into tuple-sized bites and > stores them in a table. This was done before TOAST in order to store > large files. > > I have a backend TCL function that re-assembles the file like this: > > -- Fetch the

Re: [SQL] Rules

2001-01-02 Thread Jan Wieck
Peeter Smitt wrote: > Hi > > I'm trying to make updateable view useing rules. > > CREATE RULE update_rule AS ON UPDATE TO table DO INSTEAD > SELECT fun1(new); > > Thing is that backend gives this error. > ERROR: parser: parse error at or near ")" > > What i'm doing wrong? Are there any other

Re: [SQL] pl/pgsql Limits

2001-01-13 Thread Jan Wieck
Najm Hashmi wrote: > Hi All, > As it is known that any funtion, written in pl/pgsql, can only > retrun one tuple. I am just wondering it were true as well for function > written in C language. I need to write few function that will retrun > mulitiple rows satsifying a certain set of conditi

Re: [SQL] Question #4 about PL/PGSQL

2001-01-16 Thread Jan Wieck
Josh Berkus wrote: > Folks, > > Oh, yes, one more: > > 4. If I pass a NULL to any of the parameters of a PL/PGSQL > function, any (other) VARCHAR parameters are set to NULL as > well. Fixed in 7.1. Impossible to fix in 7.0.x or earlier due to missing capabilities of the function manage

Re: [SQL] Three questions regarding PL/PGSQL

2001-01-16 Thread Jan Wieck
) if the correct number of rows has been hit. > Anybody (Jan?) who can shed some light on the above will > receive my enthusiastic gratitude in ASCII text. Some sql examples would allways help. > P.P.S. My most heartfelt gratitude to Jan Wieck for writing > some dec

Re: [INTERFACES] Re: [SQL] improve performance

2001-01-17 Thread Jan Wieck
Hannu Krosing wrote: > Tom Lane wrote: > > > > > > I've heard lots of people want to increase BLCKSZ, but you're the first > > one who ever wanted to reduce it. You sure you want to do this? It's > > going to make the maximum row length uncomfortably short. > > And it may even not work, as some

Re: [SQL] unreferenced primary keys: garbage collection

2001-01-20 Thread Jan Wieck
Forest Wilkinson wrote: > I have a database in which five separate tables may (or may not) reference > any given row in a table of postal addresses. I am using the primary / > foreign key support in postgres 7 to represent these references. > > My problem is that, any time a reference is removed

Re: [SQL] unreferenced primary keys: garbage collection

2001-01-22 Thread Jan Wieck
Jan Wieck wrote: > Forest Wilkinson wrote: > > I have a database in which five separate tables may (or may not) reference > > any given row in a table of postal addresses. I am using the primary / > > foreign key support in postgres 7 to represent these references. >

Re: [SQL] Rules and transactions

2001-01-24 Thread Jan Wieck
Brett Schwarz wrote: > If I have a rule, is the rule inside a tranaction along with the table that > it references. For example, if I have a rule that deletes an entry from > table B, whenever an entry in table A gets deleted, then is the delete for > table A and table B wrapped inside the same tr

Re: [SQL] Rule not invoked in 7.1

2001-01-25 Thread Jan Wieck
Tom Lane wrote: > Kyle <[EMAIL PROTECTED]> writes: > > ERROR: Cannot update a view without an appropriate rule. > > 7.1 insists that you provide an *unconditional* DO INSTEAD rule > for a view. What do you think was happening on your old database > when the "where old.status = 'appr'" clause was

Re: [SQL] Rule not invoked in 7.1

2001-01-26 Thread Jan Wieck
Tom Lane wrote: > Kyle <[EMAIL PROTECTED]> writes: > > If someone happens to know the primary key of a record they should not be > > able to access, and they try to update it, I would like the backend to > > ignore the query (or better yet, raise an exception but I haven't figured > > out how to d

[SQL]

2001-01-26 Thread Jan Wieck
Kyle wrote: > The only complication is > that there are a class of records which the user should be able to view, but not > modify. For example, > the employee can create and modify working records as long as the only > modification to their status > is to move them on to "open status" (creating

Re: [SQL] Rule not invoked in 7.1

2001-01-26 Thread Jan Wieck
Kyle wrote: > The only complication is > that there are a class of records which the user should be able to view, but not > modify. For example, > the employee can create and modify working records as long as the only > modification to their status > is to move them on to "open status" (creating

Re: [SQL]

2001-01-29 Thread Jan Wieck
Olivier PRENANT wrote: > set nomail ERROR: permission denied Jan -- #==# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #=

Re: [SQL] Hrm...why is this wrong?

2001-02-08 Thread Jan Wieck
Ken Corey wrote: > Wow! Answering emails on a Sunday? Someone should be giving you an award or > something. > > On Sunday 04 February 2001 8:13 pm, you wrote: > > Ken Corey <[EMAIL PROTECTED]> writes: > > > When the select at the bottom of this email is executed, I'm getting the > > > message: >

Re: [SQL] Is this a bug, or is it just me?

2001-02-08 Thread Jan Wieck
Josh Berkus wrote: > Tom et al. > > Discovered this quirk in foriegn keys: > > In the preliminary version of a database, I added foriegn > key constraints to a number of tables, linking them to a > column in a shared reference table (status.status) that was > only one-half of a composite primary k

[SQL] Re: PL/pgsql EXECUTE 'SELECT INTO ...'

2001-02-08 Thread Jan Wieck
Tom Lane wrote: > I have looked a little bit at what it'd take to make SELECT INTO inside > an EXECUTE work the same as it does in plain plpgsql --- that is, the > INTO should reference plpgsql variables, not a destination table. > It looks to me like this is possible but would require some nontri

Re: [HACKERS] Re: [SQL] PL/PGSQL function with parameters

2001-02-08 Thread Jan Wieck
Tom Lane wrote: > Michael Ansley <[EMAIL PROTECTED]> writes: > > CREATE FUNCTION table_count(varchar) RETURNS integer AS ' > > DECLARE > > SQL varchar; > > RES integer; > > BEGIN > > SQL = ''SELECT * INTO temp1 FROM '' || $1; > > EXECUTE SQL; > > SELECT count(*) INTO RES FROM temp1; > > RETU

Re: [SQL] PL/PGSQL function with parameters

2001-02-08 Thread Jan Wieck
Josh Berkus wrote: > Tom, Jan, Michael, > > > While I have not looked closely, I seem to recall that plpgsql handles > > INTO by stripping that clause out of the statement before it's passed to > > the SQL engine. Evidently that's not happening in the EXECUTE case. > > > > Jan, do you agree this

Re: [SQL] Trigger question

2001-02-14 Thread Jan Wieck
Dave Wedwick wrote: > Hi! > > I have a table with an int4 field called inserttime. Regardless of what > the user enters in this field, I want a trigger to put now() into it. > > What's the syntax for the trigger? Sample: CREATE TABLE t1 ( id serial PRIMARY KEY,

Re: [SQL] Need your help

2001-02-28 Thread Jan Wieck
Jie Liang wrote: > e.g. > Try: > > CREATE TABLE emp ( > id int4 primary key, > empname text, > salary int4, > last_date datetime, > last_user name); > > CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS > BEGIN >update emp set last_date=''now''::timestamp where id=NEW.id;

Re: [SQL] Help creating rules/triggers/functions

2001-03-03 Thread Jan Wieck
Blaise Carrupt wrote: > Hi all ! > > I use PostgreSQL 7.0.2 on a HP-UX system. > > I would like to create a simple function and a simple trigger (or rule) that > deny a delete from a table if the row is referenced in another table. > > I though it should look like this (from my Ingres experience..

Re: [SQL] PL/PgSQL and NULL

2001-03-15 Thread Jan Wieck
Jie Liang wrote: > > I think that is a bug in plpgsql, > when passing a NULL into a plpgsql defined function, it treats > other arguments as NULL also, you can use raise notice in > your function to watch this buggy thing(see following). You're blaming the wrong code for it. It's an insuffi

Re: [SQL] PL/pgSQL "compilation error"

2001-03-15 Thread Jan Wieck
Josh Berkus wrote: > This brings up an important point. We have a medium-large user base for > PL/pgSQL out there, but it appears that Jan Wieck no longer has time to > develop the language ... nor should he be the sole developer. Howe do > we find more developers to expand &

Re: [SQL] pl/Perl

2001-03-15 Thread Jan Wieck
Jie Liang wrote: > Tom, > > 1.Where or how I can get pltcl.so? I have not find this file anywhere in > my > source except a pltcl.c. > 2.Dose installation same as plpgsql? > i.e. > CREATE FUNCTION pltcl_call_handler () RETURNS OPAQUE AS > '/usr/local/pgsql/lib/pltcl.so' LANGUAGE 'C'; > C

Re: [SQL] FETCH ... INTO in PL/pgSQL

2001-03-15 Thread Jan Wieck
Josh Berkus wrote: > Tom, Bruce, > >Is there any way to make use of the contents of a cursor in a PL/pgSQL > function? FETCH ... INTO isn't supported, according to the docs. Can I > use the dot notation, or something similar? PL/pgSQL doesn't support cursors at all. That's basically a

Re: [SQL] creating "job numbers"

2001-03-22 Thread Jan Wieck
postgresql wrote: > How are you professionals handling this problem? I like the ability to > insert and have the system give me the number. As I grow into more > workstations inputting the jobs I won't have to worry about chasing > the next highest number. Two possible ways: 1. If you

Re: [SQL] creating "job numbers"

2001-03-23 Thread Jan Wieck
postgresql wrote: > Jan, > > Thanks, I must be missing something here. Bear with me, I am > trying to form an intelligent question. > > Using the serial data type... I don't understand when the backend > would skip a number. > If the db is assigning the number with the insert, then if two (or > mo

Re: [SQL] trigger output to a file

2001-03-23 Thread Jan Wieck
pgsql-sql wrote: > Hello Everyone, > > Here's my simple question. > > I just want to know/get the recent changes made to a table. > Deeper? I wanted the Postgresql server to *publish* every > changes made to a table (similar to replication, incremental transfer, > etc.). > What is the best way to

Re: [SQL] all views in database broken at once

2001-03-25 Thread Jan Wieck
Tom Lane wrote: > Andrew Perrin <[EMAIL PROTECTED]> writes: > > But I'm intrigued: what is it that causes this? Is it *my* > > recreating the view on which the other views depend, > > Yes. You dropped and recreated the view --- the new version may have > the same name but it's not the same OID, s

Re: [SQL] all views in database broken at once

2001-03-27 Thread Jan Wieck
Mathijs Brands wrote: > On Sat, Mar 24, 2001 at 11:36:56PM -0500, Tom Lane allegedly wrote: > > Mathijs Brands <[EMAIL PROTECTED]> writes: > > > How about being able to recompile them (keeping the SQL around in the > > > system catalogs)? Doesn't Oracle allow you to do something like that? > > > >

Re: [SQL] Functions and Triggers

2001-03-27 Thread Jan Wieck
Cedar Cox wrote: > > CREATE FUNCTION lastupdated() RETURNS opaque AS ' > begin > new.last_updated := CURRENT_TIMESTAMP; > return new; > end; > ' LANGUAGE 'plpgsql'; > > CREATE TRIGGER trigname BEFORE INSERT OR UPDATE on tblname > FOR EACH ROW EXECUTE PROCEDURE lastupdated(); > > Note: you co

Re: [SQL] Error explaination?

2001-04-25 Thread Jan Wieck
Josh Berkus wrote: > Folks, > >I have a fuction that creates a record in a table called user_locks, > does a bunch of stuff, then deletes the record. However, when I try to > run it, I get the following error: > > ERROR: triggered data change violation on relation "user_locks" > >It appe

Re: [SQL] rules

2001-04-26 Thread Jan Wieck
Martín Marqués wrote: > Is it posible to make a rule execute more then one query? > > Something like: > > CREATE RULE rule_name AS ON INSERT TO table1 > DO INSTEAD > INSERT INTO table2 VALUES > (new.value1,new.value2) > INSERT INTO table3 VALUES > (x,y) Yes: CREATE RULE rule_name AS

Re: [SQL] select only the first record

2001-07-10 Thread Jan Wieck
[EMAIL PROTECTED] wrote: > Hello there > > Is it possible to do a query and selecting only the first record in ad > table ? > > e.g. select FIRST * from cars You can either use a CURSOR and FETCH only the first row, or use LIMIT (non-standard). And you might want to explicitly O

Re: [SQL] can we write to a flat file from Postgresql procedure

2001-07-11 Thread Jan Wieck
R Vijayanath wrote: > Hi, > > I found your name in the Postgresql web site. > > It would be great if you can tell me if I can write a > procedure that can write the output to the OS(Linux > OS) file. > > Can you assist me on this if there is a way to do it. > > We are using Postgresql 7.1 running

[SQL] Re: [GENERAL] Cross database foreign keys

2001-07-06 Thread Jan Wieck
Morgan Curley wrote: > Does anyone know if it is possible to connect to a differernt db from > within a plsql function. > I have multilple inter-related schemas and want to enforce some fk > relationships. PL/pgSQL doesn't support external database connects. PL/TclU does. But keep i

Re: [SQL] SPI_exec does not return!

2001-07-18 Thread Jan Wieck
Markus Wagner wrote: > Hi, > > if I do a SELECT on a non-existing table, SPI_exec won't return. > I get, e. g. in pgaccess, an error message " does not exist", > and my code below the function call is never reached. Right, the SPI_exec() call in turn calls the PostgreSQL parser and

Re: [SQL] Possible problems with cyclic references

2001-07-23 Thread Jan Wieck
Gary Stainburn wrote: > Hi all, me again. > > I've been looking at the doc's again (must stop doing that!) > > I've been looking at the 'references' clause to implement referential > integrity. My problem is that I'm wanting to create a cyclic reference, and > was wondering what problems this may

Re: [SQL] Re: PLpgSQL

2001-07-23 Thread Jan Wieck
Josh Berkus wrote: > Dado, > > > But still, the $1 is still plaguing me. > > > > Here's your problem: > > > >>CREATE FUNCTION new_proj_pts_seq(int4) > > >>RETURNS text > > >>AS 'DECLARE > > >>proj_ID alias for $1; > > >>seq_name TEXT; > > >>BEGIN > > >>seq_name := '

Re: [SQL] Why does this plpgslq always return 1?

2001-07-30 Thread Jan Wieck
Stephan Szabo wrote: > On Fri, 27 Jul 2001, John Oakes wrote: > > > Can anyone tell me why this always return 1? Thanks! > > > > CREATE FUNCTION passrate(date, date, text) RETURNS float AS ' > > > > DECLARE > > begindate ALIAS FOR $1; > > enddate ALIAS FOR $2; > > passfail ALIAS FOR $3; > > r

Re: [SQL] plpgsql function return multiple values?

2001-07-30 Thread Jan Wieck
John Oakes wrote: > Is it possible for a plpgsql function to return a record? I need to return > multiple values, and preferably in the form of a record. Thanks in advance! Not useful in any released version of PostgreSQL. In v7.2 you'll have at least the possibility to return a

Re: [SQL] Foreign key

2001-08-02 Thread Jan Wieck
Lorenzo De Vito wrote: > What's the best way to build a relation between two tables ? > I know that Foreign key is no longer supported. Who told you so? Jan -- #==# # It's easier to get forgiveness for being wrong than fo

Re: [SQL] Simple Insert Problem

2001-08-07 Thread Jan Wieck
[EMAIL PROTECTED] wrote: > Josh, > > Fuck you and the high horse you rode in on. Stop that language immediately! It is not accepted on any of our PostgreSQL mailing lists. > Yes as a matter of fact I did forget the quote marks. Do you think reading > that book will help with my silly sy

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Josh Berkus wrote: > Denis, > > > I have a case where I wanted to do circular REFERENCES, is this > > impossible ? > > It can be done. It's just a bad idea. I don't see why it is a bad idea to apply the full business model to the database schema. > > Now, each shop REFERENCES a custom

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Tom Lane wrote: > Jan Wieck <[EMAIL PROTECTED]> writes: > > The point is that we based our implementation of foreign keys > > on the SQL3 specs. DEFERRED is not in SQL-92 AFAIK. > > I still have a concern about this --- sure, you can set up the circular > ref

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Jan Wieck
Josh Berkus wrote: > Jan, > > > All of this is wrong. If the constraints are defined to be > > INITIALLY DEFERRED, all you have to do is to wrap all the > > changes that put the database into a temporary inconsistent > > state into a transaction. What is a good idea and

Re: [SQL] REFERENCES constraint

2001-08-08 Thread Jan Wieck
Josh Berkus wrote: > Cedar, > > > 1. Can a column reference more than one table? (This assumes you use > > a > > single sequence to generate the IDs for both "tbla" and "tblb". I > > guess > > you would also have the problem of enforcing a unique index. Say > > what?! > > A unique index across

Re: [SQL] on update restrict

2001-08-14 Thread Jan Wieck
Mister ics wrote: > Hi, > > I'm a little confused by the "on update restrict" option in a referential > integrity constraint. I don't know if i have not understood the meaning of > this statement or it does not work properly. > I think that if it is specified ON UPDATE RESTRICT in a foreign key >

Re: [SQL] Deadlocks? What happened to MVCC?

2001-08-14 Thread Jan Wieck
Josh Berkus wrote: > Folks: > > I'm getting deadlock errors on one of the operations on my web > application. It's a function which adds a large number of rows to a > holding table, then updates that set of rows multiple times in order to > present scoring information to the user. > > However, th

Re: [SQL] Date: the day before yesterday.

2001-08-14 Thread Jan Wieck
Jason wrote: > I am trying to retrieve records generated in the passed two days and > encountered difficulties in dealing with the date in Oracle. > Here is the query I try to form: > > select * from Table where InputDate>=[the day before yesterday] > > I tried "sysdate-2", didn't work. > Any sugg

Re: [SQL] result sets from functions...

2001-08-14 Thread Jan Wieck
Josh Berkus wrote: > Robert, > > > i'm reading the postgres documentation and i'm specifically > > interested in creating stored procedures so that i can keep > > as much of the business logic in the database as possible. > > while reading 13.1.3 (SQL Functions on Composite Types) in > > the Progr

Re: [SQL] on update restrict

2001-08-15 Thread Jan Wieck
Mister ics wrote: > > > > The behaviour is correct according to the SQL specifications. > > RESTRICT (as well as NO ACTION) means, you cannot change the > > primary key value of the referenced row. All other values can > > be changed of course. > > > > So an attempt to > > > >

[SQL] Re: [GENERAL] protected ON DELETE CASCADE

2001-08-23 Thread Jan Wieck
Murray Hobbs wrote: > > here's my problem > > i have tables A, B, C, D > > A <- B > A <- C <- D > > i want to maintain integrity so that if A is deleted from then so is > anything referencing from B and C - no problem ON DELETE CASCADE > > but if there are any D's that point back to A (through com

[SQL] Re: [GENERAL] protected ON DELETE CASCADE

2001-08-23 Thread Jan Wieck
Murray Hobbs wrote: > > i neglected to show it properly > > have tables A, B, C, D PLUS a few others > > A <- B > > F > | > v > A <- C <- D > ^ > | > E > > i want to delete from C and cascade any delete to E or F but not if > there are records in D > > what i have don

Re: [SQL] calling a shell script from pl/pgsql

2001-09-11 Thread Jan Wieck
Jeff Barrett wrote: > Thanks for the suggestions. > > I am running 7.1.2 and going to 7.1.3 soon. > > If I use pl/tclu or pl/perlu I can call this executable from within the > code? > > I have a signifigant limitation, I cannot duplicate the action of the > programs I want to call in a program I w

Re: [SQL] confounding, incorrect constraint error

2001-09-24 Thread Jan Wieck
Kevin Way wrote: > I'm unemployed at the moment and this is a pet project, so I can't offer > much in the way of financial compensation, but I'll start the bidding at > $50 donation in your name to your choice of the EFF, the Red Cross, or the > American Cancer Society, in return for a fix. (If n

Re: [SQL] CHECK problem really OK now...

2001-09-24 Thread Jan Wieck
Kovacs Baldvin wrote: > Hi everybody! > > I tried, and it works: the current CVS version really runs > happily the query what sent to heaven our 7.1 version of the > backend. > > Kevin: your original complex schema also runs smoothly. > > Thanks for our mindful developers! > > Regards, > Baldvin >

Re: [SQL] make a unique index for foreign keys?

2002-06-13 Thread Jan Wieck
Beth Gatewood wrote: > > Chris/ Josh- > > OK-response to Chris below. Synopsis heresimply by creating a foreign > key will not create an index. On large tables I SHOULD put a non-unique > index on the foreign key (right?) Right, because on DELETE or UPDATE to the primary key, the

Re: [SQL] ON DELETE CASCADE question

2002-06-14 Thread Jan Wieck
Josh Berkus wrote: > > Wei, > > > Does ON DELETE CASCADE attribute you specify in CREATE TABLE > > statement > > actually create triggers for every foreign key it refers to? > > > > Yes. Two triggers for each key, I think. Three, one for INSERT OR UPDATE on the FK table, one for UPDAT

Re: [SQL] function not running after upgrade from 7.03 to 7.2

2002-06-14 Thread Jan Wieck
[EMAIL PROTECTED] wrote: > > Hello > > I have three functions running under 7.03, Now, after the Upgrade to 7.2 > these functions are not working. > What has changed in version 7.2 that causes this problem. > > Function : > > CREATE FUNCTION "buildUmfang"("bpchar") RETURNS "text" AS 'DECLARE >

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Jan Wieck
Bruno Wolff III wrote: > > On Fri, Jun 21, 2002 at 10:30:54 +0200, > Michael Agbaglo <[EMAIL PROTECTED]> wrote: > > > > of course you could sort by DOY but then you'll have a problem w/ the > > next year: > > > > if it's let's say december and you select the list for the next 60 days, > > perso

Re: [SQL] pg_restore cannot restore function

2002-07-01 Thread Jan Wieck
Sent: Friday, June 28, 2002 1:46 PM > To: 'Jan Wieck' > Cc: 'Bruce Momjian'; '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]' > Subject: RE: [SQL] pg_restore cannot restore function > > No any error msg in the logfile, I didn't see any create funct

Re: [SQL] Rule WHERE condition problem

2002-07-09 Thread Jan Wieck
Kristian Eide wrote: > > I have a table with a reference constraint and an ON DELETE SET NULL action. > When this action triggers, I also want to update another field in the table, > actually a timestamp which should be set to NOW(). > > After reading some documentation it would seem a rule is t

Re: [SQL] Waiting for Update

2002-07-10 Thread Jan Wieck
JGM wrote: > > Could it be true?? > > I've a table with < 46000 rows. And a little Update like > > UPDATE foo set xxx = 'X'; > > needs about 15 seconds??? > > What's wrong? How long since you vacuumed that table? How big are the rows? Are there triggers, constraints, anything fancy? How many

  1   2   >