[SQL] Presenting data in 5 Rows & 5 Cols for 25 specific values

2013-08-03 Thread F Bax
I have a table containing tasks completed in a game I'm playing. The game includes an extra BINGO Challenge where each cell of standard BINGO card contains a particular task to be completed. The goal is score a BINGO (row, column, diagonal) by completing five (or more) tasks from the BINGO cards.

Re: [SQL] Understanding Binary Data Type

2012-05-24 Thread F. BROUARD / SQLpro
Hi Le 22/05/2012 19:13, Carlos Mennens a écrit : Hello everyone! I wanted to ask the list a question about the 'bytea' data type& how I can picture this in my head. I've been reading SQL for about a few months now and since then, I've only been working with textual data. Basically I'm familiar

Re: [SQL] Natural sort order

2012-03-01 Thread F. BROUARD / SQLpro
The fastest way is to create a ref table with all possible entries, ordered with an additionnal numerical column, indexing it and make a join from your table to this ref table. A + Le 17/12/2011 11:33, Richard Klingler a écrit : Morning... What is the fastest way to achieve natural ordering

Re: [SQL] MS-SQL Store Procedure to Postgresql Function

2012-02-02 Thread F. BROUARD / SQLpro
Actullay there is no transaction support in internal PG routines. So the code you posted is not translatable in PG PL/SQL because it involve a transaction inside the process. A + Le 30/01/2012 07:42, Rehan Saleem a écrit : hi , how i can convert this store procedure to PostgreSQL function, e

Re: [SQL] [GENERAL] Creating rule for sliding data

