Re: [SQL] SQL Subqueries on each result row

2009-09-23 Thread Jim
On Sep 23, 5:43 am, AnthonyV wrote: > Hello, > > I have a table like : > >    date        |    value > --- > 2009-09-19 |      1 > 2009-09-20 |      2 > 2009-09-21 |      6 > 2009-09-22 |      9 > 2009-09-23 |      1 > > I'd like a request which gives me the sum of each

Re: [SQL] [PERFORM] Performance on writable views

2007-08-13 Thread Jim Nasby
od of overlap surrounding the time when you switch to a new partition), you're looking at evaluating every input query twice. In this case, the rules presumably are just simply re-directing DML, so there'd only be one rule in play at a time. That means the only real ov

Re: [SQL] Adding "on delete cascade" to all foreign key constraints

2007-05-15 Thread Jim C. Nasby
ou could do that by querying the catalogs directly, but I think you'll find the pg_user_foreign_keys view defined by http://pgfoundry.org/projects/newsysviews to be most helpful. -- Jim Nasby [EMAIL PROTECTED] EnterpriseDB h

Re: [SQL] Doing a conditional aggregate (e.g. count(*) if x=y) in postgres?

2007-05-14 Thread Jim Buttafuoco
Use case statement and sum to get a count where status=20... For example Select sum(case when status=20 then 1 else 0 end) as status20, Sum(case when status=30 then 1 else 0 end) as status30 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Br

Re: [SQL] Dynamic prepare possible in plpgsql?

2007-05-07 Thread Jim Nasby
;NULL')) in the dynamic statement. -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner

Re: [SQL] hi

2007-04-24 Thread Wilkinson, Jim
Select sno AS "SNO", SELECT value AS "VALUE", get_sum(value) as SUM from temp; From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Penchalaiah P. Sent: April 24, 2007 8:09 AM To: pgsql-sql@postgresql.org Subject: [SQL] hi Hi I have

[SQL] Function to return a multiple colmn table or view

2007-04-20 Thread Wilkinson, Jim
I am new to psql , so please be patient ! Can someone please provide a small quick example of a a function that take 1 paramater and based on that parameter, returns a table or view ? Etc Note this is just a abstract of the functon, not a working function call !!! Create function viewtest(

[SQL] EXECUTE in a funtion to return a VIEW object ID

2007-04-10 Thread Wilkinson, Jim
Hi there, I have tried many ideas to get this working but no luck. Can some show me or explain what is happening EXAMPLE == I am trying to read to 2 text fields to combine them togther to form the name of a VIEW. example SELECT * FROM ( 'april'||'may') ; I have tried the EXECUTE i

Re: [SQL] Using a variable as a view name in a select

2007-04-03 Thread Wilkinson, Jim
PROTECTED] Sent: April 3, 2007 12:45 PM To: Wilkinson, Jim Cc: pgsql-sql@postgresql.org Subject: RE: [SQL] Using a variable as a view name in a select Jim So let's suppose you have a "master" table of incidents incident_no (serial) incident_date (timestamp) other fields My unders

[SQL] Using a variable as a view name in a select

2007-04-03 Thread Wilkinson, Jim
I have created a view, called april_may. I need to select this view by combineing to fields in the database to create the view name etc ... Create view as select * from table_X; I need to do something like this ... Select * from (select table.start_month||_||table.end_month); ==

[SQL] How too select different views using a IF/THEN/ELSE procedure ?

2007-03-28 Thread Wilkinson, Jim
Below is a select statement that select incidents by month. I need a function or a method to select differents views that will show the Month columns is a different order. Say Apr - Mar for a fiscal year. I need to do something like an if/then/else statement that selects the correct view to us

[SQL] Selecting different views from a Boolean expression

2007-03-26 Thread Wilkinson, Jim
Hi there, I have a web based reporting system that I am coding. I need to be able to view statistics by the calendar year or the fiscal year depending on what the user selects. My issue is how do I change y select statements to change the column output? Example IncidentJan

Re: [HACKERS] timestamp subtraction (was Re: [SQL] formatting intervals with to_char)

2007-02-23 Thread Jim C. Nasby
00:00:00'::timestamptz - '2004-01-01 > 00:00:00'::timestamptz; >?column? > -- >24:00:00 > (1 row) > > --- > > Jim Nasby wrote: > > On

