Re: [SQL] strange corruption?

2012-12-27 Thread Scott Marlowe
On Thu, Dec 27, 2012 at 7:27 AM, John Fabiani wrote: > Hi, > I have the following statement in a function. > > UPDATE orderseq > SET orderseq_number = (orderseq_number + 1) > WHERE (orderseq_name='InvcNumber'); > > All it does is update a single record by incrementing a value (int). >

Re: [SQL] deciding on one of multiple results returned

2012-12-21 Thread Scott Marlowe
On Fri, Dec 21, 2012 at 10:28 AM, Wes James wrote: > David and Seth Thanks. That helped. > > > When I have > > select distinct on (revf3) f1, f2, f3, revers(f3) as revf3 from table order > by revf3 > > Is there a way to return just f1, f2, f3 in my results and forget revf3 (so > it doesn't show

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 7:56 PM, Mark Fenbers wrote: > I'd do somethings like: > > select * from ( > select id, sum(col1), sum(col2) from tablename group by yada >) as a [full, left, right, outer] join ( > select id, sum(col3), sum(col4) from tablename group by bada > ) as b > on (

Re: [SQL] complex query

2012-10-27 Thread Scott Marlowe
On Sat, Oct 27, 2012 at 6:01 PM, Mark Fenbers wrote: > I have a query: > SELECT id, SUM(col1), SUM(col2) FROM mytable WHERE condition1 = true GROUP > BY id; > > This gives me 3 columns, but what I want is 5 columns where the next two > columns -- SUM(col3), SUM(col4) -- have a slightly different W

Re: [SQL] Insane behaviour in 8.3.3

2012-06-15 Thread Scott Marlowe
Well, I'd see about finding a way to upgrade to 8.3.19. 8.3.3 has know data eating bugs. On Fri, Jun 15, 2012 at 9:32 AM, Achilleas Mantzios wrote: > On Παρ 15 Ιουν 2012 18:03:26 Scott Marlowe wrote: >> Not talking about going to something after 8.3.19, just updating to >

Re: [SQL] Insane behaviour in 8.3.3

2012-06-15 Thread Scott Marlowe
Not talking about going to something after 8.3.19, just updating to the latest 8.3 version. On most systems it's a simple: sudo apt-get upgrade or similar and sit back and watch. On Fri, Jun 15, 2012 at 2:24 AM, Achilleas Mantzios wrote: > On Παρ 15 Ιουν 2012 10:28:20 Scott Marlo

Re: [SQL] Insane behaviour in 8.3.3

2012-06-15 Thread Scott Marlowe
You do realize you're missing four years of bug fixes right? -- 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] order by different on mac vs linux

2012-05-16 Thread Scott Marlowe
On Wed, May 16, 2012 at 7:58 PM, Wes James wrote: > > > On Wed, May 16, 2012 at 5:00 PM, Samuel Gendler > wrote: >> >> >> >> On Wed, May 16, 2012 at 3:46 PM, Wes James wrote: >>> >>> >>> >>> On Mon, May 14, 2012 at 5:00 PM, Tom Lane wrote: Wes James writes: > Why is there a diff

Re: [SQL] order by different on mac vs linux

2012-05-15 Thread Scott Marlowe
On Tue, May 15, 2012 at 10:06 AM, Wes James wrote: > On Mon, May 14, 2012 at 5:00 PM, Tom Lane wrote: >> Wes James writes: >>> Why is there a different order on the different platforms. >> >> This is not exactly unusual.  You should first check to see if >> lc_collate is set differently in the t

Re: [SQL] Current transaction is aborted, commands ignored until end of transaction block

2011-12-30 Thread Scott Marlowe
On Fri, Dec 30, 2011 at 6:19 PM, Samuel Gendler wrote: > > > On Fri, Dec 30, 2011 at 4:03 PM, Scott Marlowe > wrote: >> >> On Fri, Dec 30, 2011 at 4:19 PM, Tom Lane wrote: >> > Jan Bakuwel writes: >> >> Why-o-why have the PostgreSQL developers de

Re: [SQL] Current transaction is aborted, commands ignored until end of transaction block

2011-12-30 Thread Scott Marlowe
On Fri, Dec 30, 2011 at 4:19 PM, Tom Lane wrote: > Jan Bakuwel writes: >> Why-o-why have the PostgreSQL developers decided to do it this way...? > > Because starting and cleaning up a subtransaction is an expensive thing. > If we had auto-rollback at the statement level, you would be paying that

Re: [SQL] Correlating Asterisk CDRs

2011-12-07 Thread Scott Marlowe
2011/12/7 Raj Mathur (राज माथुर) : >                                                             QUERY PLAN > - >  Limit  (cost=46782.15..46782.40 rows=100 wid

Re: [SQL] updating a sequence

2011-11-15 Thread Scott Marlowe
On Tue, Nov 15, 2011 at 8:46 PM, Scott Marlowe wrote: > On Tue, Nov 15, 2011 at 5:33 PM, Samuel Gendler > wrote: >> On Tue, Nov 15, 2011 at 4:28 PM, John Fabiani wrote: >>> >>> On Tuesday, November 15, 2011 08:33:54 am Richard Broersma wrote: >>> > On

Re: [SQL] updating a sequence

2011-11-15 Thread Scott Marlowe
On Tue, Nov 15, 2011 at 5:33 PM, Samuel Gendler wrote: > On Tue, Nov 15, 2011 at 4:28 PM, John Fabiani wrote: >> >> On Tuesday, November 15, 2011 08:33:54 am Richard Broersma wrote: >> > On Tue, Nov 15, 2011 at 8:06 AM, John Fabiani >> > wrote: >> > > alter sequence somename restart with (select

Re: [SQL] How to write query to access another odbc source

2011-10-19 Thread Scott Marlowe
On Wed, Oct 19, 2011 at 9:19 AM, Rich wrote: >> I have a mumps database with an ODBC connection so I can write queries >> from this database.  How can I write a sql in Postgresql to access this >> database to use in my Postgresql reports? dblink lets one pg server access another via SQL, dbilink

Re: [SQL] Want some basic compare of data type on PostgreSQL and MySQL

2011-09-01 Thread Scott Marlowe
On Thu, Sep 1, 2011 at 7:32 AM, Leif Biberg Kristensen wrote: > On Thursday 1. September 2011 11.16.23 Scott Marlowe wrote: >> The postgresql type text is a varchar with >> no precision that can hold up to about a gig or so of text.  Not that >> i recommend putting a gig

Re: [SQL] Want some basic compare of data type on PostgreSQL and MySQL

2011-09-01 Thread Scott Marlowe
On Wed, Aug 31, 2011 at 11:15 PM, bhavesh1385 wrote: > Hello All, > > I Want some basic compare of data type on PostgreSQL and MySQL. > > I am Try to using create the database on PostgreSQL with the same query on > MySQL then it will create a problem... > > I have make changes according to the Dat

Re: [SQL] Add one column to another

2011-08-25 Thread Scott Marlowe
On Thu, Aug 25, 2011 at 8:52 AM, Oliveiros d'Azevedo Cristina wrote: > Something like this...? > > SELECT first_name,surname, email1 || ';' || email2 > FROM t_your_table; If there's any nulls in email1 or email2 they'll need special handling with coalesce. -- Sent via pgsql-sql mailing list (pg

Re: [SQL] (pgsql8.4) DATA Corruption

2011-08-19 Thread Scott Marlowe
On Fri, Aug 19, 2011 at 1:08 PM, Mikola Rose wrote: > Happy Friday people! > > > > I was wondering if anyone had any suggestions on how to resolve this > issue...  I am moving otrs to another server and during the backup process I > am running into this error > > pg_dump: dumping contents of table

Re: [SQL] Max column number.

2011-07-13 Thread Scott Marlowe
On Wed, Jul 13, 2011 at 9:45 AM, Miguel Angel Conte wrote: > Hi, > Thanks for your interest. This app load scv files which change every day > (sometimes the columns too). The sizes of these files are in avg 15MB. So, > We load something like 100MB each day. We tried to find a better solution > but

Re: [SQL] Max column number.

2011-07-12 Thread Scott Marlowe
On Tue, Jul 12, 2011 at 12:08 PM, Miguel Angel Conte wrote: > Unfortunately It's an inherited data model and I can't make any change for > now... > Thanks for your answer! when you can change it, look at hstore -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to you

Re: [SQL] what is similar to like operator in mysql for postgresql

2011-07-10 Thread Scott Marlowe
On Sun, Jul 10, 2011 at 1:35 PM, hatem gamal elzanaty wrote: > hi all, > can you tell me what is similar to like operator in mysql for postgresql > hatem gamal In postgresql ilike is like mysql's case insensitive like. like in postgres is case sensitive. -- Sent via pgsql-sql mailing list (pgs

Re: [SQL] To find process that lock a table

2011-06-06 Thread Scott Marlowe
On Mon, Jun 6, 2011 at 5:16 PM, manuel antonio ochoa wrote: > Hello , > > do you know how to find a process that is locking a table  ? I try to run a > vacuum analyze  , an it take a state of waiting , I canceled it after 20 > minutes , then > I try to run an analyze  and the same happen, take a s

Re: [SQL] Function to total reset a schema

2011-05-29 Thread Scott Marlowe
On Sun, May 29, 2011 at 1:38 AM, Surfing wrote: > Hi all, > I need to write a function that totally empty a schema. > > So I have written a TRUNCATE statement for each table and set to 0 each > sequence. > Btw, it could be good to execute a vacuum statement on each table, but from > within the fun

Re: [SQL] Sorting Issue

2011-05-10 Thread Scott Marlowe
On Tue, May 10, 2011 at 11:45 AM, Samuel Gendler wrote: > > > On Tue, May 10, 2011 at 9:47 AM, Tom Lane wrote: >> >> "Ozer, Pam" writes: >> > Isn't this the English standard for collation?  Or is this a non-c >> > locale as mentioned below?  Is there anyway around this? >> >> >        LC_COLLATE

Re: [SQL] check constraint bug?

2011-05-05 Thread Scott Marlowe
On Thu, May 5, 2011 at 11:06 PM, Tarlika Elisabeth Schmitz wrote: > I specified: > > ALTER TABLE h ADD CONSTRAINT val_h_stats > CHECK (NOT (sex = 'f') AND (stats IS NOT NULL)); > > which was translated to: > > ALTER TABLE h ADD CONSTRAINT val_h_stats > CHECK (NOT sex = 'f'::bpchar AND stats IS NOT

Re: [SQL] Automating PostgreSql table partition using triggers

2011-01-27 Thread Scott Marlowe
On Thu, Jan 27, 2011 at 10:50 AM, Amitabh Kant wrote: > Hi > > I am trying to write a function which is being called from a trigger used > for partitioning a large table. The partitioning is to happen based on an > integer field (testing_id). A simplified structure of what I am trying to do > is w

Re: [SQL] Compare the resulta of a count sql into bash

2011-01-26 Thread Scott Marlowe
On Wed, Jan 26, 2011 at 10:07 AM, manuel antonio ochoa wrote: > > Hello, > I have the next : > > COUNTONE=`/var/lib/pgsql/bin/./psql -U 'Thor'   -d princlocal -p 5432 -h > 192.170.1.82  -c "select count(*) from monterrey.${NOMBRETB}"` > COUNTTWO=`/var/lib/pgsql/bin/./psql -U 'Thor'   -dprinclocal

Re: [SQL] Benchmarking

2011-01-25 Thread Scott Marlowe
On Tue, Jan 25, 2011 at 10:39 AM, manuel antonio ochoa wrote: > hello > > do you know a tool to benchmark my dbase  and the basic test that I need to > do ? > I found a pgbench !!! ... pgbench can be used as a generic testing tool by giving it a new set of sql statements to run with the -f s

Re: [SQL] check files .backup

2011-01-24 Thread Scott Marlowe
On Mon, Jan 24, 2011 at 5:18 PM, manuel antonio ochoa wrote: > Do you know if exist a  function to check my file.backup created by pgdump. I run backups like this in bash: if (pg_dump yadayada); then echo "backup succeeded." else echo "backup failed." fi; in a cronjob set to email me.

Re: [SQL] Database consistency after a power shortage

2010-12-15 Thread Scott Marlowe
On Wed, Dec 15, 2010 at 8:12 AM, Alberto wrote: > My question is regarding a potential situation: > > I have a program that inserts values on 3 tables linked to each other. My > program is used in a POS. In this specific case, the program has to update > the tables "header_invoice", "detail_invoic

Re: [SQL] Need magic for inserting in 2 tables

2010-10-03 Thread Scott Marlowe
On Sun, Oct 3, 2010 at 8:31 PM, Andreas wrote: > > insert into t1_t2 ( fk_1, fk_2 ) >    insert into table_1 ( txt ) >    values ( 'A' ), ( 'B' ), ( 'C' ) >    returning id_1, 42; > > The inner insert works and dumps the inserted ids along with the constant > which is needed in the outer insert as

Re: [SQL] Need magic for inserting in 2 tables

2010-10-03 Thread Scott Marlowe
On Sun, Oct 3, 2010 at 6:47 PM, Andreas wrote: > How can a script use what RETURNING dumps out? > I tried a bit but got nowhere. The same way it would use the output of a select, it's a record set. So it's x rows by y columns. -- To understand recursion, one must first understand recursion. -

Re: [SQL] Need magic for inserting in 2 tables

2010-10-03 Thread Scott Marlowe
On Sun, Oct 3, 2010 at 4:14 PM, Andreas wrote: > insert into staff ( company_fk, ..., department_fk ) > select  company_fk, ..., department_fk > from     departments,   companies,   company_2_project  AS c2p > where  company_id      =   c2p.company_fk >    and c2p.project_fk    =   42 >    and dep

Re: [SQL] PostGres Tables in ArcSDE and ArcCatalog.

2010-08-30 Thread Scott Marlowe
On Mon, Aug 30, 2010 at 1:31 PM, Michael Andrew Babb wrote: > Hi All, > If I execute a make table query along the lines of “select * into > SF30001_test from SF30001” I can interact with the table in ArcCatalog just > fine. what do \z SF30001 \z SF30001_test say about the permissions on the two t

Re: [SQL] Question about POSIX Regular Expressions performance on large dataset.

2010-08-17 Thread Scott Marlowe
You can do something similar on the same machine if you can come up with a common way to partition your data. Then you split your 1B rows up into chunks of 10M or so and put each on a table and hit the right table. You can use partitioning / table inheritance if you want to, or just know the tabl

Re: [SQL] Question about POSIX Regular Expressions performance on large dataset.

2010-08-17 Thread Scott Marlowe
On Tue, Aug 17, 2010 at 8:21 PM, Jose Ildefonso Camargo Tolosa wrote: > Hi! > > I'm analyzing the possibility of using PostgreSQL to store a huge > amount of data (around 1000M records, or so), and these, even > though are short (each record just have a timestamp, and a string that > is less t

Re: [SQL] Round integer division

2010-06-25 Thread Scott Marlowe
On Fri, Jun 25, 2010 at 6:53 PM, Lee Hachadoorian wrote: > Is it documented anywhere that floating-point numbers round > "scientifically", that is 0.5 rounds to the nearest even number? Compare: > > SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), > round(3.5::numeric); > > generate

Re: [SQL] oracle to postgres migration question

2010-06-16 Thread Scott Marlowe
On Wed, Jun 16, 2010 at 1:42 PM, Chris Browne wrote: > sfr...@snowman.net (Stephen Frost) writes: >> People who are trying to parse psql's output directly should realize >> they probably are going about it the wrong way. :) > > There's a set of people I need to tell that to... If you're at least

Re: [SQL] oracle to postgres migration question

2010-06-15 Thread Scott Marlowe
On Tue, Jun 15, 2010 at 2:19 PM, Stephen Frost wrote: > * Bruce Momjian (br...@momjian.us) wrote: >> Joshua Gooding wrote: >> > Hello, >> > >> > I'm looking for the postgres equivalent of oracles: set numwidth >> > command.  Is there an equivalent? >> >> If we knew what it did, we might be able to

Re: [SQL] oracle to postgres migration question

2010-06-15 Thread Scott Marlowe
On Tue, Jun 15, 2010 at 1:09 PM, Joshua Gooding wrote: > Hello, > > I'm looking for the postgres equivalent of oracles: set numwidth command. >  Is there an equivalent? Psql uses dynamic formatting for such things. Not sure there's really a big need for it. Can you give an example of what you'r

Re: [SQL] import ignoring duplicates

2010-05-16 Thread Scott Marlowe
On Sun, May 16, 2010 at 12:38 PM, Mark Fenbers wrote: > I am using psql's \copy command to add records to a database from a file. >  The file has over 100,000 lines.  Occasionally, there is a duplicate, and > the import ceases and an internal rollback is performed.  In other words, no > data is im

Re: [SQL] advice on query joining 10 tables

2010-05-10 Thread Scott Marlowe
On Mon, May 10, 2010 at 2:38 PM, Gerardo Herzig wrote: > Scott Marlowe wrote: >> On Mon, May 10, 2010 at 12:40 PM, Gerardo Herzig wrote: >>> Hi all. Im triyng to see if i can improve the performance of a query >>> (mainly a 10 table join) >>> >>>

Re: [SQL] advice on query joining 10 tables

2010-05-10 Thread Scott Marlowe
On Mon, May 10, 2010 at 12:40 PM, Gerardo Herzig wrote: > Hi all. Im triyng to see if i can improve the performance of a query > (mainly a 10 table join) > > 1) Besides of triyng to use indexes, there is some rules of thumb to follow? log long running queries for later analysis? > 2) Should i tr

Re: [SQL] Problem with insert related to different schemas

2010-04-21 Thread Scott Marlowe
On Wed, Apr 21, 2010 at 7:25 AM, Gonzalo Aguilar Delgado wrote: > Hi Tom, > > > >> >> This is a select query.  I don't think that's the right error message. >> >> > Yes, but IS the correct error message. >> >> The query being complained of appears to be a generated foreign key >> checking query.  

Re: [SQL] Problem with insert related to different schemas

2010-04-20 Thread Scott Marlowe
On Tue, Apr 20, 2010 at 10:32 AM, Gonzalo Aguilar Delgado wrote: > >> Hi Everyone, >> >> I've come along with a problem that appeared with latest version of >> Postgresql 8.4.2. >> >> I'm trying to insert a row in the analysis schema: >> > > This is an insert query: > > Yes it is... > > >> INSERT

Re: [SQL] Problem with insert related to different schemas

2010-04-20 Thread Scott Marlowe
On Wed, Apr 14, 2010 at 2:23 AM, Gonzalo Aguilar Delgado wrote: > Hi Everyone, > > I've come along with a problem that appeared with latest version of > Postgresql 8.4.2. > > I'm trying to insert a row in the analysis schema: > This is an insert query: > INSERT INTO > "analisys"."response_qualit

Re: [SQL] Table Design for Hierarchical Data

2010-04-06 Thread Scott Marlowe
On Tue, Apr 6, 2010 at 11:43 PM, silly sad wrote: > P.S. > almost foget, do not try any oracle-like "tree-jouns" or "special types" or > such a crap. > > your problem as plain as to store a pair of integers > (or numerics (i prefer)) Since it's an identifier and not really a numeric per se, I'd s

Re: [SQL] Rename Index - Deadlock

2010-03-16 Thread Scott Marlowe
On Tue, Mar 16, 2010 at 3:45 AM, Thomas Kenner wrote: > Hi, > > Each day I'm recreating the index my_index of the table my_table. Therefore I > create a new index my_index_new, drop the old index my_index, and rename the > new index: > ALTER INDEX my_index_new RENAME TO my_index; > > If an insert

Re: [SQL] Issue with insert

2010-02-27 Thread Scott Marlowe
On Sat, Feb 27, 2010 at 10:14 AM, Michael Gould wrote: > I'm having a issue with a insert > > INSERT INTO >  iss.citystateinfo > ( >  citystateinfoid, >  citystate, >  zipcode, >  cityname, >  statecode > ) > VALUES ( >  '31344342-3439-4135-2d32-3044462d3433', >  'Orange Park,FL', >  '32065', >  '

Re: [SQL] Fwd: Help required on query performance

2010-01-31 Thread Scott Marlowe
On Sun, Jan 31, 2010 at 9:25 PM, Dave Clements wrote: > After the analyze I am getting the time 3.20 ms but there is not > HashJoin there. Still all of them are NestLoops. But that is fine. > > Now the only problem is the sequence scan on sq_sch_idx table. > I have a query like this: > > explain a

Re: [SQL] Fwd: Help required on query performance

2010-01-31 Thread Scott Marlowe
On Sun, Jan 31, 2010 at 6:09 PM, Dave Clements wrote: > I did the re-analyze serveral times, using the command: > > ANALYZE tablename; > > Is there any other command as well or another way to do that? It's important that the stats target get increased as well, it looks like you're not getting eno

Re: [SQL] Fwd: Help required on query performance

2010-01-31 Thread Scott Marlowe
On Sun, Jan 31, 2010 at 6:02 PM, Dave Clements wrote: > Hi, following the output from explain analyze. Without doing any heavy analysis, it looks like your row estimates are way off. Have you cranked up stats target and re-analyzed yet? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.

Re: [SQL] Fwd: Help required on query performance

2010-01-31 Thread Scott Marlowe
On Sun, Jan 31, 2010 at 5:50 PM, Dave Clements wrote: > Hello, I have this query in my system which takes around 2.5 seconds > to run. I have diagnosed that the problem is actually a hashjoin on > perm and s_ast_role tables. Is there a way I can avoid that join? I > just want to change the > query

Re: [SQL] Partitioning by letter question

2010-01-30 Thread Scott Marlowe
On Sat, Jan 30, 2010 at 7:11 AM, John Lister wrote: >> wrote: > > .> Hi, I was wondering if this was possible. I'm trying to partition a > table, > .> which is straightforward enough thanks to the great documentation, but i >>> >>> have a question: >>> >>> If I partition using something like a pr

Re: [SQL] Partitioning by letter question

2010-01-29 Thread Scott Marlowe
On Fri, Jan 29, 2010 at 3:24 PM, John Lister wrote: > Hi, I was wondering if this was possible. I'm trying to partition a table, > which is straightforward enough thanks to the great documentation, but i > have a question: > > If I partition using something like a product_id for example and have c

Re: [SQL] CHECK constraint removing brackets

2010-01-11 Thread Scott Marlowe
On Mon, Jan 11, 2010 at 12:49 PM, Andy Shellam wrote: > With the above in mind, I decided on the following check to enforce this: > > (state = 'Unconfirmed'::client.order_state AND invoice_id = NULL) OR (state > != 'Unconfirmed'::client.order_state AND invoice_id != NULL) Nothing can = null. an

Re: [SQL] 8.4.1 distinct query WITHOUT order by

2009-12-22 Thread Scott Marlowe
On Tue, Dec 22, 2009 at 12:11 AM, msi77 wrote: >> What are the ramifications of renaming the table (containing 8000 >> rows) and creating a view of the same name? > > View does not admit ORDER BY clause, at least, Standard does not. Postgres certainly allows it, but I don't think it will help in

Re: [SQL] 8.4.1 distinct query WITHOUT order by

2009-12-21 Thread Scott Marlowe
On Mon, Dec 21, 2009 at 10:18 PM, Scott Marlowe wrote: > On Mon, Dec 21, 2009 at 8:45 PM, Gary Chambers wrote: >>> Yeah, if you're code base is that fragile, bandaging it up by jumping >>> through hoops in pgsql is just putting off the inevitable when it (the >>&g

Re: [SQL] 8.4.1 distinct query WITHOUT order by

2009-12-21 Thread Scott Marlowe
On Mon, Dec 21, 2009 at 8:45 PM, Gary Chambers wrote: >> Yeah, if you're code base is that fragile, bandaging it up by jumping >> through hoops in pgsql is just putting off the inevitable when it (the >> code base) has to get recompiled someday anyway. > > I appreciate (and agree with) the concern

Re: [SQL] 8.4.1 distinct query WITHOUT order by

2009-12-21 Thread Scott Marlowe
On Mon, Dec 21, 2009 at 3:38 PM, Thomas Kellerer wrote: > Gary Chambers wrote on 21.12.2009 23:15: >> >> The current maintainer is unsure about being able to do the right >> thing and recompile the code after fixing the query. > > Why not simply add the necessary GROUP BY? Yeah, if you're code ba

Re: [SQL] need nelp with aggregate functions

2009-11-18 Thread Scott Marlowe
On Wed, Nov 18, 2009 at 9:55 AM, Another Trad wrote: > The DB structure is in attachment. > I with the number of clients and the number of computers that have > processors with "manufacturer" = "INTEL" and "speed" = "2GB" > I am trying: > > select count(c) as qtd_client, count(cm) as qtd_computers

Re: [SQL] Foreign key columns

2009-11-05 Thread Scott Marlowe
On Thu, Nov 5, 2009 at 2:08 PM, Svenne Krap wrote: > Hi. > > Is there a simple way to get foreign key data... for example I found a > view, that does what I want ... > > It delivers > >   fk_table   |     fk_column      |     pk_table      | pk_column |           > constraint_name > > ---

Re: [SQL] DDL problems: Referential issue?

2009-11-04 Thread Scott Marlowe
On Wed, Nov 4, 2009 at 1:14 PM, Leif Biberg Kristensen wrote: > On Wednesday 4. November 2009 21.03.26 Scott Marlowe wrote: >> On Wed, Nov 4, 2009 at 11:53 AM, Leif Biberg Kristensen >> > This looks strange to me, but it works: >> > >> > pgslekt=> CREATE

Re: [SQL] DDL problems: Referential issue?

2009-11-04 Thread Scott Marlowe
On Wed, Nov 4, 2009 at 11:53 AM, Leif Biberg Kristensen wrote: > On Wednesday 4. November 2009 19.37.41 Scott Marlowe wrote: >> On Wed, Nov 4, 2009 at 11:36 AM, Leif Biberg Kristensen >> wrote: >>> I'd missed that particular syntax. >>> >>> This ta

Re: [SQL] DDL problems: Referential issue?

2009-11-04 Thread Scott Marlowe
On Wed, Nov 4, 2009 at 11:36 AM, Leif Biberg Kristensen wrote: > On Wednesday 4. November 2009 19.24.29 Scott Marlowe wrote: >> You're referencing a single column, which does not have a unique key >> on it.  Being part of a two column unique PK index doesn't count, as &

Re: [SQL] DDL problems: Referential issue?

2009-11-04 Thread Scott Marlowe
On Wed, Nov 4, 2009 at 11:03 AM, Leif Biberg Kristensen wrote: > PostgreSQL 8.3.8 on Gentoo Linux. > > I've got a junction table: > > CREATE TABLE participants ( >    person_fk INTEGER REFERENCES persons (person_id), >    event_fk INTEGER REFERENCES events (event_id) ON DELETE CASCADE, >    sort_o

Re: [SQL] Speed up UPDATE query?

2009-10-31 Thread Scott Marlowe
On Thu, Oct 29, 2009 at 11:50 AM, Lee Hachadoorian wrote: > I'm trying to update several tables (all child tables of the same > parent), and as the number of records increases, the length of time it > takes to run the update is shooting up exponentially. I have imported > the new data to an import

Re: [SQL] question about timestamp with tz

2009-10-22 Thread Scott Marlowe
On Thu, Oct 22, 2009 at 2:41 PM, the6campbells wrote: > Question.. is there a way that I can get Postgres to return the tz as > supplied on the insert statement PostgreSQL converts the timezone to GMT and stores it with no offset, then adds an offset based on the TZ of the client requesting it ba

Re: [SQL] reading last inserted record withoud any autoincrement field

2009-10-05 Thread Scott Marlowe
On Sun, Oct 4, 2009 at 1:34 PM, Rob Sargent wrote: > Osvaldo Kussama wrote: >> >> 2009/10/4 mohammad qoreishy >> >>> >>> How can get last inserted record in a table without any autoincrement >>> filed? >>> I need to  frequently fetch the last inserted record. >>> If I must use the "Cursor" please

Re: [SQL] Pg_Restore with --clean option

2009-09-30 Thread Scott Marlowe
On Wed, Sep 30, 2009 at 11:14 PM, Jyoti Seth wrote: > > I want to restore data of a single table. Before restoring the data I > disabled all the triggers and constraints on that table. I used the restore > command with --clean option so that data gets deleted from that table and > then fresh data

Re: [SQL] Can i customize null-padding for outer joins?

2009-09-30 Thread Scott Marlowe
On Thu, Oct 1, 2009 at 12:19 AM, Shruthi A wrote: > Hello, > > I have a query where I full-outer-join 2 tables, and all the columns other > than the join column are numerical columns. For my further calculations i > need to pad the unmatched tuples with 0 (zero) instead of NULL so that I can > per

Re: [SQL] Working slow

2009-09-21 Thread Scott Marlowe
On Mon, Sep 21, 2009 at 7:58 AM, Judith Altamirano wrote: > hello every body, I'm having a data base in a point of sale that is getting > frozen, I already have run a vacuum -z -d to reindex the data base and > nothing happens.. Some suggestions to speed the process, Do you guys > think that t

Re: [SQL] How to simulate (run) the function

2009-09-04 Thread Scott Marlowe
On Fri, Sep 4, 2009 at 8:43 PM, bilal ghayyad wrote: > Hello; > > I have an SQL function and I need to know how to simulate it (calling it and > pass for it the argument and see what the value it returns), HOW? Can I do > this from the pgAdminIII GUI or from the CLI? > > This method help to check

Re: [SQL] Odd sort behaviour

2009-09-01 Thread Scott Marlowe
On Tue, Sep 1, 2009 at 3:01 PM, Rob Sargent wrote: > Since when does "." sort as "nothing at all" Since you set your locale equal to something like en_US instead of C -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mai

Re: [SQL] Rewrite without correlated subqueries

2009-08-20 Thread Scott Marlowe
On Thu, Aug 20, 2009 at 3:16 PM, bricklen wrote: > Interesting idea. Preferably this operation could be done in straight SQL in > a single transaction, to fit in with the way our application works, but if > that's not possible I may need to go the temporary table route. Temp tables can be included

Re: [SQL] Call Procedure From Trigger Function

2009-08-19 Thread Scott Marlowe
On Wed, Aug 19, 2009 at 3:53 PM, Doug Pisarek wrote: > I am in the process of coverting an Oracle 10.2.0.3 database to Postgresql > 8.3. I have a number of triggers in Oracle that make a call to packages. > I know I will need to re-write the Oracle packages to postgres functions. > The issue which

Re: [SQL] De-duplicating rows

2009-07-17 Thread Scott Marlowe
On Thu, Jul 16, 2009 at 9:07 PM, Christophe wrote: > The Subject: is somewhat imprecise, but here's what I'm trying to do.  For > some reason, my brain is locking up over it. > > I'm moving a 7.2 (yes) database to 8.4.  In the table in question, the > structure is along the lines of: > >        ser

Re: [SQL] Request new version to support "on commit drop" for create temp table ... as select ?

2009-07-14 Thread Scott Marlowe
On Tue, Jul 14, 2009 at 10:47 AM, Tom Lane wrote: > Emi Lu writes: >> I googled to find that "on commit drop" does not support: > >> (a) create temp table as select * from table1 where 1<>2; >> http://archives.postgresql.org/pgsql-sql/2005-09/msg00153.php > > Ah, the pitfalls of believing that the

Re: [SQL] Best way to simulate Booleans

2009-07-06 Thread Scott Marlowe
On Mon, Jul 6, 2009 at 7:22 PM, Peter Headland wrote: > I know, I know, PostgreSQL has Booleans that work very nicely. > Unfortunately, I have to create a schema that will work on Oracle as well as > PostgreSQL, by which I mean that a single set of Java/JDBC code has to work > with both databases.

Re: [SQL] Sequences

2009-07-04 Thread Scott Marlowe
Easiest way is with pg_dump -s -t tablename dbname On Sat, Jul 4, 2009 at 6:35 AM, Jasmin Dizdarevic wrote: > Nice Information. Does somebody know how to get the complete > create-statement of an existing table/view? > > 2009/7/3 Chris Browne >> >> Andre Rothe writes: >> > Where are stored the s

Re: [SQL] Avoiding "will create implicit index" NOTICE

2009-06-01 Thread Scott Marlowe
On Mon, Jun 1, 2009 at 1:32 PM, Bryce Nesbitt wrote: > I'm looking for a good way to avoid triggering the "will create implicit > index" NOTICE that Postgres (all versions) puts out.  This ends up spamming > cron scripts for no good reason: > > => create table junk_six (foo int, primary key (foo))

Re: [SQL] Assigning data-entry tasks to multiple concurrent clients

2009-06-01 Thread Scott Marlowe
On Sun, May 31, 2009 at 9:54 PM, Jamie Tufnell wrote: > BEGIN; > SELECT * FROM records > WHERE in_edit_queue AND id NOT IN ( >   SELECT record_id FROM locked_records >   WHERE locked_since < now() + interval '5 minutes') > LIMIT 1; > > INSERT INTO locked_records (record_id, locked_since) VALUES (?

Re: [SQL] Distinct oddity

2009-05-08 Thread Scott Marlowe
On Fri, May 8, 2009 at 3:28 AM, Maximilian Tyrtania wrote: > am 07.05.2009 20:54 Uhr schrieb Scott Marlowe unter scott.marl...@gmail.com: > >> On Thu, May 7, 2009 at 2:21 AM, Maximilian Tyrtania >> wrote: >>> Hi there, >>> >>> does this look right?

Re: [SQL] Distinct oddity

2009-05-07 Thread Scott Marlowe
On Thu, May 7, 2009 at 2:21 AM, Maximilian Tyrtania wrote: > Hi there, > > does this look right? > > FAKDB=# select count(distinct(f.land)) from firmen f where > f.typlist='Redaktion'; >  count > --- >  1975 > (1 row) > > FAKDB=# select count(distinct(f.land||'1')) from firmen f where > f.typl

Re: [SQL] Query with Parameters and Wildcards

2009-04-26 Thread Scott Marlowe
On Sun, Apr 26, 2009 at 6:21 PM, landsharkdaddy wrote: > > I have a query that works on SQL Server to return customers that contain the > string entered by the user by accepting parameters and using the LIKE > keyword. I would like to move this to postgreSQL but I'm just not sure how > to get it d

[SQL] Re: [GENERAL] Frequently unable connecting to db "server doesn't listen"

2009-04-19 Thread Scott Marlowe
On Sun, Apr 19, 2009 at 8:10 PM, Net Tree Inc. wrote: > > If this e-mail address is not intend use for asking questions using e-mail > suscription, please ignore it.  I could not find any official PostgreSQL > support forum for me to post ask questions. Appreciated if you could you > refer me a fe

Re: [SQL] Postgres entering zombie state once a week in production evnvironment

2009-04-14 Thread Scott Marlowe
On Tue, Apr 14, 2009 at 2:59 PM, Bryce Nesbitt wrote: > Scott Marlowe wrote: >> >> What does pg_locks say during this time?  Specifically about locks >> that aren't granted? > > I don't know, yet.  Though these events go for 15-30 minutes before postgres >

Re: [SQL] Postgres entering zombie state once a week in production evnvironment

2009-04-14 Thread Scott Marlowe
On Tue, Apr 14, 2009 at 12:25 AM, Bryce Nesbitt wrote: > We have a medium scale installation of Postgres 8.3 that is freezing about > once a week.  I'm looking for any hints on how to diagnose the situation, as > nothing is logged. > > The system is matched pair of Sunfire servers, running Debian

Re: [SQL] changing multiple pk's in one update

2009-04-10 Thread Scott Marlowe
2009/4/7 Stuart McGraw : > Hello all, > > I have a table with a primary key column > that contains sequential numbers. > > Sometimes I need to shift them all up or down > by a fixed amount.  For example, if I have > four rows with primary keys, 2, 3, 4, 5, I > might want to shift them down by 1 by

Re: [SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Scott Marlowe
On Thu, Apr 2, 2009 at 3:33 PM, Tena Sakai wrote: > Hi Everybody, > > I am using postgres 8.3.4 on linux. > I often use a line like: >   psql -tf query.sql mydatabase > query.out > > -t option gets rid of the heading and count > report at the bottom.  There is a blank line > at the bottom, however

Re: [SQL] Add: Special sort querstion

2009-04-01 Thread Scott Marlowe
On Fri, Mar 27, 2009 at 6:10 AM, Dominik Piekarski wrote: > Oh, actually every row of the same id-range has the same start_lat/start_lng > coordinates as the predecessors end_lat/end_lng coordinates. But the > question remains the same. Is there a way to do something like ORDER BY > (start_lat = e

Re: [SQL] alter table on a large db

2009-03-19 Thread Scott Marlowe
On Thu, Mar 19, 2009 at 1:57 AM, Zdravko Balorda wrote: > > Hi, > > I need to make some ALTER TABLEs. It takes about 30min to copy > this quite large databse, bat several ours to run a bunch of ALTER > TABLE statements. > Is there any way to make it faster? I wonder what could possibly alter table

Re: [SQL] Problem with an Empty Column

2009-03-10 Thread Scott Marlowe
On Tue, Mar 10, 2009 at 11:41 PM, wrote: > Good Morning list, I am new in the PostgreSQL list, and i have a problem > with a query because i have an empty column in a empty table and i compare > this empty column with a column what have values in other table i use an > LEFT OUTER JOIN and works w

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Scott Marlowe
On Fri, Feb 27, 2009 at 2:02 PM, Carol Cheung wrote: > Hi, > I have a table called temp > >  access_date | active | status > -++ >  2009-02-01  | t      |     15 >  2009-02-01  | f      |     16 >  2009-02-02  | f      |     17 >  2009-02-01  | t      |     17 >  2009-0

Re: [SQL] Is this possible?

2009-02-17 Thread Scott Marlowe
On Mon, Feb 16, 2009 at 7:36 PM, johnf wrote: > Hi, > I'm not to sure this is possible. > > I need to replace a primary key (pkid) with the value of a different field. > I have > pkid = 200 > attendid = 301 > > I need the pkid = 301 > > But there may or may not be a pkid that already exist that ha

Re: [SQL] Grass Root Protectionism

2009-02-07 Thread Scott Marlowe
Oh, and might I ask what you've done for pgsql, Mr. hiding behind an anonymous email address at yahoo? -- 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] Grass Root Protectionism

2009-02-07 Thread Scott Marlowe
On Sat, Feb 7, 2009 at 11:40 PM, Boycott Tech Forums wrote: > I am a Sr. Software Engineer in USA who (like many others) have been > unfairly treated with offshore software engineers who have the audacity to > take our jobs, yet ask (mostly) American engineers to help them with their > technical c

Re: [SQL] some howto/theory book/tutorial on practical problem solving in SQL

2009-01-11 Thread Scott Marlowe
On Sun, Jan 11, 2009 at 9:32 AM, Ivan Sergio Borgonovo wrote: > > My current problem is how to manage discounts in SQL, inside > transactions. Specifically how to "delete" promotions if they are > overlapping, considering I have to display discounted prices on a 1M > article DB and I may have hund

Re: [SQL] Object create date

2008-12-29 Thread Scott Marlowe
On Mon, Dec 29, 2008 at 11:23 AM, Fernando Hevia wrote: > Hi list, > > I'm having a hard time trying to find out if the latest patches have been > applied to my application (uses lots of pgplsql functions). > Does Postgres store creation date and/or modification date for tables, > functions and ot

  1   2   3   4   >