Re: [SQL] Getting row with id=max(id)

2001-06-12 Thread jeff
> A related question is: is there a way to time a query in psql, like the > client of MySQL does? use the explain commmand explain select * from foo; > > > ---(end of broadcast)--- > TIP 2: you can get off all lists at once with the unregister co

[SQL] large going giving errors.

2001-06-13 Thread jeff
uw.id=9 and the error ERROR: copyObject: don't know how to copy 704 can anyone shed a little light please ? jeff. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

RE: [SQL] large going giving errors.

2001-06-13 Thread jeff
i actually found the problem, SELECT o.name,o,contactname should be SELECT o.name,o.contactname jeff On Wed, 13 Jun 2001, Robby Slaughter wrote: > What happens when you don't join quite so much? That is, take off the AND > blah blocks, > one by one? > -Robby > >

[SQL] constraints,

2001-06-22 Thread jeff
Hello folks, wondering how to display any constraints that a table may have, as well i know alter table add constraint works, but what's the syntax to remove one ? i assume /alter table remove constraint, but i can't find any examples. jeff ---(end of

Re: [SQL] how do i insert an empty string ?

2002-10-15 Thread Jeff
?)"); $query->execute($md5, $origin, $name, $value); This way you don't have to deal with double quoting and all that. (You can also call bind_param, but I find it easier to just pass args into execute) -- J

[SQL] How to specify the beginning of the month in Postgres SQL syntax?

2003-12-09 Thread jeff
Hello, I need to create a view in Postgres that has a where clause of the date < beginning of month. i.e.: SELECT supplier_number, Sum(amount) AS due FROM purchase_orders WHERE date < '2003-12-1' AND paid = 0 GROUP BY supplier_number ORDER BY supplier_number ASC As you can see, I've specifi

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

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] [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] Fetch the latest log for each product

2000-08-17 Thread Jeff Hoffmann
t_transaction from log_tb l, prod_tb p where l.prod_id=p.prod_id group by p.prod_name, l.prod_id; i think that's what you want, at least... -- Jeff Hoffmann PropertyKey.com

[SQL] select