[SQL] unsubscribe

2007-02-08 Thread Wilkinson, Jim
unsubscribe

Re: [SQL] Related tables to a view

2006-12-26 Thread Jim Buttafuoco
Try this query select a.relname as base,a.relkind from pg_class a join pg_depend d on (a.oid = d.refobjid) join pg_class c on (d.classid = c.oid) join pg_rewrite r on (objid = r.oid) join pg_class v on (ev_class = v.oid) where a.relkind in('r', 'v') and a.relname <> v.relname and v.relname='YOUR

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Jim Buttafuoco
Try select into a now() - interval ($1 || ' day') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Ray Sent: Tuesday, December 19, 2006 3:10 PM To: pgsql-sql@postgresql.org Subject: [SQL] Help with quotes in plpgsql How should this be properly qu

Re: [SQL] Rule for multiple entries

2006-12-13 Thread Jim Buttafuoco
Use a trigger instead, the rule is only run once per insert/update/delete while the trigger is run for each row. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of William Scott Jordan Sent: Wednesday, December 13, 2006 9:05 PM To: pgsql-sql@postgresql.org S

Re: [SQL] [pgadmin-support] Groups and Roles and Users

2006-11-16 Thread Jim Nasby
PostgreSQL docs? Roles aren't pgAdmin specific, afterall. -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) ---(end of broadcast)--- TIP 9: In versions

Re: [HACKERS] [SQL] Case Preservation disregarding case

2006-11-15 Thread Jim Nasby
g that for output column names, /d, etc. get shot down? I thought it would be a useful addition... -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) ---(end of broadcast)

Re: [SQL] [ADMIN] Is there anyway to...

2006-11-07 Thread Jim C. Nasby
cron job to decrement some counter every day, I think that's not the best approach. Instead, I'd run a query once a day that finds all students that are past-due and takes some kind of action. -- Jim Nasby[EMAIL PROTECTED] Enter

Re: [SQL] Can we convert from Postgres to Oracle !!???

2006-10-26 Thread Jim C. Nasby
On Sun, Oct 22, 2006 at 12:03:38AM +0300, Devrim GUNDUZ wrote: > On Tue, 2006-10-17 at 14:21 +0530, Sandeep Kumar Jakkaraju wrote: > > Can we convert from Postgres to Oracle !!??? You can also run our software and get Oracle syntax for 1/25th the cost. --

Re: [SQL] Grouping by day, limiting amounts

2006-10-19 Thread Jim C. Nasby
BY votes DESC LIMIT 3 ) ; Note that this has to scan the table twice (well, the second subquery will likely use an index on date). If you have another table that has the dates in it already, you can use that instead of the first subquery. If you know that every day has a

Re: [SQL] [HACKERS] Bug?

2006-10-19 Thread Jim C. Nasby
See section 9.12 of the docs. On Thu, Oct 19, 2006 at 12:28:58PM +0530, Indira Muthuswamy wrote: > Then how do we clear the values of a serial column(is it done only by > dropping the column?)? > > Regards, > M.Indira > > > > On 10/19/06, Jim C. Nasby <[EMAIL PR

Re: [SQL] hi i want help on levels

2006-10-18 Thread Jim C. Nasby
Search the archives for hierarchical query. -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] [HACKERS] Bug?

2006-10-18 Thread Jim C. Nasby
column a incremented to the value 21. > But I heard from my friends that the value of the serial column gets > decremented whenever we issue the 'truncate table' command (in MS SQL > SERVER).Is the concept same with PostgreSQL or not?Can anyone clarify me on >

Re: [SQL] Temp tables and functions

2006-10-10 Thread Jim C. Nasby
ipt that creates the function. You don't need to populate it or anything, you just need it to exist (prefferably with the correct definition). -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

Re: [HACKERS] timestamp subtraction (was Re: [SQL] formatting intervals with to_char)

2006-10-09 Thread Jim C. Nasby
On Mon, Oct 09, 2006 at 02:57:28PM -0500, Aaron Bono wrote: > On 10/5/06, Jim Nasby <[EMAIL PROTECTED]> wrote: > > > >On Oct 5, 2006, at 11:50 AM, Tom Lane wrote: > >> regression=# select ('2006-09-15 23:59:00'::timestamp - '2006-09-01

