Re: [SQL] list of all months

2010-03-15 Thread Dawid Kuroczko
On Mon, Mar 8, 2010 at 13:25, query wrote: > > Hi, > > I want to display data for all days in a month even if no data exists for > that month. Some of the days in a month might not have any data at all. With > normal query, we can display days only if data exists.But I want to display > rows fo

Re: [SQL] Subselects returning array and ANY...

2008-02-27 Thread Dawid Kuroczko
On Thu, Feb 28, 2008 at 1:11 AM, Josh Berkus <[EMAIL PROTECTED]> wrote: > Dawid, > >SELECT * FROM foo WHERE t = ANY (SELECT '{x4,5,zzz}'::text[]); > > ERROR: operator does not exist: text = text[] > > HINT: No operator matches the given name and argument type(s). You > > might need to add

[SQL] Subselects returning array and ANY...

2008-02-27 Thread Dawid Kuroczko
A simple text case =# CREATE TEMP TABLE foo (t text); CREATE TABLE =# INSERT INTO foo SELECT 'x'||n FROM generate_series(1,100) AS x(n); INSERT 0 100 This works: SELECT * FROM foo WHERE t = ANY ('{x4,5,zzz}'::text[]); And this works too: SELECT * FROM foo WHERE t IN (SELECT t FROM foo LIMIT

[SQL] JOINing SET returning function.

2008-01-29 Thread Dawid Kuroczko
Hi, I have a set returning function returning variable number of rows (RETURNS SETOF RECORD). I have a table which contains a list of input values for this SRF. I want to write SQL which will return all the data found there. A simple test case: a tble CREATE TEMP TABLE list (n int); INSERT INT

[SQL] Scrolling cursors in PL/PgSQL

2007-11-01 Thread Dawid Kuroczko
Hello. Is there a way to scroll a cursor from within PL/PgSQL? I tried EXECUTE, but: ERROR: cannot manipulate cursors directly in PL/pgSQL HINT: Use PL/pgSQL's cursor features instead. The idea would be that PL/pgsql function would look through (all) query results, then rewind the cursor and

Re: [SQL] [ADMIN] Postgres Array Traversing Problem

2007-10-05 Thread Dawid Kuroczko
On 10/4/07, yogesh <[EMAIL PROTECTED]> wrote: > Hello Friends, > > I have a Problem in Accessing Arrays in the Postgres. > The Description of my problem is given > here:--- > I have two array of numeric types. One That stores the IDs and Other > Store their va

Re: [SQL] Need help with CASE statement in Function

2007-10-03 Thread Dawid Kuroczko
On 10/3/07, Hengky Lie <[EMAIL PROTECTED]> wrote: > Dear friends, > I am a new user to postgreSQL and really need help to solve my "stupid ?" > problem. > > I have created function with 4 arguments like this : > > CREATE OR REPLACE FUNCTION "public"."fHistoryCard" (begdate date, enddate > date, Pr

Re: [SQL] Finding broken regex'es

2007-10-03 Thread Dawid Kuroczko
On 10/3/07, Filip Rembiałkowski <[EMAIL PROTECTED]> wrote: > 2007/10/3, Dawid Kuroczko <[EMAIL PROTECTED]>: > > > CREATE TABLE rx_check ( > > rx text CHECK ('' ~ rx IN ('t','f')) > > ); > > wow. This is beautiful :)

Re: [SQL] Finding broken regex'es

2007-10-03 Thread Dawid Kuroczko
On 10/2/07, Enrico Weigelt <[EMAIL PROTECTED]> wrote: > > Hi folks, > > > I'm looking for some way to find broken regex'es in some column > to kick them off. For now I'm regularily fetching all regexes > from an PHP script, try an preg_match() and so find the broken > ones to later remove them. > >

Re: [SQL] Negative lookbehind assertions in regexs

2005-09-03 Thread Dawid Kuroczko
On 9/3/05, Julian Scarfe <[EMAIL PROTECTED]> wrote: >> I'd like a regex that matches 'CD' but not 'ABCD' in any part of the>> regex.From: "Bruno Wolff III" <[EMAIL PROTECTED]>> Something like: > (^.?CD)|([^B]CD)|([^A]BCD)Thanks to Bruno, and to Dawid who replied offline.  The above does the jobnice

Re: [SQL] How to connect ORACLE database from Postgres function using plpgsql/pltclu?