2011-10-09 Thread F. BROUARD / SQLpro
I am answering to myseilf... the good syntax is something like : CREATE RULE R_U_MSR_BEFORE2000x AS ON UPDATE TO T_MESURE_MSR WHERE ( NEW.MSR_DATE < DATE '2000-01-01' ) DO INSTEAD ( -- rows does not change partition : UPDATE T_MESURE_BEFORE2000_MSR SET MSR_ID = NEW.MSR_ID, MSR_

[SQL] [GENERAL] Creating rule for sliding data

2011-10-09 Thread F. BROUARD / SQLpro
Hello, I have a problem to find the good syntax for a rule for rows going for one partition to the other in cas of an update. Let me give the conditions : 1 - having a mother table CREATE TABLE T_MESURE_MSR ( MSR_ID INT NOT NULL, MSR_DATEDATE NOT NULL, MSR_MESURE FLOAT NOT

Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread F. BROUARD / SQLpro
I write a paper on this topic comparing queries for PG, SQL Server and MySQL. Can you read french ? http://blog.developpez.com/sqlpro/p9821/langage-sql-norme/agregation-d-intervalles-en-sql-1/ The worst query is the RECURSIVE one ! A + Le 15/06/2011 17:23, Jira, Marcel a écrit : Hi! Althou

[SQL] FOR EACH STATEMENT trigger ?

2011-05-06 Thread F. BROUARD / SQLpro
Hi there I am trying to get an example of SET BASED trigger logic with FOR EACH STATEMENT, but I cannot find any example involving the pseudo table NEW (or OLD) in the trigger function SQL statement. Let me give you a real life example. Suppose we have the above table : CREATE TABLE T_PRODUIT

[SQL] Get id of a tuple using exception

2011-04-14 Thread f vf
Hello, i'm using a pl/sql procedure and I prevent inserting duplicate tuples using an exception for example: BEGIN INSERT INTO "Triples"(id, subject, predicate, "object") VALUES (id, sub_i, pred_i, obj_i); * EXCEPTION WHEN unique_violation THEN --do som

[SQL] postgre2postgre

2009-02-04 Thread F.
Hello, I am trying to migrate from postgresql-8.1.11-1.el5_1.1 (i386) to postgresql-8.3.4-1.fc10.x86_64. But I can not. Database uses ltree and tsearch and the problem seems to be this. I am using, pg_dump in first computer and psql in second computer to execute script. First error: psql:inform

[SQL] Bizarre sort order

2008-03-26 Thread Conlon, Joseph F SIK
Does anyone think this is the correct behavior? adaps_db=# select * from upc_usage order by 1 ; usage -- 53E ABC CYPHER _GENERAL H66 HAWK _JOE RSRA S61 S65 S70 S76 S92 XWING (14 rows) It appears to be ignoring the underscore! Database has LATIN1 encoding and was recently

Re: [SQL] Returning String as Integer

2006-05-05 Thread Hogan, James F. Jr.
Here is a Perl function a friend of mine wrote to help with this... Problems I ran into were errors because of NON NUMERIC Characters in the String... Casting would fail It doesn't catch all cases but it has been quite helpful to me $x = $_[0]; $x =~ s/^[^-\d\.]*//; $x =~ s/\,//g; $x = $x * 1;

[SQL] audit table containing Select statements submitted

2006-05-04 Thread Hogan, James F. Jr.
No response from the pgsql-admin list so I though I would try cross posting here: pgsql-sql@postgresql.org pgsql-general@postgresql.org I just know I am not the first to try and do this Jim * Can anyone point me in a direction that may help me populate in real time a table

Re: [SQL] SQL Functions

2005-10-26 Thread Thomas F. O'Connell
eters available. http://developer.postgresql.org/docs/postgres/plpgsql.html#PLPGSQL- OVERVIEW -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Open Source Solutions. Optimized Web Development. http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-63

Re: [SQL] Strange join...maybe some improvements???

2005-10-13 Thread Thomas F. O'Connell
What indexes do you have on these tables?And have you ANALYZEd all three recently? --Thomas F. O'ConnellCo-Founder, Information ArchitectSitening, LLCOpen Source Solutions. Optimized Web Development.http://www.sitening.com/110 30th Avenue North, Suite 6Nashville, TN 37203-6320615-469-515061

Re: [SQL] EXECUTE with SELECT INTO variable, or alternatives

2005-09-30 Thread Thomas F. O'Connell
hit upon one of your options. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-469-5150 615-469-5151 (fax) On Sep 29, 2005, at 1:16 PM, Mario Spl

Re: [SQL] Searching for results with an unknown amount of data

2005-09-05 Thread Thomas F. O'Connell
ccommodate arbitrary lists, I can't imagine how you'd do it without using a PL, but you could still build your IN clause programmatically. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110 30th

Re: [SQL] Numerical variables in pqsql statements

2005-08-30 Thread Thomas F. O'Connell
Well, browse through this list: http://www.postgresql.org/docs/books/ I can't make any recommendations, as I am fairly familiar with the online documentation, which, when supported by the community, seems to be pretty good. -- Thomas F. O'Connell Co-Founder, Information Architec

Re: [SQL] question

2005-08-29 Thread Thomas F. O'Connell
Matt, In PostgreSQL 8.0.3, I see: postgres=# select nullif( '1', '' ); nullif 1 (1 row) postgres=# select nullif( '', '' ) is null; ?column? -- t (1 row) What behavior are you expecting? -- Thomas F. O'Connell Co-Founder, Inform

Re: [SQL] Numerical variables in pqsql statements

2005-08-29 Thread Thomas F. O'Connell
y that you know to be safe or passing in safe values generated elsewhere in the application, you're less likely to need to quote your variables explicitly or to build queries dynamically. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source

Re: [SQL] sql function: using set as argument

2005-08-15 Thread Thomas F. O'Connell
Is there a reason not to build it in as a sub-query?E.g., if you have a function get_count( int ): SELECT count(b_column)FROM some_tableWHERE some_field_1 in (    SELECT a_column    FROM a_table    WHERE some_condition)AND some_field_2 = $2; --Thomas F. O'ConnellCo-Founder, Inform

Re: [SQL] Grouping Too Closely

2005-06-24 Thread Thomas F. O'Connell
This doesn't give me quite what I'm looking for because I need there to be only one of each possible value of seq2 to be returned for each value of fkey. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.si

[SQL] Grouping Too Closely

2005-06-23 Thread Thomas F. O'Connell
ayer_idThis seems like it works, but it is abominably slow, running on the order of days across 1.5 million rows rather than the seconds (or preferably milliseconds) I'd prefer.I have this annoying feeling that I'm overlooking a reasonably efficient in-between query.-- Thomas F. O'Conne

Re: [SQL] DROP IF ...

2005-05-24 Thread Thomas F. O'Connell
le; RETURN true; ELSE RETURN false; END IF; END; ' LANGUAGE 'plpgsql'; -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i™ http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashvi

Re: [SQL] query

2005-03-21 Thread Thomas F . O'Connell
You should be able to use the CURRENT_DATE function in place of sysdate. You might need to cast the 1 explicitly to an interval. As in: CURRENT_DATE - '1 day'::interval -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Aven

Re: [SQL] Making NULL entries appear first when ORDER BY ASC

2005-02-23 Thread Thomas F . O'Connell
Yup. Got it. Wasn't thinking clearly about what expression meant. Thanks! -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Feb 23, 2005, at 2:33 PM, Bruno Wolff

Re: [SQL] plpgsql functions and NULLs

2005-01-31 Thread Thomas F . O'Connell
As far as I know, you didn't post your actual table definitions (or full queries) earlier, so I'm not exactly sure what you mean. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 372

Re: [SQL] plpgsql functions and NULLs

2005-01-31 Thread Thomas F . O'Connell
This sounds like a perfect candidate for a LEFT OUTER JOIN. See: http://www.postgresql.org/docs/7.4/static/queries-table- expressions.html#QUERIES-FROM Yours would looks something like: SELECT * FROM ... LEFT JOIN candidate AS c ON <...>.omcr_id = c.omcr_id AND ... -tfo -- Thomas F. O'

Re: [SQL] How to update dependent tables AND design considerations

2005-01-25 Thread Thomas F . O'Connell
Have you looked at the documentation on triggers? -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Jan 23, 2005, at 11:23 AM, Klaus W. wrote: Hi! Because i got no answ

Re: [SQL] Counting Distinct Records

2004-11-17 Thread Thomas F . O'Connell
her tables. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Nov 17, 2004, at 8:52 AM, Stephan Szabo wrote: On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: Hmm. I wa

[SQL] Counting Distinct Records

2004-11-16 Thread Thomas F . O'Connell
? Furthermore, is there a better way of performing this sort of operation in postgres (or just in SQL in general)? Thanks! -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260

Re: [SQL] SQL confusion

2004-10-12 Thread Thomas F . O'Connell
This is untested, but it might be enough to get you started: SELECT namecounter FROM name n WHERE NOT EXISTS ( SELECT 1 FROM name WHERE hh > 0 AND famnu = n.famnu ) GROUP BY famnu HAVING birthdate = min( birthdate ); What I'm trying to do here is grab all families th

Re: [SQL] help on a query

2004-10-08 Thread Thomas F . O'Connell
I think the OUTER JOIN version is probably more efficient, but EXPLAIN would tell you. -tfo On Oct 8, 2004, at 8:02 AM, CHRIS HOOVER wrote: Just curious, what is wrong with the first way of coding the solution? --( Forwarded letter 1 follows )- Date: Fri, 8 Oct

Re: [SQL] help on a query

2004-10-07 Thread Thomas F . O'Connell
A query that should get the job done is: SELECT registration_id FROM registrations r WHERE NOT EXISTS ( SELECT 1 FROM receipts WHERE registration_id = r.registration_id ); There might be a more efficient version with JOINs that don't require a subquery, but this should get

Re: [SQL] Extracting fieldnames from a TABLE

2004-09-01 Thread Thomas F . O'Connell
One way to do this is to use the column_info database handle method. Here's a little perl script that accepts a table name as an argument and returns the column names: #!/usr/bin/perl use DBI; use strict; my( $database, $table ) = @ARGV; my $dbh = DBI->connect( "dbi:Pg:dbname=$database", 'postgre

Re: [SQL] CASE returning multiple values (was SQL Help)

2003-05-31 Thread C F
I was afraid someone was going to ask that :) Okay, I'll do my best at explaining where I'm coming from I'm working on a mapping application it is user-configurable.  What this means (as it pertains to this disucssion) is that the through a configuration file, the user is able to define the ru

[SQL] SQL Help

2003-05-31 Thread C F
Hello, I already tried this same basic question with no response  maybe I was too wordy.  So here it is simplified what's the best way to write this query?  I'm open to using stored procedures, but even then I don't know how I would conditionally populate a resultset (refcursor).  Notice th

[SQL] Returning Multiple Values from CASE statement?

2003-05-30 Thread C F
Hello, This is probably an odd request, but I have my reasons :)  Basically, what I need to do is return *multiple* values each for a number of criteria.  Imagine being able to return multiple values for each CASE statement... that's what I'm trying to do.  I can solve this with subqueries, but as