2000-09-23 Thread Jeff MacDonald
how would i select all rows where a boolean value is neither t nor f.. ? ie if someone inserted without setting the boolean tag. Jeff MacDonald, - PostgreSQL Inc | Hub.Org Networking Services [EMAIL PROTECTED] | [EMAIL

Re: [SQL] select

2000-09-23 Thread Jeff MacDonald
, Indraneel Majumdar wrote: > Hi, > > AFAIK, you can't enter a null value in a bool field, it has to be 1 or 0. > > \Indraneel > > On Sat, 23 Sep 2000, Jeff MacDonald wrote: > > > how would i select all rows where a boolean value is neither > > t

Re: [SQL] select

2000-09-23 Thread Jeff MacDonald
bingo, thaks On Sat, 23 Sep 2000, Stephan Szabo wrote: > > I'd assume this would work: > select * from table where booleanfield is null; > > Stephan Szabo > [EMAIL PROTECTED] > > On Sat, 23 Sep 2000, Jeff MacDonald wrote: > > > how would i select all

[SQL] Re: OID Perfomance - Object-Relational databases

2000-10-04 Thread Jeff MacDonald
e indexes are automatcally created on serials. > 2. Can I define my own index on the OIDs of a table? sure, create index oid_idx on table(oid); Jeff MacDonald, - PostgreSQL Inc | Hub.Org Networking Services [EMAIL

Re: [SQL] Table Attribute Help

2000-10-09 Thread Jeff Hoffmann
"Brian C. Doyle" wrote: > > Hello all, > > I am trying to find a query to retrive the attributes of a table as in \d > tablename but as a select command. Is this possible? run "psql -E" -- it will echo all of the sql queries that those commands use. -- Jeff Hoffmann PropertyKey.com

[SQL] substr

2000-10-19 Thread Jeff MacDonald
i noticed that substr behaves a bit different in pgsql than perl ie select foo from table where substr(foo,1,1) = 'X'; initially i thought it should be substr(foo,0,1) just wondering on the reasoning for this offset ? Jeff

Re: [SQL] substr

2000-10-19 Thread Jeff MacDonald
> Jeff MacDonald <[EMAIL PROTECTED]> writes: > > i noticed that substr behaves a bit different in pgsql than perl > > ie select foo from table where substr(foo,1,1) = 'X'; > > > just wondering on the reasoning for this offset ? > > Larry Wall a

Re: [SQL] fetching rows

2000-10-30 Thread Jeff Hoffmann
t how I can fetch rows from 26 to 50? I mean withou fetching first 25. Or > can I skip first 25? you can't do that with a cursor, but you can use they mysql-ism called a limit clause. for example, to fetch rows 26-50 from that query, you'd do: select * from films limit 25,26; or s

[SQL] substring ..

2000-12-19 Thread Jeff MacDonald
hi folks.. i want to do this to a datetime field.. select foo from table where substr(datefoo,1,11) = '2000-12-14'; it returns no results yet.. select substr(datefoo,1,11) does return some values that say 2000-12-14 any clues ? Jeff

[SQL] Use of RETURN in pl/pgsql function

2001-02-07 Thread Jeff Eckermann
My script is below. I thought (based on recent posts) that this use of RETURN is allowed, but when trying an insert to report_table, I get the following error: ERROR: control reaches end of trigger procedure without RETURN I have solved several problems in getting to this point, but have now r

RE: [SQL] Use of RETURN in pl/pgsql function

2001-02-07 Thread Jeff Eckermann
nsider every mystery, I'd never get any work done:-). Thanks very much for your help (again). > -Original Message- > From: Tom Lane [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, February 07, 2001 12:48 PM > To: Jeff Eckermann > Cc: '[EMAIL PROTECTED]' >

[SQL] COPY isn't working right for me

2001-02-13 Thread Jeff S.
I have a tab delimited file that I'm trying to import into an empty table. I've set the table up as follows: create table member ( member_id serial not null, fname varchar(25) not null, lname varchar(25) not null, member_since date not null, Primary Key (member_id) ); My member.txt file looks l

Re: [SQL] pl/Perl

2001-02-21 Thread Jeff MacDonald
using gmake instead of make (cd /usr/ports/devel/gmake, make) thanks ! works great. Jeff MacDonald, - PostgreSQL Inc | Hub.Org Networking Services [EMAIL PROTECTED] | [EMAIL PROTECTED] w

[SQL] pl/Perl

2001-02-21 Thread Jeff MacDonald
uot;../../../src/Makefile.global", line 292: Missing dependency operator "../../../src/Makefile.global", line 294: Need an operator "../../../src/Makefile.global", line 296: Need an operator "../../../src/Makefile.global", line 299: Need an operator "../..

[SQL] bug.. ?

2001-02-23 Thread Jeff MacDonald
A person recent pointed this out to me.. seems a bit funny, because limit 1 pretty much say's it't not gonna return multiple values. jeff > This doesn't work: > > CREATE FUNCTION vuln_port(int4) RETURNS int4 AS 'SELECT port FROM > i_host_vuln WHERE vuln = $1 G

[SQL] Re: logging a psql script

2001-02-23 Thread Jeff Duffy
> > DROP > DROP > DROP > CREATE > CREATE > CREATE > On UNIX/UNIX-like machines, use the script(1) command (man script for details). Jeff -- Errors have occurred. We won't tell you where or why. Lazy programmers. -- Hacking haiku

[SQL] How do I use text script containing SQL?

2001-03-05 Thread Jeff S.
I want to build my tables by placing all the sql statements in a file. What is the correct way to use this file with psql? Example: My text file has this in it: CREATE TABLE table1 ( table1_id serial, field1 char(5), PRIMARY KEY (table1_id) ); I want to be able to use the file to crea

[SQL] Help with UPDATE syntax

2001-03-15 Thread Jeff Putsch
eplacement, but get an error: NOTICE: current transaction is aborted, queries ignored until end of transaction block As noted earlier, any guidance will be most appreciated. Thanks, Jeff. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] RE: Still don't know how to build this string ?

2001-03-26 Thread Jeff Eckermann
Still learning this stuff, so please be gentle... jeff=# select * from test_it; typ | diam -+-- 01 | 800 01 | 840 01 | 870 01 | 1120 02 | 760 02 | 780 02 | 800 02 | 900 03 | 1200 03 | 1234 03 | 1352 (11 rows) jeff=# \! cat test_it drop function test_it_too(text

[SQL] RE: pl/pgsql and returning rows

2001-03-27 Thread Jeff Eckermann
As a workaround, you can insert your row into an existing table, then retrieve it from there later. I think you need to enumerate all of the fields, as in 'INSERT INTO table VALUES (ret.field1, ret.field2,...ret.fieldn);'. At least, I haven't succeeded any other way. Messy, but the best method a

[SQL] RE: counting distinct rows on more than one column

2001-03-28 Thread Jeff Eckermann
I don't think this will necessarily work: field1 | field2 aa | ab a | aab These are two distinct rows, so should be counted as two. The proposed method would count them as one. You can get around this problem by doing: count (distinct (a || x || b)) where x is some character not foun

[SQL] RE: serial type; race conditions

2001-03-29 Thread Jeff Eckermann
Probably just me: but I don't see the point. Consider: * User 1 commences insert transaction: grabs nextval(sequence), max(foo) * User 2 commences insert transaction: grabs nextval(sequence), max(foo) * User 1 commits * User 2 commits (insert has sequence value one higher

RE: [SQL] RE: serial type; race conditions

2001-04-05 Thread Jeff Eckermann
il 04, 2001 7:24 PM > To: Jeff Eckermann; 'Andrew Perrin' > Cc: PgSQL-SQL > Subject: RE: [SQL] RE: serial type; race conditions > > > It seems to just feel like conflicting requirements, so it's a tug-of-war. > > I've always done it by doing all t

FW: [SQL] RE: serial type; race conditions

2001-04-05 Thread Jeff Eckermann
s will become a problem. > -Original Message- > From: Jeff Eckermann > Sent: Thursday, April 05, 2001 10:36 AM > To: 'Gerald Gutierrez'; 'Andrew Perrin' > Cc: PgSQL-SQL > Subject: RE: [SQL] RE: serial type; race conditions > >

[SQL] RE: Re: select substr???

2001-04-10 Thread Jeff Eckermann
Regular expressions make this much easier. The below could be shortened to: create function ComparisonString(text) returns text as ' declare t alias for $1; r text; c char; begin if t is null or t !~ ''[^a-zA-Z0-9

[SQL] RE: Re: select substr???

2001-04-10 Thread Jeff Eckermann
And if you have plperl installed, something like this is even easier: create function texttrim(text) returns text as '$_[0] =~ s/\\W//g; return $_[0]' language 'plperl'; (I just read the docs) :-) > -Original Message- > From: Jeff Eckermann [SMTP:[EMAIL PROTECTE

[SQL] RE: RE: Re: select substr???

2001-04-12 Thread Jeff Eckermann
ically return > NULL as the result, doesn't it? > > Albert. > > > On Tue, Apr 10, 2001 at 05:41:26PM -0500, Jeff Eckermann wrote: > > Regular expressions make this much easier. The below could be shortened > to: > > > > create fun

Re: [SQL] RTREE on points

2001-04-16 Thread Jeff Hoffmann
a query by shutting off the sequential scans (set enable_seqscan=off) and retrying the query. essentially, this forces it to use an index scan if at all possible. -- Jeff Hoffmann PropertyKey.com ---(end of broadcast)--- TIP 5: Have you checked o

Re: [SQL] RTREE on points

2001-04-16 Thread Jeff Hoffmann
work, but there doesn't seem to be a lot of usage of the geometric functions by the developers to look at missing features -- they're mostly just reactive to problems. i really have never dug into tweaking access methods to get this to work, but i would imagine it's not that hard

Re: [SQL] RTREE on points

2001-04-17 Thread Jeff Hoffmann
but i thought there used to be at least a gist_box_ops. or was that another contrib item that got dropped? -- Jeff Hoffmann PropertyKey.com ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] RTREE on points

2001-04-17 Thread Jeff Hoffmann
ny built-in way of using it, if for no other reason than to be able to test if the feature even works. -- Jeff Hoffmann PropertyKey.com ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-noma

Re: [SQL] RTREE on points

2001-04-17 Thread Jeff Hoffmann
on in the standard distribution because it'd be easy to test -- you already have to run rtree tests anyway, you can just duplicate them with gist & gist_box_ops. -- Jeff Hoffmann PropertyKey.com ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] creating tables that are visible across databases

2001-04-20 Thread Jeff Hoffmann
created when you create a new database using that template (look at "createdb -T" to see how this works). this may not be what you're looking for because they wouldn't be shared across databases, they would just be copied into the new database when it was created. i don&#

Re: [SQL] SET SEQSCAN TO OFF - error

2001-04-26 Thread Jeff Hoffmann
Does anybody know why? > because the documentation is wrong. the variable name is ENABLE_SEQSCAN, i.e.: SET ENABLE_SEQSCAN TO OFF; should work. -- Jeff Hoffmann PropertyKey.com ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] "correct" sorting.

