Re: [SQL] DELETE WHERE EXISTS unexpected results

2010-12-01 Thread Jeff Bland
The second example you gave worked for me. Thanks Carla ! D. Jeff Bland z/OS System House Installation and Packaging (zSHIP) BLAND at IBMUS bl...@us.ibm.com http://w3.pok.ibm.com/zos/i95a/ 845-435-42108/295-4210 Famous quote: Beauty is in the eye of the beer holder. From: Carla To

[SQL] DELETE WHERE EXISTS unexpected results

2010-11-30 Thread Jeff Bland
I want to delete certain rows from table USER_TBL. Two tables are involved. USER_TBL and OWNER_TBL. The entries that match BLAND type in OWNER table and who also have a matching entry in USER table NAME but only for USER_TBL entries with places equal to HOME. DELETE FROM SP.TST_USER_TBL WH

Re: [SQL] PERSISTANT PREPARE (another point of view)

2008-07-22 Thread Jeff Williams
INNER JOIN Orders O ON C.CustomID=O.CustomID WHERE C.Name LIKE '%' || input || '%'; RETURN $1; END $$ LANGUAGE plpgsql; Then to use: BEGIN; SELECT test('curs', ); FETCH ALL FROM curs; END; Jeff -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] finding columns that have three or fewer distinct characters

2008-03-05 Thread Jeff Frost
On Wed, 5 Mar 2008, Osvaldo Rosario Kussama wrote: Jeff Frost escreveu: I've got an interesting one...I'm trying to find columns that have three or fewer distinct characters (for example, "aa"). Wondering if I need to write a function or if someone has an idea how

[SQL] finding columns that have three or fewer distinct characters

2008-03-05 Thread Jeff Frost
thing to do would be to lowercase everything, then remove all duplicate chars and spaces, then use length() on that, but it's not obvious to me how I might remove the duplicate chars with the pattern matching support in the docs. -- Jeff Frost, Owner <[EMAIL PROTECTED]&g

[SQL] DBLink or setof record functions & type shortcuts

2007-12-19 Thread Jeff Trout
('select * from someFooTypeReturningFunc()') as t1(col text, ) I could write select * from dblink('select ... ') as t1(footype) I've poked over the docs and googled around, haven't seen anything yet. -- Jeff Trout <[EMAIL PROTECTED]> http:/

[SQL] Why does the sequence skip a number with generate_series?

2007-10-03 Thread Jeff Frost
doesn't hurt anything, I'm just curious why it skips one after every generate_series insert? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(

Re: [SQL] separating improperly grouped page views

2007-07-05 Thread Jeff Frost
On Sun, 17 Jun 2007, Jeff Frost wrote: On Mon, 18 Jun 2007, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: [ umpteen million iterations of: ] -> Limit (cost=0.00..367.09 rows=1 width=8) -> Index Scan Backward using page_view_

Re: [SQL] separating improperly grouped page views

2007-06-19 Thread Jeff Frost
On Sun, 17 Jun 2007, Jeff Frost wrote: - Seq Scan on page_view pv1 (cost=0.00..11529031.34 rows=3580205 width=239) SubPlan -> Result (cost=1.58..1.59 r

Re: [SQL] separating improperly grouped page views

2007-06-17 Thread Jeff Frost
On Mon, 18 Jun 2007, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: [ umpteen million iterations of: ] -> Limit (cost=0.00..367.09 rows=1 width=8) -> Index Scan Backward using page_view_stamp_idx on page_view pv2 (cost=0.00..158215

[SQL] separating improperly grouped page views

2007-06-17 Thread Jeff Frost
explain analyze output yet. Does anyone have a better method of separating this data out? --- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)

Re: [SQL] COPY FROM - force a value

2007-02-08 Thread Demel, Jeff
That works like a charm. Thanks, Alvaro! -Jeff -Original Message- From: Alvaro Herrera [mailto:[EMAIL PROTECTED] Sent: Thursday, February 08, 2007 1:22 PM To: Demel, Jeff Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] COPY FROM - force a value Demel, Jeff wrote: > Is there a way

[SQL] COPY FROM - force a value

2007-02-08 Thread Demel, Jeff
LIMITER AS ' ', forcevalue1 = 1, forcevalue2 = 'this value' ; TIA -Jeff This email is intended only for the individual or entity to which it is addressed. This email may contain information that is privileged, confidential or otherwise protected from disclosure. Dissem

Re: [SQL] metaphone and nysiis in postgres

2007-02-08 Thread Demel, Jeff
;t have to juggle users, permissions, and settings. -Jeff -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: Thursday, February 08, 2007 3:06 AM To: Demel, Jeff Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] metaphone and nysiis in postgres Demel, Jeff wrote: >

Re: [SQL] metaphone and nysiis in postgres

2007-02-07 Thread Demel, Jeff
Can this be installed easily on Windows? -Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Demel, Jeff Sent: Wednesday, February 07, 2007 2:13 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] metaphone and nysiis in postgres Ah! Cool. Contrib

