Re: [SQL] aggregation problem: first/last/count(*)

2009-01-26 Thread Volkan YAZICI
On Mon, 26 Jan 2009, "Marc Mamin" writes: > create table test > ( > time int8, --store the time as epoch > a_group varchar, > category varchar > ) > > ... > > SELECT > FIRST.a_group, > FIRST.time as first_time, > FIRST.category as first_category, > LAST.time as last_time

Re: [SQL] Test if a table is present

2008-07-25 Thread Volkan YAZICI
On Sat, 26 Jul 2008, "Ole Ekerhovd" <[EMAIL PROTECTED]> writes: > How can I test if a table is present in database? SELECT TRUE FROM information_schema.tables WHERE table_name = '' AND table_schema = '' BTW, this query is portable across database systems supporting information

Re: [SQL] pg_advisory_lock(bigint) vs. LOCK TABLE

2008-07-17 Thread Volkan YAZICI
On Thu, 17 Jul 2008, Alvaro Herrera <[EMAIL PROTECTED]> writes: > Volkan YAZICI wrote: >> What's the difference between below two queue implementations? > > They are two different lock spaces. pg_advisory_lock does not conflict > with regular system locks, wher

[SQL] pg_advisory_lock(bigint) vs. LOCK TABLE

2008-07-16 Thread Volkan YAZICI
Hi, What's the difference between below two queue implementations? -- -- With advisory locks. -- BEGIN; SELECT pg_advisory_lock((SELECT oid FROM pg_class WHERE relname = 'queue')); DELETE FROM queue WHERE id = (SELECT MI

Re: [SQL] Create Table Problem

2008-06-13 Thread Volkan YAZICI
"Shavonne Marietta Wijesinghe" <[EMAIL PROTECTED]> writes: > IF (table not found) THEN > CREATE TABLE distributors ( > did integer, > namevarchar(40), > UNIQUE(name) > ); > END IF Assuming you're in a procedure (above code snippet looks to be executed within

Re: [SQL] update with multiple fields as aggregates

2008-05-03 Thread Volkan YAZICI
On Sat, 3 May 2008, Alexy Khrabrov <[EMAIL PROTECTED]> writes: > I need to fill two columns of a Rats table from an Offset1 table, > where for each Id row in Rats we need to fill an average offset and > the sum of all offset from Offset1 with the same Id. I can create a > derivative table like thi

Re: [SQL] How I can check a substring is a valid number in postgresql ?

2008-04-24 Thread Volkan YAZICI
On Thu, 24 Apr 2008, "Anoop G" <[EMAIL PROTECTED]> writes: > How I can check a substring is a valid number in postgresql ? SELECT col ~ '[0-9]+'; Regards. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsq

Re: [SQL] How to find double entries

2008-04-15 Thread Volkan YAZICI
On Wed, 16 Apr 2008, Andreas <[EMAIL PROTECTED]> writes: > how can I find double entries in varchar columns where the content is > not 100% identical because of a spelling error or the person > considered it "looked nicer" that way? > > I'd like to identify and then merge records of e.g. 'google'

Re: [SQL] dateformat issue

2008-04-10 Thread Volkan YAZICI
Hi, Gavin 'Beau' Baumanis <[EMAIL PROTECTED]> writes: > I have a question about dates, please. > > I am using Coldfusion and Postgres > I have a function that takes the ate entered in a form and converts it > into an odbc date format. > > So the string ends up being; > {d '2008-04-10'} > > Strange

Re: [SQL] count question

2008-04-08 Thread Volkan YAZICI
On Wed, 9 Apr 2008, novice <[EMAIL PROTECTED]> writes: > Is it possible to write a query to produce: > > meter_id | no_of_bays | bay_id > --++--- > 5397 | 2 | 5397-01 > 5397 | 2 | 5397-02 > 5409 | 3 | 5409-01 > 5409

Re: [SQL] Sequential non unique IDs

2008-04-01 Thread Volkan YAZICI
On Tue, 1 Apr 2008, "John Reeve" <[EMAIL PROTECTED]> writes: > I have the following scenario: > > A 'task' table that has the fields: > id => primary key, updated on each insert using a sequence > customerid => integer > localid => integer > > I need the localid to be sequential an

Re: [SQL] compare 2 tables in sql

2008-03-19 Thread Volkan YAZICI
On Wed, 19 Mar 2008, "Tena Sakai" <[EMAIL PROTECTED]> writes: > Is there a sql way to compare (in a diff/cmp sense) > 2 tables? You can diff "pg_dump --schema-only" output of the related tables. (I attached an ad-hoc script once I wrote to use for such stuff.) I don't know about [php]pgadmin, but

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Volkan YAZICI
Franklin Haut <[EMAIL PROTECTED]> writes: > I Tries create a cast but the function text doesn't exist more in PG 8.3 sql-createcast.html tells that "It is normally not necessary to create casts between user-defined types and the standard string types (text, varchar, and char(n)). PostgreSQ

[SQL] Partitioning and Foreign Keys