2001-05-02 Thread Jeff MacDonald
Hi folks, say i have a text field with teh values 1,2,3,10,20,30,1a,1b,2a,2b and i want to sort it so i get, 1 1a 1b 2 2a 2b 3 10 20 30 is there anyway to do that with postgresql ? below is what actually happens. jeff=> select * from foo order by var1; var1 -- 1 10 1a 1b 2

Re: [SQL] "correct" sorting.

2001-05-04 Thread Jeff Self
ut of course you won't be able to use characters in that. Therefore, create a second field called revision or whatever of text. Now you can sort correctly with: select * from foo order by var1,revision; On Thu, 3 May 2001, Jeff MacDonald wrote: > Hi folks, > > say i have a text fi

[SQL] RE: Order by email address by domain ?

2001-05-10 Thread Jeff Eckermann
I assume that you want to do this within the database, i.e. with a query. You would need to use a function, but I don't think a builtin function would do it. Try: CREATE FUNCTION email_order (text) RETURNS text AS ' select substr ($1, strpos ($1, ''@'') + 1) || substr ($1, 1, strpos ($1, ''@'') -1

[SQL] RE: Order by email address by domain ?

2001-05-11 Thread Jeff Eckermann
??? I don't think anyone suggested adding a new builtin function. Yes, your suggestion is good for an occasional use. Where this kind of functionality is likely to be needed on a continuing basis, my experience is that wrapping the code up in a custom function is easier and cleaner than writing it

Re: [SQL] execute client application from PL/pgSql

2001-05-11 Thread Jeff MacDonald
you could hack the pg_dump bit out of phpPgAdmin i think the license permits it. just my 2 cents. jeff On Wed, 9 May 2001, Jack wrote: > Date: Wed, 9 May 2001 09:45:46 +1000 > From: Jack <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: [SQL] execute client applica

Re: [SQL] execute client application from PL/pgSql

2001-05-14 Thread Jeff MacDonald
hi, phpPGAdmin is a web based php driven postgresql admin tool. not sure of the exact url, try google :) it has a pg_dump option in it. jeff On Sat, 12 May 2001, datactrl wrote: > Date: Sat, 12 May 2001 10:23:39 +1000 > From: datactrl <[EMAIL PROTECTED]> > To: [EMAIL PROTE

[SQL] seleting all dates between two dates

2001-06-06 Thread Jeff Barrett
: I want all dates between 05-29-2001 and 06-02-2001 The result set would be: 05-30-2001 05-31-2001 06-01-2001 Thanks for the help. -Jeff ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs

[SQL] Re: rpt

2001-06-12 Thread Jeff Boes
it is natively built in or some 3rd party > tool that I can use. Depends on what platform you want to run the report generator on. If you're happy with a Windows platform, you could connect Access or Crystal Reports, or a large number of other query

[SQL] create type of table

2001-07-06 Thread Jeff Barrett
ids and then write my queries to use this table. How can I do this in postgresql, I did not see any support for a type table. Anyone know of any good tutorials or how-tos for doing this type of stuff in postgresql? Thanks - Jeff ---(end of broadcast

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

2001-07-11 Thread Jeff Eckermann
I don't think there is any way to do this using any of the generally available tools. You could do a workaround using pl/pgsql, in the following way: * insert your data into a temp table * output the data to a file using COPY pl/pgsql allows INSERT statements, but does not allow CREA

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

2001-07-11 Thread Jeff Eckermann
I haven't seen anything on this list to say that pl/perlu is being worked on. Is it? > -Original Message- > From: Alex Pilosov [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, July 11, 2001 10:03 AM > To: Peter Eisentraut > Cc: R Vijayanath; [EMAIL PROTECTED] > Subject: Re: can we wr

[SQL] RE: pl/pgsql - code review + question

2001-07-18 Thread Jeff Eckermann
I think you need to use syntax: raise exception ''Member % Not Found'', unitno; > -Original Message- > From: Gary Stainburn [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, July 18, 2001 10:24 AM > To: pgsql-sql > Subject: Re: pl/pgsql - code review + question > > Okay, I've been hit r

[SQL] RE: pl/pgsql - code review + question

2001-07-18 Thread Jeff Eckermann
If the string will always be in that general form, use substring & position functions (see "String Functions and Operators" in the docs. Example: unit_number := substr(team_number, strpos(team_number, ''-'') + 1); If you don't want the leading zero, you could make make the "+1" into "+2". If you m

[SQL] RE: Records exactly the same.

2001-07-20 Thread Jeff Eckermann
If you include "oid" in your GROUP BY clause, you will get each distinct record. That will get you by for right now, but Josh's point is correct. You need some kind of unique key in your table. But... if you want to see every distinct record: why are you using a GROUP BY? > -Original Message

[SQL] RE: example of [outer] join

2001-07-20 Thread Jeff Eckermann
You could make your FROM clause something like: FROM members m INNER JOIN address a ON m.madd = a.aid INNER JOIN teams t ON m.team = t.tid LEFT JOIN emails e ON m.memail = e.eid I think that should work: if not, try putting everything between (but not including) FROM and LE

[SQL] RE: PLpgSQL

2001-07-20 Thread Jeff Eckermann
You will need to use "EXECUTE" to create the sequence. The docs on pl/pgsql cover it: basically, "EXECUTE string" will cause that string to be executed as a SQL statement. > -Original Message- > From: Dado Feigenblatt [SMTP:[EMAIL PROTECTED]] > Sent: Friday, July 20, 2001 2:26 PM > To:

[SQL] RE: Records exactly the same.

2001-07-23 Thread Jeff Eckermann
The content of your record is not limited to user data. Including a field that provides a unique key is simple: look at the documentation for data type SERIAL for an easy way to do this. You can also include information about when the record was inserted, and by whom, just by including fields in

[SQL] RE: position(text,text) function

2001-07-23 Thread Jeff Eckermann
You are confusing the syntax of two similar functions: position ('substring' in 'string') strpos ('string', 'substring'). I have a feeling that "position" actually calls "strpos", but I am guessing on that. > -Original Message- > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]] > Sent: Mo

Re: [SQL] performance issue with distance function

2001-07-26 Thread Jeff Hoffmann
> Thanks in advance. > this probably isn't what you want, but would it speed things up if you did an "order by distance" instead of doing the "distance <= 60", then having your application cut the results at 60? that should work from a language perspective, at le

[SQL] Restriction by grouping problem.

2001-07-26 Thread Jeff Barrett
the column getfile. So the question I have is how would I create the retstriction of the min(datetime), sid and only return the value of getfile? The english of what I am looking for is. Select the getfile for the earliest of each sid. Any help would be greatly appreciated. --Jeff

[SQL] Re: Restriction by grouping problem.

2001-07-26 Thread Jeff Barrett
) and I want this for every row in the table. Thanks for the quick response Josh, hopefully above will help out some. --Jeff ""Josh Berkus"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Jeff, > > > The query I ha

[SQL] RE: Fuzzy matching?

2001-07-31 Thread Jeff Eckermann
With version 7.2 we will have pl/perlu (untrusted), which will allow use of the various Perl modules which do this sort of thing. > -Original Message- > From: Josh Berkus [SMTP:[EMAIL PROTECTED]] > Sent: Tuesday, July 31, 2001 1:16 PM > To: Joe Conway; Bruce Momjian > Cc: Josh Berkus;

[SQL] RE: Referencing named attribute in where clause doesn't work with 7.1.2?

2001-08-08 Thread Jeff Eckermann
The WHERE clause is evaluated before your SELECT list is determined, so the aliased value cannot be used. You can put further NOT NULL tests into the subqueries to make sure that null values are not returned. Question: why not just join the tables explicitly? The more usual SQL approach would be

[SQL] RE: RE: Referencing named attribute in where clause doesn't work with7.1.2?

2001-08-08 Thread Jeff Eckermann
day, August 08, 2001 9:41 AM > To: [EMAIL PROTECTED] > Subject: Re: RE: Referencing named attribute in where clause doesn't > work with7.1.2? > > Jeff Eckermann wrote: > > > > The WHERE clause is evaluated before your SELECT list is determined, so > the

[SQL] Re: create function using language SQL

2001-08-14 Thread Jeff Eckermann
The "create function" syntax is the same. The language syntax is straight SQL: CREATE FUNCTION getteamno(int4) RETURNS varchar AS ' SELECT tregion || ''/'' || to_char(tnumber, ''FM000'') FROM teams WHERE tid = $1 ' LANGUAGE 'sql'; You don't get to build in error checking, but there has to be a

[SQL] \set variant for use in regular sql commands

2001-08-15 Thread Jeff Barrett
7;:testvar Which is then used in: select * from table where id in (:testvar); Thanks, --Jeff ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Jeff Eckermann
Why not just include examples of DATEDIFF and DATEADD functions? For example: CREATE FUNCTION datediff(timestamp, timestamp) RETURNS integer AS ' BEGIN RETURN $2 - $1; END; ' LANGUAGE 'plpgsql'; And similarly with DATEADD. You will increase the scope (and length) of your article, but only slightly

[SQL] Re: how to use record type

2001-08-17 Thread Jeff Eckermann
I have encountered this problem (in a different context), and could not find a way to insert entire rows/records in the way that you appear to want. But it worked fine if I INSERTed explicitly, like: INSERT INTO table VALUES (OLD.field1, OLD.field2, ..., OLD.fieldn); That should work fine inside

[SQL] Re: Simple SQL-syntax

2001-08-20 Thread Jeff Eckermann
UPDATE TableA SET nrA = TableB.nrB WHERE nrA = TableB.nrA;   UPDATE statements don't take FROM clauses.  I don't think they like aliasing, either. - Original Message - From: Fredrik Thunberg To: [EMAIL PROTECTED] Sent: Monday, August 20, 2001 6:15 AM Subject: Sim

[SQL] Re: Sequential select queries...??

2001-08-20 Thread Jeff Eckermann
Select id from T where name = 'bleh' UNION ALL Select id from T where description = 'bleh'; Will get you the resultset you want, but: I don't believe that you can do a GROUP BY on it. If you just want counts, as you describe below, you could do something like: SELECT 'Only One', (SELECT count (i

[SQL] Re: split/explode functions

2001-08-21 Thread Jeff Eckermann
Not amongst the builtin functions. You will need to create your own using a procedural language. Easiest is plperl, since Perl already has a very functional "split" function. - Original Message - From: "omid omoomi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, August 20, 20

[SQL] Re: Getting 'n-1'th record.

2001-08-21 Thread Jeff Eckermann
SELECT * FROM table ORDER BY field DESC LIMIT 1 OFFSET 1; This way you don't need to know the value of "n" in advance. The descending ORDER BY is to indicate a reversal of your intended ordering, so as to make the n-1'th record the second record. Note that getting the n-1'th record from an unorde

Re: [SQL] Help On Postgresql

2001-08-30 Thread Jeff Eckermann
a)  Look at "Date/Time Functions" in the docs: specifically, listed under "Functions and Operators" in the Users Guide. b) "Serial" type will do this.  Look under "Numeric Types" , in the "Data Types" section of the Users Guide. - Original Message - From: Jaydip To: [EMAIL

Re: [SQL] 2 tables, joins and same name...

2001-09-04 Thread Jeff Eckermann
I learned SQL from Sam's "Teach Yourself SQL in 21 Days", and am happy to recommend it. Which book is "best" is very subjective and situation dependent; all I can say is that this one did the job for me. Pros: clearly written; knowledgable authors; good coverage Cons: all due to space limitations

[SQL] row level locking?

2001-09-10 Thread Jeff Barrett
I have an update statement (no transaction controls surround these statements): update sessions set sessdate = 0 where sessid in ( long list of ids); How long will the rows being updated be locked for this statement? Will all be locked until all updates are completed or will the row locking only

[SQL] calling a shell script from pl/pgsql

2001-09-10 Thread Jeff Barrett
. Thanks, Jeff Barrett ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

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

2001-09-10 Thread Jeff Barrett
! Jeff Barrett "Jeff Barrett" <[EMAIL PROTECTED]> wrote in message 9nip2p$1s5o$[EMAIL PROTECTED]">news:9nip2p$1s5o$[EMAIL PROTECTED]... > How can I call a shell script from within a pl/pgsql function that is called > as from a trigger. I do not want to interact with the

Re: [SQL] How do I extract ONE particular field, when multiple table contain the same field name?

2001-09-14 Thread Jeff Eckermann
You need to qualify "DENOM" with the table name: just write "xi.DENOM". I find this to be good general practice when selecting from more than one table. - Original Message - From: "Olle Wijk" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 4:06 AM Subject:

Re: [SQL] Number the lines

2001-09-14 Thread Jeff Eckermann
If you want "the third maximum value", easist to do: SELECT * FROM table ORDER BY whatever DESC OFFSET 2 LIMIT 1; - Original Message - From: "Yoann" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 14, 2001 7:05 AM Subject: Number the lines > how can I number the res

Re: [SQL] transposing data for a view

2001-11-01 Thread Jeff Eckermann
--- James Orr <[EMAIL PROTECTED]> wrote: > I think he might be talking about mine. The region > values will not be > duplicated, the WHERE clause prevents it. If you are saying that I didn't read the original query closely enough, you're probably right. Unfortunately I deleted the original me

Re: [SQL] transposing data for a view

2001-11-01 Thread Jeff Eckermann
Josh, I don't see how you got the result you quote below. My query sums the volume figures, grouping by scanid: that worked as expected (one line per scanid) on my system when I tested it (version 7.1.2, though I don't think that matters). Jeff --- Josh Berkus <[EMAIL PROTECTED]&