Re: [HACKERS] timestamp subtraction (was Re: [SQL] formatting intervals with to_char)

2006-10-05 Thread Jim Nasby
purposes. I agree it should be removed, but we might need a form of backwards compatibility for a version or two... -- Jim Nasby[EMAIL PROTECTED] EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) ---(end of broadcas

Re: [SQL] files or DataBase

2006-09-28 Thread Jim C. Nasby
ic, you might want to mix and match the two somehow. Here's what you don't want to do: have each page issueing 100 queries to the database. That's a great way to kill your performance and/or scaleability. -- Jim Nasby

Re: [SQL] Deleting Functions

2006-08-23 Thread Jim Buttafuoco
Scott, I use the following query with psql \o option. Change the schema name from public to whatever. I am sure you could put this into a plpgsql function using execute as well. Jim \o drops.sql select 'drop function ' || nspname || '.' || proname || '('

Re: [SQL] finding unused indexes?

2006-08-01 Thread Jim Buttafuoco
check out pg_stat_user_indexes, you will need to turn on the stats collection in your postgresql.conf file first. Jim -- Original Message --- From: "George Pavlov" <[EMAIL PROTECTED]> To: Sent: Tue, 1 Aug 2006 09:05:34 -0700 Subject: [SQL] finding unused ind

Re: [SQL] DBD::Pg ... how would I format this prepare?

2006-07-26 Thread Jim Buttafuoco
try now() + (? || ' day')::interval -- Original Message --- From: "Marc G. Fournier" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Wed, 26 Jul 2006 18:29:32 -0300 (ADT) Subject: [SQL] DBD::Pg ... how would I format this prepare? > I need to do: > > NOW() + '2 day'::in

Re: [SQL] SELECT substring with regex

2006-07-07 Thread Jim Buttafuoco
use plperl -- Original Message --- From: T E Schmitz <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Fri, 07 Jul 2006 20:23:50 +0100 Subject: Re: [SQL] SELECT substring with regex > Rodrigo De Leon wrote: > > On 7/7/06, T E Schmitz <[EMAIL PROTECTED]> wrote: > > > >> But

Re: [SQL] create aggregate function 'count_bool( column_name, boolean )'

2006-07-07 Thread Jim Buttafuoco
ct_id; Jim -- Original Message --- From: "James Moliere" <[EMAIL PROTECTED]> To: Sent: Fri, 7 Jul 2006 06:53:45 -0700 Subject: [SQL] create aggregate function 'count_bool( column_name, boolean )' > Hello, > I'd like to create a function ca

Re: [SQL] Good examples of calling slony stored procedures

2006-06-14 Thread Jim Buttafuoco
try www.slony.info -- Original Message --- From: "Mark Adan" <[EMAIL PROTECTED]> To: Sent: Wed, 14 Jun 2006 08:50:23 -0700 Subject: Re: [SQL] Good examples of calling slony stored procedures > Hi > > Can somebody direct me to the mailing list for slony. I couldn't find > it

Re: [SQL] Problems Testing User-Defined Function

2006-06-09 Thread Jim Buttafuoco
You will have to use the "CALLED ON NULL INPUT" option to "create function" (Postgresql 8.1, I don't know about other versions) if you expect NULL arguments. Jim -- Original Message --- From: "Rommel the iCeMAn" <[EMAIL PROTECTED]> To:

Re: [SQL] pgxml & xpath_table

2006-06-08 Thread Jim C. Nasby
11 22 33 > > > I was expecting doc_num would receive twice the C1 value, just like with a > normal sql join. > > Regards, > > -- > Philippe Lang, Ing. Dipl. EPFL > Attik System > rte de la Fonderie

Re: [SQL] (Ab)Using schemas and inheritance

2006-05-23 Thread Jim C. Nasby
other consideration is that the free space map doesn't care too much for tracking space info on tons of small tables. Perhaps the biggest issue is: what happens when you need to do DDL? If you have 1000 schemas that should be identical, you'll need to perform any DDL 1000 times. But as

Re: [SQL] LinkedList

2006-04-26 Thread Jim C. Nasby
rently. > > You should be able to do this with a fairly simple self-join... > > select a.id, b.aid, a.field1, b.field1 > from mytable a > join mytable b > on (a.id=b.aid) > > Or something like that. > > ---(end of broadcast)--- > T

Re: [SQL] Migrating a Database to a new tablespace

2006-04-26 Thread Jim C. Nasby
ftp://candle.pha.pa.us/pub/postgresql/mypatches/checkfile.* > > Let me know if you want details. Is it able to also delete the cruft? Seems to be a useful extension, especially on windows, which AFAIK doesn't have an equivalent to ``. -- Jim C. Nasby, Sr. Engineering Consultant

Re: [SQL] Migrating a Database to a new tablespace

2006-04-24 Thread Jim C. Nasby
chaber | Logical Tracking&Tracing International AG > Dipl. Inf. | Software Development GIS > > Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org > > ---(end of broadcast)--- > TIP 4: Have you searched ou

Re: [SQL] Query from shell

2006-04-06 Thread Jim Buttafuoco
or psql db < To: Sent: Thu, 6 Apr 2006 14:37:51 -0700 Subject: Re: [SQL] Query from shell > Judith wrote: > > >Hi every body, somebody can show me hot to execute a > > query from a shell > > echo QUERY HERE | psql databasename > > Or, if you want to run several queries, run psql and

Re: [SQL] unique names in variables and columns in plsql functions

2006-03-27 Thread Jim C. Nasby
ystem more usable if the parser tried to apply a heuristic rule > about some occurrences being meant as variable references and other ones > not. If the rule ever got it wrong, it'd be even more confusing. BTW, I believe SELECT investment_products.provider_id would work here, but I'm

Re: [SQL] unique names in variables and columns in plsql functions

2006-03-27 Thread Jim C. Nasby
Because of this I *always* prefix plpgsql variables with something, such as p_ for parameters and v_ for general variables. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasby.net/perva

Re: [SQL] Find min and max values across two columns?

2006-03-27 Thread Jim C. Nasby
CT max(greatest(column_a, column_b) ... SELECT min(least(column_a, column_b) ... There may be a difference in performance between the two. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://ji

Re: [SQL] Question about One to Many relationships

2006-03-27 Thread Jim C. Nasby
, you should link a band to a track, not an album. > This opens another can of worms... > > I would use the following tables : BTW, if you're going to be writing code to manage stuff like this, you should absolutely check out the source for http://musicbrainz.or

Re: [SQL] SQL Query Newbie Help

2006-03-27 Thread Jim C. Nasby
select T.* from quality_control_reset T inner join > (select qualitycontrolrange, max(date) as date from quality_control_reset > group by qualitycontrolrange) T2 > on (T.qualitycontrolrange = T2.qualitycontrolrange and T.date=T2.date); BTW, I believe the new row operator fixes in 8.2

Re: [SQL] Expressing a result set as an array (and vice versa)?

2006-03-27 Thread Jim C. Nasby
id ) FROM bookmarks; > array_accum > --- > {1,2,3,4,5,7} Couldn't you just use array()? -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasby.net/

Re: [SQL] Problem with query on history table

2006-03-01 Thread Jim C. Nasby
fied, hist.modified > as > hist_modified, coalesce(hist.etc, curr.etc) as etc FROM curr LEFT OUTER JOIN > hist ON(curr.id = hist.curr_id) WHERE ... > > I'm really stuck here. It seems to me that I need a lot of > CASE...WHEN...ELSE.. statements in the query, but

Re: [SQL] Replication - state of the art?

2006-03-01 Thread Jim C. Nasby
t addicted, is all. > > A > > -- > Andrew Sullivan | [EMAIL PROTECTED] > Information security isn't a technological problem. It's an economics > problem. > --Bruce Schneier > > ---(end of broadcast)--- > TIP

Re: [SQL] regarding grant option

2006-03-01 Thread Jim C. Nasby
ompany - Command Prompt, Inc. > > ---(end of broadcast)--- > TIP 9: In versions below 8.0, the planner will ignore your desire to >choose an index scan if your joining column's datatypes do not >match > -- Jim C. N

Re: [SQL] Sum If

2006-02-23 Thread Jim Buttafuoco
try select ...,sum(case when sales.itemname = 'some' then sales.count else 0 end) as "Sales Candies" from your_table_here group by ... -- Original Message --- From: "Daniel Hernandez" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Thu, 23 Feb 2006 12:46:44 -0500 (EST)

Re: [SQL] new rule syntax?

2006-02-05 Thread Jim Buttafuoco
Try this rule instead create rule checks_d0 as on delete to checks do delete from checkitems where ckid = OLD.ckid; -- Original Message --- From: "Milen A. Radev" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Sun, 05 Feb 2006 15:10:23 +0200 Subjec

Re: [SQL] FOREIGN KEYs ... I think ...

2006-01-04 Thread Jim Johannsen
Marc Is the "assumption" that anytime there are comments the status changes? If I'm reading between the lines correctly, there could be a large number of comments before the status changes. So no need to change status until explicitly needed. If there is a specific "comment" th

Re: [SQL] Does VACUUM reorder tables on clustered indices

2005-12-20 Thread Jim C. Nasby
dead tuples, so if > >>you cluster you don't need to vacuum. > > > >It also does a REINDEX... -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasb

Re: [SQL] Does VACUUM reorder tables on clustered indices

2005-12-20 Thread Jim C. Nasby
ommand that can do that? > > > > Cluster does that. Vacuum only cleans dead tuples from the tables. > > Note that while reordering, CLUSTER also gets rid of dead tuples, so if > you cluster you don't need to vacuum. It also does a REINDEX... -- Jim C. Nasby, Sr. Engineering C

Re: [SQL] How to get a count() where column < ''?

2005-12-04 Thread Jim Johannsen
Joost Kraaijeveld wrote: Hi Stephan, On Sun, 2005-12-04 at 13:33 -0800, Stephan Szabo wrote: SELECT COUNT(customers.objectid) FROM prototype.customers, prototype.addresses WHERE customers.contactaddress = addresses.objectid AND zipCode < '2716BN' ORDER By zipCode, houseNumber I

Re: [SQL] Nested Table in PostgreSQL or some alternative Variants

2005-11-01 Thread Jim C. Nasby
broadcast)------- > TIP 2: Don't 'kill -9' the postmaster > -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasby.net/perv

Re: [SQL] [GENERAL] A Not Join

2005-11-01 Thread Jim C. Nasby
NULL You might have to do the NULL check in a HAVING clause instead... try it. BTW, this is probably better asked on pgsql-sql. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasby.net/pervasive

Re: [SQL] why vacuum

2005-10-27 Thread Jim C. Nasby
worthless - it works fine for many > people. But it does have limitations. And you can easily have multi-master syncronous replication in PostgreSQL using the same idea; just see pgCluster. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software

Re: [SQL] How to speed up the database query?

2005-10-27 Thread Jim C. Nasby
y time > increased compare to say select a,b from tableA. > > any help, prettymuch appreciated. > > > ---(end of broadcast)--- > TIP 5: don't forget to increase your free space map settings > -- Jim C. Nasby, Sr.

Re: [DOCS] [SQL] Update timestamp on update

2005-10-13 Thread Jim C. Nasby
s the only examples in > chapter 35. There is a paragraph in there suggesting you go look at > the PL languages first, but obviously it's not getting the job done. Chapter 35 is plpgsql.. do you mean chapter 32.4? > Anybody have a better idea? What about a See Also section a

Re: [SQL] using pg_tables and tablename in queries

2005-10-04 Thread Jim Buttafuoco
an EXECUTE. If you need help, post the schema for a couple of your tables and I will help with the function Jim -- Original Message --- From: solarsail <[EMAIL PROTECTED]> To: Yasir Malik <[EMAIL PROTECTED]> Cc: PostgreSQL Sent: Tue, 4 Oct 2005 15:50:39 -0400 Subje

Re: [SQL] Why doesn't the SERIAL data type automatically have a

2005-10-04 Thread Jim C. Nasby
rry... It I don't think either assertion is true. I'd bet most of the developers actually do normally use an index on a serial, since it's normally used as a PK. And while people can be a bit terse with their replies, I wouldn't say you were blasted. :) -- Jim C. Nasby,

Re: [SQL] Why doesn't the SERIAL data type automatically have a

2005-10-04 Thread Jim C. Nasby
e useful to toss a NOTICE or maybe even WARNING when a serial is created without a unique constraint of some kind? -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software http://pervasive.comwork: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512

Re: [SQL] Help with multistage query

2005-10-04 Thread Jim C. Nasby
lect t1.id from t1, t2 where t1.id = t2.id and t2.id = x > > or more correctly, based on the OP's example: > > select t2.x from t1, t2 where t1.id = t2.id and t1.id = Actually, I think you want AND t2.x , not t1.id. BTW, I recommend not using id as a bareword field name. Very easy

Re: [SQL] using pg_tables and tablename in queries

2005-10-04 Thread Jim Buttafuoco
do you mean UNION ALL instead of JOIN, if you mean UNION ALL , I would go with a set returning function passing it the necessary WHERE clause to be applied to all of your tables. You might be able to wrap the whole thing into a view -- Original Message --- From: solarsail <[

Re: [SQL] insert only if conditions are met?

2005-08-31 Thread Jim C. Nasby
Is this possible? > > > > Sure, given a suitable schema > > > > It is not clear to me, if the hours worked are > > to be found in the same table you want to insert > > into, or not. > > > > gnari > > > > > > > > -- Jim C.

Re: [SQL] [PHP] [ADMIN] Data insert

2005-08-22 Thread Jim C. Nasby
r than individual transactions. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Softwarehttp://pervasive.com512-569-9461 ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your des

Re: [SQL] Multi-column returns from pgsql

2005-07-23 Thread Jim Buttafuoco
ti-column returns from pgsql > On 7/22/05, Jim Buttafuoco <[EMAIL PROTECTED]> wrote: > > Mark, > > > > Instead of RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN > > NEXT rec; > > > > then your select statement would be > > sele

Re: [SQL] Multi-column returns from pgsql

2005-07-22 Thread Jim Buttafuoco
Mark, Instead of RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN NEXT rec; then your select statement would be select * from my_func() as (txt1 text,txt2 text); Jim -- Original Message --- From: "Mark R. Dingee" <[EMAIL PROTECTED]> To: pgsql-sq

Re: [SQL] Dumping table definitions

2005-07-18 Thread Jim Buttafuoco
use pg_dump with the --schema-only and --table= params -- Original Message --- From: "Mark Fenbers" <[EMAIL PROTECTED]> To: Pg SQL Discussion Group Sent: Mon, 18 Jul 2005 12:50:54 -0400 Subject: [SQL] Dumping table definitions > I am looking for a way to reformat the informatio

Re: [SQL] Generating a range of integers in a query

2005-07-13 Thread Jim Buttafuoco
I use the following function which returns a date series. You can modify it to return an int series instead create or replace function alldates(date,date) returns setof date as ' declare s alias for $1; e alias for $2; d date; begin d := s; while d <= e

Re: [SQL] 'show full processlist' in postgres?

2005-07-01 Thread Jim Buttafuoco
did you restart postgresql and use the pg_stat_activity view instead (just to save some typing). Jim -- Original Message --- From: Erik Wasser <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Fri, 1 Jul 2005 15:58:46 +0200 Subject: [SQL] 'show full proc

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Jim Buttafuoco
try case for example select case when bool_column then 'Yes' else 'No end from your_table; -- Original Message --- From: Roy Souther <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Mon, 27 Jun 2005 11:16:58 -0600 Subject: [SQL] How can I simply substatue a value in a que

Re: [SQL] multiple PK with a non UNIQUE field

2005-06-26 Thread Jim Buttafuoco
if you need a multi column fk don't use the "references" keyword on your create table, instead use the "FOREIGN KEY" keyword for the table, see the "create table" help. so for example (untested) change CREATE TABLE appalto ( cod_op int not null references Opere, cod_co

Re: [SQL] funny update, say update 1, updated 1 added 2nd.

2005-06-16 Thread Jim Buttafuoco
works fine for me. Do you have any triggers on the tables or other rules? Can you provide a complete SQL script that starts from an empty database. Jim -- Original Message --- From: Neil Dugan <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Thu, 16 Jun 2005 13

Re: [SQL] Numeric and CSV under 8.0.1 ?

2005-04-08 Thread Jim Johannsen
Stef: Why is iuserid numeric? Are you going to do any math on the field? If not, change it to varchar. In the long run you'll be happier. Stef wrote: Hello Everyone, Currently, here at work, I am doing the whole 'advocacy' part of postgreSQL. It's not really hard to do, as the other

Re: [SQL] Calling functions from Delete View (+ contrib/pgcrypto) = madness ??

2005-03-24 Thread Jim Buttafuoco
Mike, I posted this RULE also on hackers CREATE or replace RULE crypto_view_delete_rule AS ON DELETE TO crypto_view DO INSTEAD ( select func_delFromCrypto( OLD.id,OLD.crypted_content); ); Jim -- Original Message --- From: "Moran.Michael" <[EMAIL PROTECTED]&g

Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Jim Buttafuoco
I would change the return type to TEXT, I believe your original example had it as a varchar and I didn't change it. Also, I believe that "under the hood" text does equal varchar. Glad I could help Jim -- Original Message --- From: "Moran.Michael&quo

Re: [SQL] Funtions + plpgsql + contrib/pgcrypto = ??

2005-03-24 Thread Jim Buttafuoco
give this a try CREATE OR REPLACE FUNCTION selectFromCrypto(INTEGER) RETURNS VARCHAR AS ' DECLARE _pid ALIAS FOR $1; c text; BEGIN SELECT decrypt(crypted_content, decode(''password''::text, ''escape''::text), ''aes''::text) into c FROM crypto WHERE pid = _pid; RET

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Jim Buttafuoco
tested yet with 8.0.X. You can adjust the output to fit your needs. Jim -- Original Message --- From: Stef <[EMAIL PROTECTED]> To: Tom Lane <[EMAIL PROTECTED]> Cc: pgsql-ADMIN@postgresql.org, pgsql-sql@postgresql.org Sent: Mon, 7 Mar 2005 17:31:55 +0200 Subject: Re:

Re: [SQL] vacuum analyze slows sql query

2004-11-03 Thread Jim Buttafuoco
have you reindexes your tables. When I was running 7.1.4, I ran a vacuum and reindex nightly. Otherwise your index files will keep getting bigger and bigger (this has been fixed in 7.4). Jim -- Original Message --- From: patrick ~ <[EMAIL PROTECTED]> To: [EMAIL PRO

Re: [SQL] Is it possible in PostgreSQL?

2004-01-18 Thread Jim Johannsen
This is what I use to flatten a table, the syntax may not be postgresql correct but you will get idea. SELECT a.name ,SUM (CASE WHEN EXTRACT(month from a.date) = 1 THEN a.quantity ELSE 0 END) AS '01'

[SQL] Substrings by Regular Expression

2003-11-19 Thread Jim Drummey
Hello- The 7.2 version distributed with RedHat 8.0 seems not to work for substrings and POSIX regular expressions. I think this should work pds=> select substring( str1 from ',' ) from address; ERROR: pg_atoi: error in ",": can't parse "," Am I missing something? TIA J. Drummey [EMAIL PR

Re: [SQL] Case Insensitive Queries

2001-05-29 Thread Jim Ballard
to change this Postgres behavior? Thanks, Jim Ballard Netezza Corp. -- Original Message -- From: Mark <[EMAIL PROTECTED]> Date: 29 May 2001 10:21:15 -0600 >We tried these but it didn't work. However, that's because username is >a bpchar

[SQL] Difficult SQL Statement

2001-05-28 Thread Jim
I have a table that has the following columns: AUTHOR_NO, ASMT_CODE, & STATUS. The table would look something like this: AUTHOR_NO ASMT_CODE STATUS 12345 1 PASSED 12345 2 FAILED 12345 3 FAILED 12345 4 PASSED 12346 1 PASSED 12346 2 PASSED

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

2001-03-28 Thread Jim Ballard
alues, as in the following where that maximum is 20 and we are looking at 3 fields: select count(distinct (cast(field1 as char(20)) || cast(field2 as char(20)) || field3)) from ... Jim Ballard - Original Message - From: "Jeff Eckermann" <[EMAIL PROTECTED]> To: "