2005-08-01 Thread Dawid Kuroczko
On 8/1/05, Dinesh Pandey <[EMAIL PROTECTED]> wrote: > Is there any way to connect ORACLE database from Postgres function using > plpgsql/pltclu? With PLpgSQL I don't think its possible. I don't know how about PLtclU (should be possible), but I'm sure its doable from PLperlU (using DBI). Don't e

Re: [SQL] Dumping table definitions

2005-07-18 Thread Dawid Kuroczko
On 7/18/05, Mark Fenbers <[EMAIL PROTECTED]> wrote: > I am looking for a way to reformat the information that is generated from > \d mytable > into SQL syntax, such that the table can be recreated with 'psql -f > mytable.sql' complete with index and constraint definitions. I can do > awk and s

Re: [SQL] Make COUNT(*) Faster?

2005-07-08 Thread Dawid Kuroczko
On 7/8/05, Rod Taylor <[EMAIL PROTECTED]> wrote: > Create 2 sequences, one for counting tuple additions and one for > counting tuple deletions. > > When you INSERT a tuple, bump the "added" sequence (select nextval()); > > When you DELETE a tuple, bump the "deleted" sequence (select nextval()); >

Re: [SQL] Make COUNT(*) Faster?

2005-07-08 Thread Dawid Kuroczko
On 7/8/05, Steve Wampler <[EMAIL PROTECTED]> wrote: > > None of those transactions have COMMITted, so there are some 78 tuples > > "in limbo" spread across 16 transactions. > > > > If there were some "single secret place" with a count, how would you > > suggest it address those 78 tuples and 16 tra

Re: [SQL] ORDER records based on parameters in IN clause

2005-06-30 Thread Dawid Kuroczko
On 6/30/05, M.D.G. Lange <[EMAIL PROTECTED]> wrote: > Another option would be: > SELECT * FROM table WHERE id=2003 OR id=1342 OR id=799 OR id=1450; > This should give you the results in the right order... I don't think so... create temporary table seq as select * from generate_series(1,20) as g(

Re: [SQL] ORDER records based on parameters in IN clause

2005-06-29 Thread Dawid Kuroczko
On 6/27/05, Riya Verghese <[EMAIL PROTECTED]> wrote: > I have a stmt where the outer-query is limited by the results of the inner > query. I would like the outer query to return records in the same order as > the values provided in the IN clause (returned form the inner query). > > The inner_quer

Re: [SQL] ENUM like data type

2005-06-29 Thread Dawid Kuroczko
On 6/28/05, Martín Marqués wrote: > El Mar 28 Jun 2005 13:58, PFC escribió: > > Personnally I use one table which has columns (domain, name) and which > > stores all enum values for all different enums. > > I have then CHECK( is_in_domain( column, 'domain_name' )) which is a > > simple

Re: [SQL] [GENERAL] Foreign Key relationship between two databases

2005-01-27 Thread Dawid Kuroczko
On Thu, 27 Jan 2005 18:47:44 +0530, Sandeep Gaikwad <[EMAIL PROTECTED]> wrote: > Hi, > I am using postgres 7.3.4. I am new to postgres. > I can give foreign key relationship between two tables of same > database. Can I give foreign key relationship between tables of two databases

Re: [SQL] Columns into rows.

2005-01-13 Thread Dawid Kuroczko
On Thu, 13 Jan 2005 11:45:52 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: > > SELECT * FROM (SELECT id, path AS path_a FROM new_table_paths WHERE > > pathtype = 'a') AS a NATURAL FULL OUTER JOIN (SELECT id, path AS > > path_bb FROM new_table_paths WHE

Re: [SQL] Columns into rows.

2005-01-13 Thread Dawid Kuroczko
On Thu, 13 Jan 2005 11:26:04 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: > I can write: > > SELECT * FROM (SELECT id, path AS path_a FROM new_table_paths WHERE id > = <> AND pathtype = 'a') AS a NATURAL FULL OUTER JOIN (SELECT id, > path AS path_bb F

[SQL] Columns into rows.

2005-01-13 Thread Dawid Kuroczko
I'm working with a quite flat table schema (think: mySQL ;)), and I want to divide it into two tables. Lets start with how it looks now: CREATE TABLE old_table ( id serial PRIMARY KEY, body text, path_a varchar(1024), gendate_a date, path_bb varchar(1024), gendate_bb date, path_ccc v