Re: [SQL] Creating a boolean function

2001-09-19 Thread Jeff Eckermann
Maybe the reason is that you defined the function to return bool, but are attempting to return text? You need conditional logic, which suggests pl/pgsql is the way to go. Something simple should do it, like: create function check_loan (text,int,int) returns bool as ' begin select * from loans whe

[SQL] select is fast, update based on same where clause is slow

2001-09-21 Thread Jeff Barrett
causing this update statement to not complete? Why are the costs so different since it seems to me that besides the cost of the update they are the same query? Any help would be great! Jeff Barrett ---(end of broadcast)--- TIP 3: if posting

Re: [SQL] select is fast, update based on same where clause is slow

2001-09-21 Thread Jeff Barrett
That did the trick. Thank you for the quick detailed answer. It runs in about a minute now. Jeff Barrett "Stephan Szabo" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Fri, 21 Sep 2001, Jeff Barrett wrote: > > > I ha

Re: [SQL] ORDER BY case insensitive?

2001-10-03 Thread Jeff Boes
In article <PXEu7.602317$[EMAIL PROTECTED]>, "Bob Swerdlow" <[EMAIL PROTECTED]> wrote: > How do I get the rows sorted in a case insensitive way? > SELECT * FROM MyTable ORDER BY Name; Try SELECT * FROM MyTable ORDER BY upper(Name); (or &#

Re: [SQL] assign count() result to a declared variable in plpgsql

2002-06-24 Thread Jeff Eckermann
try: f_count_var := count(empno) from employee; --- Joseph Syjuco <[EMAIL PROTECTED]> wrote: > > i want to put my count() result in a plpgsql > declared integer variable > > > declare f_count_var integer; > begin > select into f_count_var count(empno) from employee > end; > > tried this

[SQL] to_char() and order-by

2002-06-27 Thread Jeff Boes
Perhaps this was covered in the 7.2.x release notes, but it's mystifying us: select to_char(time_link,'999.99') from stat_fetch where time_link is not null order by 1 desc limit 10; (time_link is a double-precision column.) Under 7.1.3, this returns results like: to_char - 9.99

Re: [SQL] PLPGSQL language documentation

2002-07-09 Thread Jeff Eckermann
I'll second the suggestion about looking at Oracle PL/SQL materials. I used an introductory PL/SQL text when learning about PLpgSQL, and found it very useful. The syntax/functionality is highly similar (by design, apparently). Much of the Oracle PL/SQL functionality is not (yet) implemented in P

Re: [SQL] "reverse()" on strings

2002-08-26 Thread Jeff Boes
h (iscachable); The same approach can be used to provide a regex match with Perl syntax, but I don't have an example of that coded up and at hand. -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer f

Re: [SQL] Retrieving the new nextval...

2002-08-28 Thread Jeff Eckermann
--- friedrich nietzsche <[EMAIL PROTECTED]> wrote: > Hi all, > I'm in trouble with the same problem, but in PHP.. > With your solution, I cannot be totally sure that > last > inserted raw was mine... > Because I'm on a web page, it could be that, as soon > as I've inserted my record, another one

[SQL] Large number of lookups

2002-08-30 Thread Jeff Boes
ect second_val union ...) as TEMP_TABLE using (SECONDARY_KEY_FLD) likewise, either taking some number of my desired values in "chunks" or all at once. What's likely to work better, and why? (I'm going off to write a benchmark script, but I'd like to hear some theoretic