Re: [SQL] metaphone and nysiis in postgres

2007-02-07 Thread Demel, Jeff
Ah! Cool. Contrib/fuzzystrmatch has metaphone. Looks like it has soundex and levenschtein too. Thanks! -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 07, 2007 2:09 PM To: Demel, Jeff Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] metaphone and

[SQL] metaphone and nysiis in postgres

2007-02-07 Thread Demel, Jeff
Microsoft SQL server has two extended stored procedures that I need in Postgres: xp_nysiis and xp_metaphone. They do fuzzy matching on strings. Are there Postgres alternatives for these? Or maybe some other way to do phonetic/fuzzy matching that would be as effective? -Jeff -Original

Re: [SQL] Nocount and scope_identity()

2007-02-02 Thread Demel, Jeff
t; I haven't gotten there yet, but I'm also wondering if the > SCOPE_IDENTITY() method is going to work or not. I doubt it. What does it do? It returns the id of the record just inserted. -Jeff This email is intended only for the individual or entity to which it is addressed.

[SQL] Nocount and scope_identity()

2007-02-02 Thread Demel, Jeff
o, I'm wondering if NOCOUNT is supported in Postgres at all. If it's not, what's the alternative? If it is, what is wrong with my syntax? I haven't gotten there yet, but I'm also wondering if the SCOPE_IDENTITY() method is going to work or not. TIA -Jeff This email is in

Re: [SQL] How to query by column names

2007-01-22 Thread Jeff Frost
On Tue, 23 Jan 2007, Josh Williams wrote: From: Jeff Frost <[EMAIL PROTECTED]> On Mon, 22 Jan 2007, Richard Ray wrote: ... That's definitely part of it. I'm assuming the above is an abridged example and the OP is doing something dynamic with the query. The real trouble i

Re: [SQL] How to query by column names

2007-01-22 Thread Jeff Frost
On Mon, 22 Jan 2007, Richard Ray wrote: On Mon, 22 Jan 2007, Jeff Frost wrote: So why are you avoiding "SELECT * FROM t1;" ? I was affeared that if I brought my total ignorance to light I would be band from the list but here goes. I work in UNIX/Linux environments. It's my

Re: [SQL] How to query by column names

2007-01-22 Thread Jeff Frost
pg_class where relname = 't1') and attisdropped = false and attnum > 0) is a substitute for * On Mon, 22 Jan 2007, Jeff Frost wrote: Perhaps I should have asked this earlier. What information are you trying to extract? On Mon, 22 Jan 2007, Richard Ray wrote: This is not exactly what

Re: [SQL] How to query by column names

2007-01-22 Thread Jeff Frost
Perhaps I should have asked this earlier. What information are you trying to extract? On Mon, 22 Jan 2007, Richard Ray wrote: This is not exactly what I need I want to return the data in t1 On Mon, 22 Jan 2007, Jeff Frost wrote: I think this is what you're looking for Richard: S

Re: [SQL] How to query by column names

2007-01-22 Thread Jeff Frost
e row returned by a subquery used as an expression Thanks Richard ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://

Re: [SQL] hi any one can help me

2006-12-03 Thread Jeff Lu
You will need to manually remove the postgresql folder under Program files because uninstalling does not remove that folder for you. - Original Message From: Penchalaiah P. <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Sunday, December 3, 2006 5:33:41 AM Subject: [SQL] hi any o

Re: [SQL] consistent random order

2006-11-30 Thread Jeff Herrin
Michael, I think you may have solved my problem. We're still experimenting with it but I think setseed is going to work. Thank you very, very much! Jeff Herrin - Original Message - From: Michael Fuhr <[EMAIL PROTECTED]> To: Jeff Herrin <[EMAIL PROTECTED]> Cc: Andreas K