[SQL] the optimizer and exists

2002-08-29 Thread Thomas F. O'Connell
id int2 foo_id int2 references foo( id ) ); imagine that the tables are populated. now, consider the query select b.foo_id from bar b where b.id = and exists( select * from foo f where b.foo_id = f.id and b.id = ); now consider the same query with "selec

Re: [SQL] random rows

2001-04-26 Thread Joao Pedro M. F. Monoo
fetch the n desired rows example SELECT * FROM test_table LIMIT 100 OFFSET 100; this will skip to row number 100 and the fetch the next 100 rows []´s - Joao Pedro M. F. Monoo Infortrade Information Systems #183816 Linux Registered User Slackware 7.1 r

[SQL] using top-level aggregate values in subqueries

2001-04-23 Thread Thomas F. O'Connell
from the docs, i know that if you have two tables, foo and bar, you can write a query such as select f.bling from foo f where f.id = ( select max( b.id ) from bar b where b.bling = "i kiss you!" ); what i'm wondering is if you need that subquery in two pl

Re: [SQL] I can be a BUG?

2000-12-02 Thread Edipo E. F. Melo
template1 and on project database too. Thank's for help! []'s Edipo Elder F. de Melo

[SQL] I can be a BUG?

2000-12-01 Thread Edipo E. F. Melo
We using PostgreSQL 7.0.3. under Conectiva Linux 5.0. I'm sending the ASCII script attached. PS.: Sara, sorry if you receive more than one copy of this mensage, but I was uncertain about you correct e-mail address. Thank's and "Feliz Natal" to all, []'s Edipo Elder F. de Melo TESTE.ZIP

Re: [SQL] Date problem

2000-10-07 Thread Edipo E. F. Melo
4ADT (I live in Brazil, Natal city). > >Hm. On a RedHat Linux box, with pgsql 7.0.2: > >regression=# show TimeZone ; >NOTICE: Time zone is AST4ADT >SHOW VARIABLE >regression=# select '2000-01-01'::date::timestamp; >?column? >---- > 2000-01-01 00:00:00-04 []'s Edipo Elder F. de Melo

[SQL] Date problem

2000-09-28 Thread Edipo E. F. Melo
I'm using OS/2 with Fix Pack 12, Postgresql 7.0.2. Can any one explain this? []'s Edipo Elder F. de Melo

[SQL] date is not equals to dia/month/year: what's wrong?

2000-09-26 Thread Edipo E. F. Melo
I'm doing something wrong? if the date is '2000-04-01', the "frac-date-select" returns day: 31, month: 03, year 2000. More over: '2000-01-01', splited: 31, 12, 1999. []'s Edipo Elder F. de Melo