Re: [SQL] still sorting and casting problems

2002-09-12 Thread Jeff Eckermann
--- [EMAIL PROTECTED] wrote: > I need to sort the query by the log_date desc > (log_date is char(10)). I > tried the following without success : > > select id, log_date from userlog order by cast > (log_date as date) desc > > select id, log_date from userlog order by > date(log_date) desc > >

Re: [SQL] Select the max on a field

2002-09-12 Thread Jeff Eckermann
--- Gaetano Mendola <[EMAIL PROTECTED]> wrote: > > "Gaetano Mendola" <[EMAIL PROTECTED]> wrote in > message > alq3mr$2s7o$[EMAIL PROTECTED]">news:alq3mr$2s7o$[EMAIL PROTECTED]... > > Hi all, > > > > Suppose that I have a table like this: > > > > > > att_1 |att_2 |att_3 | att_4 > >

[SQL] Query to evaluate space used

2002-09-18 Thread Jeff Boes
elect a.relname, b.relname, 0, b.relpages from pg_class a join pg_class b on (b.relname like 'pg_toast_' || a.relfilenode || '%') where a.relkind = 'r' ) as pg_class group by relname order by sum(relpages) desc offset 20) as "Others") as rows o

[SQL] Quartile (etc) ranking in a SQL statement?

2002-11-07 Thread Jeff Boes
(142 rows) How can I write a query that will return these as 1 | aaa | 1251 2 | aba | 1197 3 | cax | 1042 ... | ... | ... 142 | axq | 23 -- Jeff Boes vox 616.226.9550 ext 24 Database Engineer fax 616.349.9076 Nexcerpt

Re: [SQL] calculating interval

2002-11-22 Thread Jeff Boes
way. > The easiest way would be to write a function in a language that supports some kind of date library. I'm most familiar with Perl and its Date::Manip library, so that's what I would turn to. -- Jeff Boes vox 616.226.9550 ext 24 Database Engi

  1   2   3   >