Re: [SQL] consistent random order

2006-11-29 Thread Jeff Herrin
I don't think cursors are going to help in this case. The order by random() is still going to give different result sets on different pages. Jeff - Original Message - From: Andreas Kretschmer <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Wednesday, November 29, 2006

Re: [SQL] consistent random order

2006-11-29 Thread Jeff Herrin
I need it a little more random than that. In both these scenarios, the same items will always follow each other. Jeff - Original Message - Why not create a random seed between 1 and the number of possibilities in your web application when a user first hits the site, store that in

[SQL] consistent random order

2006-11-29 Thread Jeff Herrin
random set. That way, when I get to the 2nd page, i know i'm getting the dataset back in the same order that I had on page 1, and the offset works like normal. Is this even realistically possible? Thanks, Jeff Herrin

Re: [SQL] delete and select with IN clause issues

2006-11-08 Thread Jeff Frost
On Tue, 7 Nov 2006, Jeff Frost wrote: Well, it's been working wonderfully since the REINDEX, so I don't know what to say. Any idea if having a too small max_fsm_pages could hose an index, because I know that happened not too long before we started seeing this problem. The fsm set

Re: [SQL] delete and select with IN clause issues

2006-11-07 Thread Jeff Frost
rring, but it's possible the index was already damaged? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 3

Re: [SQL] delete and select with IN clause issues

2006-11-03 Thread Jeff Frost
On Fri, 3 Nov 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: Well, I spoke to soon on the it all works front. So, it's been reindexed and appears to be working properly now. I guess I'll keep an eye on it for a while. I didn't get your query suggestion in

Re: [SQL] delete and select with IN clause issues

2006-11-02 Thread Jeff Frost
On Fri, 3 Nov 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: BTW, just to make sure I get the right file to ship over if we have this again, it would be: /var/lib/pgsql/data/base/9366228/16204210 yes? Not necessarily --- the filename is initially the same as the index OI

Re: [SQL] delete and select with IN clause issues

2006-11-02 Thread Jeff Frost
On Fri, 3 Nov 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: On Thu, 2 Nov 2006, Tom Lane wrote: This seems pretty darn weird. I am wondering about corrupt indexes --- can you find the indicated key in either table if you set enable_indexscan and enable_bitmapsca

Re: [SQL] delete and select with IN clause issues

2006-11-02 Thread Jeff Frost
On Thu, 2 Nov 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: delete from visit where id not in (select distinct visit_id from page_view); This yields the following error: ERROR: update or delete on "visit" violates foreign key constraint "fk34afd255fb

Re: [SQL] delete and select with IN clause issues

2006-11-02 Thread Jeff Frost
On Thu, 2 Nov 2006, Jeff Frost wrote: I'm having problem with a cleanup script that runs nightly. The script calls the following query: delete from visit where id not in (select distinct visit_id from page_view); This yields the following error: ERROR: update or delete on "visit

[SQL] delete and select with IN clause issues

2006-11-02 Thread Jeff Frost
;page_view_visit_idx" btree (visit_id) Foreign-key constraints: "fk34afd255fbacabec" FOREIGN KEY (visit_id) REFERENCES visit(id) What kind of silliness am I forgetting? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Disk is full, what's cool to get rid of?

2006-07-27 Thread Jeff Frost
up on filesystem maintenance/tweaking... Scott Marlowe wrote: I can't tell you the number of times that little trick has saved my life. On Thu, 2006-07-27 at 11:32, Jeff Frost wrote: You can probably just "tune2fs -m 0 " to give yourself enough space to get out of the jam before yo

Re: [SQL] Disk is full, what's cool to get rid of?

2006-07-27 Thread Jeff Frost
one who set up this box and there has been virtually no administration or maintenance on it that I know of...) How about the WAL files in pg_xlog? How critical are they when no data on the system is critical in and of itself? Any suggestions would be greatly appreciated... -- Je

Re: [SQL] PostgreSQL server terminated by signal 11

2006-07-27 Thread Jeff Frost
terminated: Daniel, I would guess this is more appropriate for the -admin list so I cc'd it. I think you are most likely running out of memory or running up against a ulimit on memory. I would first check my ulimit settings on the postgres user and see if they are a bit small. -- Jeff