2007-11-04 Thread Volkan YAZICI
Hi, We have a customers database growing ~1,000 rows per day. (Nearly, %40 of the table is garbage and won't get queried that often in the future. But we keep them for statistical analysing purposes of previous jobs.) Despite table allocates relatively small size on the disk, requirement of instan

Re: [SQL] transactional shared variable in postgresql

2006-11-18 Thread Volkan YAZICI
Hi, On Nov 18 06:00, Rajesh Kumar Mallah wrote: > Is there any way to set a variable from a web application (using > dbi/perl , libpq etc), and access the same variable from a C trigger > inside a transaction ? Also you may consider using a sequence for storing an integer value. This approach wil

Re: [SQL] transactional shared variable in postgresql

2006-11-18 Thread Volkan YAZICI
Hi, On Nov 18 06:00, Rajesh Kumar Mallah wrote: > Is there any way to set a variable from a web application (using > dbi/perl , libpq etc), and access the same variable from a C trigger > inside a transaction ? Why don't you use a temporary table for that purpose? Regards.

Re: [SQL] drop a check

2006-11-13 Thread Volkan YAZICI
On Nov 13 06:38, ivan marchesini wrote: > thank you for your answer... > I have tried to verify the table > information_schema.constraint_column_usage, but, and I was really > surprised, I have found nothing inside it.. > it seems there are not checks!!! > I have also seen the manual page you sugg

Re: [SQL] drop a check

2006-11-13 Thread Volkan YAZICI
On Nov 13 05:32, ivan marchesini wrote: > I have created a check constraint without giving it a name.. > now I have a check named "$25" in my table that I need to drop or > modify!!! > How can I do??? > with names is simple > > alter table tablename drop constraint constraintname; > > but without

Re: [SQL] COALESCE and GROUP BY and AGGREGATES

2006-11-13 Thread Volkan YAZICI
On Nov 13 10:49, Erik Jones wrote: > Ok, here's a sample table for the question I have: > > CREATE TABLE sales_table ( > sale_type varchar default 'setup' not null, > sale_amount numeric not null > sale_date timestamp without timezone default now()); > > So, let's say there are 3 different sale_t

Re: [SQL] record datatype comparisons

2006-11-01 Thread Volkan YAZICI
On Nov 01 09:28, Andrew Sullivan wrote: > On Tue, Oct 31, 2006 at 11:45:00PM +0200, Volkan YAZICI wrote: > > > Note the column headers. They're differently shaped. Because > > > pseudotype record doesn't have a shape, equality doesn't make sense, > >

Re: [SQL] record datatype comparisons

2006-10-31 Thread Volkan YAZICI
On Oct 31 06:49, Alvaro Herrera wrote: > George Pavlov wrote: > > thanks fo the reply. i was misled by pgAdmin (1.6) giving both as > > "record" in the datatype (i thought "row" and "?column?" were just "best > > guess" column headers). > > > > so, if they are indeed differently shaped is there a

Re: [SQL] record datatype comparisons

2006-10-31 Thread Volkan YAZICI
On Oct 31 04:22, Andrew Sullivan wrote: > On Tue, Oct 31, 2006 at 12:38:36PM -0800, George Pavlov wrote: > > Both (1::int,'a'::varchar) and (select (2::int,'a'::varchar)) are of > > type record, aren't they? > > I don't think so. Psql gives you a hint that not: > > testing=# SELECT (1::int, 'a':

Re: [SQL] Sorting items in aggregate function

2006-09-12 Thread Volkan YAZICI
On Sep 12 04:46, Steven Murdoch wrote: > I would like to concatenate sorted strings in an aggregate function. I > found a way to do it without sorting[1], but not with. If the array elements will be made of integers, then you can use sort() procedure comes with intarray contrib module. For instanc

Re: [SQL] UTF-8 Problem ?

2006-06-15 Thread Volkan YAZICI
On Jun 15 01:01, Milen Kulev wrote: > I want to insert some german specific characters (umlaut characters) > into a table, but I am getting the following > Error message: > postgres=# EXECUTE stmt (1, 1 , 1 , 'Grün') ; > ERROR: invalid UTF-8 byte sequence detected near byte 0xfc > ... > postgr

Re: [SQL] Sorting aggregate column contents

2006-05-02 Thread Volkan YAZICI
On May 02 06:00, Everton Luís Berz wrote: > Is it possible to sort the content of an aggregate text column? > > Query: > select s.name, ag_concat(c.name) from state s > inner join city c on (c.idstate = s.idstate) > group by s.name > order by s.name; IMHO, you can receive results ordered by using

Re: [SQL] Primary key reference count

2006-04-19 Thread Volkan YAZICI
On Apr 19 02:01, Wiebe Cazemier wrote: > I'm trying to find which of the tables in pg_catalog contains the amount of > references to a primary key, but I can't seem to find it. Here's simple query, to list which table's which columns references to a specific table. (Hope this is what you asked for

Re: [SQL] Simple plpgsql question

2006-04-14 Thread Volkan YAZICI
On Apr 13 11:38, Todd Kennedy wrote: > What I'd also like to do is have it create a new row in a different > table using the automatically assigned id as a reference, but I'm > unsure of how to obtain the id of the newly created row in the first > table. If I understand you right, you're refering

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

2006-03-25 Thread Volkan YAZICI
On Mar 25 10:11, george young wrote: > On Mar 23 11:44, Don Maier <[EMAIL PROTECTED]> wrote: > > Conversely, is it possible to construct a (single column) result set > > from a select expression on a one-dimensional array with an unknown > > number of elements? > > Not so easy without a custom

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Volkan YAZICI
Hi, On Mar 11 05:31, Jesper K. Pedersen wrote: > Is it possible to use SQL to merge data into one result? test=# SELECT id, info FROM concat_t; id | info +-- 1 | A 2 | B 1 | AA 3 | C 1 | D 1 | DD (6 rows) test=# SELECT array_to_string(ARRAY(SELECT info FROM concat_t WHERE i

Re: [SQL] Check/unique constraint question

2006-03-05 Thread Volkan YAZICI
On Mar 05 12:02, Nikolay Samokhvalov wrote: > Unfortunately, at the moment Postgres doesn't support subqueries in > CHECK constraints I don't know how feasible this is but, it's possible to hide subqueries that will be used in constraints in procedures. Here's an alternative method to Nikolay's:

Re: [SQL] Matching several rows

2006-01-18 Thread Volkan YAZICI
On Jan 18 09:33, Michael Glaesemann wrote: > On Jan 18, 2006, at 20:55 , Volkan YAZICI wrote: > >SELECT t.id > >FROM (SELECT id, sum(1) AS s > > FROM id_n_rights > > WHERE rights = ANY(ARRAY[2,5,10]) > > GROUP BY id) AS t > >WHERE t.s = 3;

Re: [SQL] Matching several rows

2006-01-18 Thread Volkan YAZICI
Hi, On Jan 18 05:43, Ivan Steganov wrote: > IDRIGHT > - > 201 > 202 > 205 > 2010 > 302 > 3010 > > Now I need to find out which IDs have, say rights 2 AND 5 AND 10. SELECT t.id FROM (SELECT id, sum(1) AS s FROM

[SQL] Combining two SELECTs by same filters

2005-10-26 Thread Volkan YAZICI
Hi, I've a table like: => SELECT dt FROM sales WHERE id = 2; dt 2005-10-25 21:43:35.870049 2005-10-25 21:43:36.254122 2005-10-25 21:43:36.591196 2005-10-25 21:43:36.893331 2005-10-25 21:43:37.265671 2005-10-25 21:43:37.688186 2005-10-25 22:25:35.2131

Re: [SQL] How to delete Large Object from Database?

2005-10-08 Thread Volkan YAZICI
Hi, On 10/7/05, Richard Huxton wrote: > Deleting the OID does not remove the object itself - see details of > lo_unlink() in Chapter 28 of the manuals. > > I seem to recall some other utilities in the contrib/ directory of the > source distribution too. Could it be `contrib/lo'? Here's some snip

Re: [SQL] SELECT very slow

2005-06-09 Thread Volkan YAZICI
Hi, On 6/9/05, Thomas Kellerer <[EMAIL PROTECTED]> wrote: > No I want the whole result. As Tom underlined: On 6/9/05, Tom Lane <[EMAIL PROTECTED]> wrote: > The solution is to use a cursor and FETCH a reasonably > small number of rows at a time. AFAIC, query results are stored as arrays in PGres

Re: [SQL] large object support in PostGres 7.4

2005-06-06 Thread Volkan YAZICI
Hi, On 6/7/05, Vadivel Subramaniam <[EMAIL PROTECTED]> wrote: > My doubt is, do these API's operate on character data? i.e., My table > schema is like this > > table (name varchar, script varchar). I have to store a large data(in > character form) in the script column (upto 3 MB). > > As of m

Re: [SQL] postgre variable

2005-05-19 Thread Volkan YAZICI
Hi, On 5/19/05, bandeng <[EMAIL PROTECTED]> wrote: > i want to make dynamic sql query like this > > select * from tb_cust where name='erick' and age='20' > > to > > select * from tb_cust $1 > > i have tried but error comeup I think there's a confusion about the usage of parameters like $1, $2

Re: [SQL] Java and Currval

2005-05-02 Thread Volkan YAZICI
Hi, On 5/2/05, Sam Adams <[EMAIL PROTECTED]> wrote: > I'm having trouble getting the currval function to work from a Java > program (or from Postgres at all). I want to get the value of addressid > in the table taddress. The best I seem to be able to come up with is > 'SELECT currval(taddress.addr

Re: [SQL] PHP postgres connections

2005-04-30 Thread Volkan YAZICI
Hi, On 4/29/05, Mauro Bertoli <[EMAIL PROTECTED]> wrote: > I need to connect to 2 differents Postgres 8.0.0 > databases located in the same machine using the same > PHP script with an "db wrapper object" instance > (pg_Connect)... simply a PHP page with contemporarily > 2 database connections...