Re: [SQL] keeping last 30 entries of a log table

2006-06-21 Thread Jeff Frost
last 30 items per each account_id...so each account_id will have his last 30 messages in the table. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadc

Re: [SQL] keeping last 30 entries of a log table

2006-06-20 Thread Jeff Frost
27;t be too bad. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will

Re: [SQL] keeping last 30 entries of a log table

2006-06-19 Thread Jeff Frost
#x27;s no way to get around the subselect though. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 6: explain analyze is your friend

[SQL] keeping last 30 entries of a log table

2006-06-16 Thread Jeff Frost
elect id from log where account_id = 1 order by timestamp desc limit 30); I'm wondering if there is a more performance oriented method of doing the delete that I'm not thinking of. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingll

Re: [SQL] [pgsql-www] MySQL DB to PostgresSQL DB

2006-05-17 Thread Jeff MacDonald
node.net is an *excellent* resource. > > Thanks in advance. > > Jose > regards, J -- Jeff MacDonald Zoid Technologies, http://zoidtechnologies.com/ ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Multi-Column Constraints and Null Values

2006-04-29 Thread Jeff Frost
X foo_A_B_unique_idx ON foo (A,B); See the docs here: http://www.postgresql.org/docs/current/interactive/indexes-unique.html -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954

Re: [SQL] find all tables with a specific column name?

2006-04-21 Thread Jeff Frost
On Fri, 21 Apr 2006, Bruno Wolff III wrote: On Fri, Apr 21, 2006 at 09:29:33 -0700, Jeff Frost <[EMAIL PROTECTED]> wrote: Is there a reasonable way to extract a list of all tables which contain a specific column name from the system views on 8.1? For instance, I might want to enumera

[SQL] find all tables with a specific column name?

2006-04-21 Thread Jeff Frost
Is there a reasonable way to extract a list of all tables which contain a specific column name from the system views on 8.1? For instance, I might want to enumerate all tables with a column named last_modified. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC

[SQL] Joins involving functions

2006-04-10 Thread Jeff Boes
I have a function that returns a row from a table, e.g.: create table foo (a integer); create function f_foo (integer) returns foo language 'sql' as $foo$ select * from foo where a = $1 limit 1 $foo$ create table bar (b integer); select * from bar cross join f_foo(bar.b) as foo; Unfortunatel

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Jeff Frost
remedy the problem. Is postgres logging any errors? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 1: if postin

Re: [SQL] Power cut and performance problem

2006-03-20 Thread Jeff Frost
it should be (hopefullY) fixed by tomorrow morning. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Power cut and performance problem

2006-03-20 Thread Jeff Frost
atabase suffers from performance since. For example, a simple query such as "SELECT MIN(a-primary-key-column) FROM a-table" takes quite a very long time; actually I gave up before getting the result. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.fro

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-20 Thread Jeff Frost
rd and not credit_card_audit. Are you saying that it could cause this sort of problem even though it doesn't fire? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-18 Thread Jeff Frost
CONSTRAINT credit_card_audit_account_id_fkey FOREIGN KEY (account_id) REFERENCES accounts_basics (id) MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED Now that I've got a test case for you guys to look at, I'm off to rewrite our standard procedure to use TRUNCATE instea

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Jeff Frost wrote: I'll try that and see if that makes the difference, since we're recreating (create or replace) that function in that transaction anyway, but perhaps that needs to happen before the update. I added this at the top of the transaction: DRO

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
x27;re recreating (create or replace) that function in that transaction anyway, but perhaps that needs to happen before the update. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FA

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
hanging a NOT NULL constraint. I didn't think this to be the expected behavior for this query, so I thought I'd post and see whether I was thinking along the wrong lines. If this is the expected behavior, then TRUNCATE...ALTER TABLE appears like the way to go in the future. Tha

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Jeff Frost wrote: Could we see a complete test case, rather than handwaving? I'd expect some issues like this if you were using any prepared statements or plpgsql functions with non-EXECUTEd queries involving the dropped table, but your description doesn't ment

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: After commit, I get a lovely: ERROR: could not open relation with OID x Could we see a complete test case, rather than handwaving? I'd expect some issues like this if you were using any prepared st

[SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
COMMIT; After commit, I get a lovely: ERROR: could not open relation with OID x Is this expected? To solve this, I simply moved my initial update outside the transaction. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phon

Re: [SQL] Check/unique constraint question

2006-03-05 Thread Jeff Frost
On Sun, 5 Mar 2006, Michael Glaesemann wrote: On Mar 5, 2006, at 17:25 , Jeff Frost wrote: I believe you're looking for what is called a partial index. http://www.postgresql.org/docs/current/interactive/indexes-partial.html create unique index foo_partial_idx on foo (id) where a

[SQL] Check/unique constraint question

2006-03-05 Thread Jeff Frost
active='t'),id) But the above does not appear to exist. Is there a simple way to create a check constraint for this type of situation, or do I need to create a function to eval a check constraint? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http:

Re: [SQL] [GENERAL] bug with if ... then ... clause in views

2006-01-18 Thread Jeff
ething else' end as blah, public.Z_documents as d ... -- Jeff Trout <[EMAIL PROTECTED]> http://www.jefftrout.com/ http://www.stuarthamm.net/ ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-16 Thread Jeff Boes
Michael Glaesemann wrote: > > On Jan 14, 2006, at 23:54 , Jeff Boes wrote: > >> Tony Wasson wrote: > >> >> Sure, but that was not my question. I want to be able to set the >> variable on the command line, BUT have it default to a value inside >> the SQL

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-14 Thread Jeff Boes
Tony Wasson wrote: On 1/11/06, Jeff Boes <[EMAIL PROTECTED]> wrote: Stumped: is there any way to set up default values for psql variables within the .SQL file itself? Obviously, I can do something like: $ psql -f my_script -v MYVAR=${myvar:-mydefault} but I would prefer t

[SQL] psql client: technique for applying default values to :variables?

2006-01-11 Thread Jeff Boes
Stumped: is there any way to set up default values for psql variables within the .SQL file itself? Obviously, I can do something like: $ psql -f my_script -v MYVAR=${myvar:-mydefault} but I would prefer to have the value stored with the .SQL file, e.g. (if this actually worked): \set MYVAR COALE

Re: [SQL] Update timestamp on update

2005-10-12 Thread Jeff Williams
Tom Lane wrote: >Jeff Williams <[EMAIL PROTECTED]> writes: > > >>last_status_change timestamp DEFAULT now() >> >> > > > >>What I would like is that whenever the status is changed the >>last_status_change timestamp is updated to

[SQL] Update timestamp on update

2005-10-12 Thread Jeff Williams
would be similar to: CREATE RULE last_status_change AS ON UPDATE TO products WHERE NEW.status <> OLD.status DO UPDATE products SET last_status_change = now() WHERE id = OLD.id; Except of course that the above is recursive and doesn't work. How can I do

Re: [SQL] how to do 'deep queries'?

2005-09-26 Thread jeff sacksteder
Nevermind. It's late here and I'm not thinking clearly. Problem solved.

[SQL] how to do 'deep queries'?

2005-09-26 Thread jeff sacksteder
Is there supported syntax to do 'deep' queries? That is where A relates to B relates to C, returning fields from each table? This doesn't seem to work. Is there a google-able term for this sort of query? select    foo.aaa,    bar.bbb,    baz.ccc from    foo,bar,baz where    foo.bar_id = bar.i

[SQL] alter sequence + subqueries

2005-09-16 Thread jeff sacksteder
The postgres-specific sql extension 'ALTER SEQUENCE' does not appear to support subqueries. I have inserted some data into a table, including values in the primary key. I want to reset the associated sequence so that any further records to be inserted into that table  resume numbering correctly. T

[SQL] How to encrypt a column

2005-08-14 Thread Jeff Lu
Hi,   I'm interested in encrypting column in table.  Are there any example using "C" to create the encrypted column, inserting and retreiving data  to/from it?   Thank you  __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection aroun

Re: [SQL] Fwd: How to encrypt a column

2005-08-11 Thread Jeff Lu
t; = "0018`0018`64045`08112005`64045`1Discount=0.00;``2``~"   printf("%s", encrypt(data, "foo", "bar")) prints out (null) Thank youOwen Jacobson <[EMAIL PROTECTED]> wrote: Jeff Lu wrote:> Hi,>> I'm interested in encrypting an colum

[SQL] Fwd: How to encrypt a column

2005-08-11 Thread Jeff Lu
Hi,   I'm interested in encrypting an column in table.  Are there any example using "C" to create the encrypted column, inserting and retreiving data  to/from it?   the table is: CREATE TABLE mytable (  id SERIAL PRIMARY KEY,  crypted_content BYTEA ); I'm getting (null) in the field with t

Re: [SQL] How to alias table columns in result?

2005-08-11 Thread Jeff Boes
nori wrote: > Ok I got it. There is no way to alias all columns of some table with > some "prefix" that will be visible in result except to alias each > column. Only other way would be to write a view for each table, then write all your queries against the views. ---(end o

Re: [SQL] Breakdown results by month

2005-08-04 Thread Jeff Boes
Henry Ortega wrote: > I have the ff table: > > id |total| effective|end_date > john 6 01-01-200502-28-2005 > john 8 03-01-200506-30-2005 > > How can I return: > id |total| effective

[SQL] CREATE TABLE AS SELECT

2005-07-29 Thread Jeff Boes
lly a "username" constructor, making "jboes" out of "Jeff Boes"). The odd thing is that function f() also looks into the table "foo" to see if the value it's constructing is truly unique; if it is not, it tacks on a "1", "2", etc. until i

[SQL] Foreign key with check?

2005-07-27 Thread Jeff Boes
Given a table like this: create table primary ( a integer primary key, b boolean ); And another like this: create table secondary ( a integer, some_other_fields ); I would like a foreign key constraint on the "secondary" table that looks something like: foreign key (a, true) reference

Re: [SQL] [ANNOUNCE] pgtop, display PostgreSQL processes in `top' style

2005-05-04 Thread Jeff -
it only runs on linux and it must run on the same box as pg itself. You may want to look at it and see if you can get anything good out of it. queries / second is tricky. You could look at my pgspy utility but it is in C. It can give you queries / second data -- Jeff Trout <[EMAI

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
Forget that message. I need another cup of coffee! "Jeff Eckermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hi, >> I am new user of

Re: [SQL] DateAdd function ?

2005-04-19 Thread Jeff Eckermann
"Zlatko Matiæ" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am currently migrating from MSDE to PostgreSQL and have to rewrite the >function that is calculating next date of sampling... > In MSDE there is a DateAdd function. I can't find the appropriate function > in postgre.

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
"Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I am new user of PostGreSQL 8.0.1. While using it i faced following issue. > As SQL is Case insensetive Language So the Uper or Lower cases are not > significant. But while using the database there is pr

Re: [SQL] outer join in ms query

2005-04-18 Thread Jeff Eckermann
MS Query is crippled. If you want to do much from Excel, you will need to write code. But it's not difficult. ADO is a good choice for this. "gad renert via DBMonster.com" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, I am a novice with SQL, I have 2 tables > (transfer

Re: [SQL] DROP TYPE without error?

2005-04-07 Thread Jeff Boes
being generated automatically, based on data found in a database. If I understand you correctly, then this might be useful: begin; select now(); \o tmp.tmp \qecho 'drop type \"foofookitty\";' \o \! psql -f tmp.tmp select now(); commit; -- Jeff Boes

[SQL] finding schema of table that called a trigger

2005-03-13 Thread Jeff Hoffmann
Is there a variable defined that has the schema of the table that called the trigger (like TG_RELNAME = table name)? I didn't see anything in the documentation. Is the only way to get that to look it up with TG_RELID? -- Jeff Hoffmann [EMAIL PROTECTED] ---(e

Re: [SQL] Calendar Function

2005-02-03 Thread Jeff Boes
?column? - 2004-02-29 00:00:00 (1 row) Thus, given the original response to your question: select * from calendar('1 feb 2004', ( '1 feb 2004'::date + '1 month'::interval - '1 day'::interval )::date); -- Jeff Boes

Re: [SQL] Parsing a Calculation from a field

2005-01-11 Thread Jeff Eckermann
How are you getting the data from Excel? Perhaps you could use Excel's own methods to evaluate the cell contents? You may still need to do something for literal text values (e.g. 'NULL'), though. "Kieran Ashley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, Apologies if th

Re: [SQL] How to get the max on a char column?

2004-11-20 Thread Jeff Eckermann
--- Rodrigo Carvalhaes <[EMAIL PROTECTED]> wrote: > Hi ! > > I am quite confused of the results on a SELECT > max... > > My environment: > Conectiva Linux 10, PostgreSQL 7.4.6 (compiled from > the sources) > > My problem is the "select max(id) FROM test" the > result is 20 but the > right is 1

Re: [SQL] CREATE TYPE

2004-11-03 Thread Jeff
On Nov 3, 2004, at 10:56 AM, Ameen - Etemady wrote: I like to do it like this: create table mytmp(name myvarchar(10,"en_US")); you can't unless you modify the parser. It has special cases to support varchar (and numeric) syntax. -- Jeff Trout <[EMAIL PROTECTED]> http://ww

[SQL] How to recognize trigger-inserted rows?

2004-10-27 Thread Jeff Boes
I have a table with an INSERT/UPDATE/DELETE statement trigger. The trigger's action is to insert "jobs" into a queue noting that the table has changed. A number of other tables have FK relationships with this table, and they have their own statement triggers that fire on DELETE. When I delete

[SQL] How to recognize trigger-inserted rows?

2004-10-26 Thread Jeff Boes
I have a table with an INSERT/UPDATE/DELETE statement trigger. The trigger's action is to insert "jobs" into a queue noting that the table has changed. A number of other tables have FK relationships with this table, and they have their own statement triggers that fire on DELETE. When I delete a n

Re: [SQL] Stored Procedures returning a RECORD

2004-10-05 Thread Jeff Eckermann
--- Kent Anderson <[EMAIL PROTECTED]> wrote: > I am attempting to use a stored procedure to pull a > report from the > database. My questions is if its even possible to > pull the data using a > function and then treat the returned data as a > normal recordset with the web > pages. > > The actua

[SQL] psql variable interpolation from command line

2004-10-01 Thread Jeff Boes
why won't variable interpolation work when the "-c" flag is used? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ..

Re: [SQL] psql variable interpolation from command line

2004-10-01 Thread Jeff Boes
Ugh, never mind. I finally saw the reason in the 'psql' documentation. Missed it the first time. (And the second, and third, ...) -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nex

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Jeff Eckermann
--- Christopher Browne <[EMAIL PROTECTED]> wrote: > In an attempt to throw the authorities off his > trail, [EMAIL PROTECTED] ("Sandeep Gaikwad") > transmitted: > > Hello Sir, > > I want to know how to check > whether postgres database > > is running or not ? when I give command

Re: [SQL] Isnumeric function?

2004-09-09 Thread Jeff Eckermann
Ok, how about this. At least it works in my testing. I have extended it to allow a negative sign (trailing also), which I would expect to be allowed in a comprehensive "isnumeric" function. If I am wrong, feel free to slap me around; although correcting the regex would be more constructive. ;-)

Re: [SQL] Complicated "group by" question

2004-09-02 Thread Jeff Boes
Andrew Perrin wrote: I have a table of people ("reviewers"), a table of review assignments ("assign"), and a table of review acceptances ("accept"). I would like to be able to write a query to return the latest (e.g., max(assign_date)) assignment for each reviewer, plus the acc_id field from "accep

[SQL] Trigger and function not on speaking terms

2004-08-02 Thread Jeff Boes
Hmm, this is puzzling me: create or replace function fn_foo(text) returns trigger as ' begin # Do some stuff with $1 end; ' language 'plpgsql'; CREATE FUNCTION create table bar (aaa text); CREATE TABLE create trigger trg_bar after insert or update on bar execute procedure fn_foo('string'); ERROR:

Re: [SQL] Converting a plperlu function to a plpgsql function

2004-07-22 Thread Jeff Eckermann
--- Joe Conway <[EMAIL PROTECTED]> wrote: > Devin Whalen wrote: > > First line: > > my @active_tables=split(/,/,$tables); > > > > Is there anyway to split a variable like the perl > split above? > > I'm no perl guru, but in 7.4 I believe this does > what you're looking for: > > regression=# sele

[SQL] Inherited tables and new fields

2004-07-20 Thread Jeff Boes
This feels like a flaw in the way inherited tables work. I have a "template" table used to create other tables (but not by inheritance; instead the "daughter" tables are created via create table draft_00123 as select * from draft_template where false; This is done for somewhat historical reasons,

  1   2   3   >