Re: [SQL] copy command and array of composite types?

2008-03-25 Thread Guy Fraser
Try to export some data from the table using copy from ... to see what it looks like. On 2008-Mar-25, at 12:19, Jon Norman wrote: I'm using PostgreSQL 8.3.1. I've created the following composite type: CREATE TYPE expression_event_type AS ( event_id varchar(10), expr_indices smallint[] );

[SQL] Was: fetch first rows of grouped data

2007-08-28 Thread Guy Fraser
Hi there I have a list of events that take place in a certain city at a certain date. Now I would like to have the first two (ordered by date) events for each city. Is there a way to do this with one query? I am using PostgreSQL 7.4.

Re: [SQL] Regular Expressions

2007-03-21 Thread Guy Fraser
of broadcast)--- TIP 2: Don't 'kill -9' the postmaster -- Guy Fraser Network Administrator The Internet Centre 1-888-450-6787 (780)450-6787 ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ

Re: [SQL] Regular Expressions

2007-03-21 Thread Guy Fraser
On Wed, 2007-03-21 at 14:37 -0300, Ezequias R. da Rocha wrote: Guy Fraser escreveu: On Wed, 2007-03-21 at 11:04 -0300, Ezequias R. da Rocha wrote: Hi list, I would like to know if postgresql has a Regular Expressions (Regex) implemented already. With it we could implement

Re: [SQL] LinkedList

2006-05-01 Thread Guy Fraser
On Sat, 2006-29-04 at 01:50 -0500, Ben K. wrote: On Fri, 28 Apr 2006, Guy Fraser wrote: -- HEAD insert into linkedlist values(null,1,0); insert into linkedlist values(1,2,10); insert into linkedlist values(2,3,20); insert into linkedlist values(3,4,30); insert into linkedlist values

Re: [SQL] pgcrypto-crypt

2006-04-06 Thread Guy Fraser
On Thu, 2006-06-04 at 13:53 +0530, AKHILESH GUPTA wrote: dear all, i want to encrypt and decrypt one of the fields in my table (i.e- password field) i have searched and with the help of pgcrypto package, using function crypt, i am able to encrypt my data, but there is nothing which i found

Re: [SQL] Simple Question

2005-01-11 Thread Guy Fraser
'kill -9' the postmaster -- Guy Fraser Network Administrator The Internet Centre 1-888-450-6787 (780)450-6787 ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] save sql result to file

2004-12-24 Thread Guy Fraser
Off the top of my head: psql -c select into dump_table from old_table ; database pg_dump -t dump_table -f dump_table.tmp database sed -e s/dump_table/table_name/g dump_table.tmp table_name.sql rm dump_table.tmp You should now have a file called table_name.sql with the stuff required

Re: [SQL] Comparing Dates

2004-11-19 Thread Guy Fraser
-- guy Thomas F.O'Connell [EMAIL PROTECTED] writes: select 2004-06-08; ?column? -- 1990 I'm not exactly sure how the bare string is converted internally, but it's clearly not a complete date like you're expecting. -- Guy Fraser Network Administrator The Internet Centre

Re: [SQL] [GENERAL] PHP or JSP? That is the question.

2004-03-23 Thread Guy Fraser
regarding errors like 'Object not found' or build extensive automated regression tests but then you are going to spent time for building those test cases which still may fail to detect errors which are otherwise just easily detected by the compiler. -Original Message- From: Guy Fraser [mailto

Re: [SQL] comparing nulls

2004-01-20 Thread Guy Fraser
Kenneth Gonsalves wrote: On Tuesday 20 January 2004 19:26, Chris Bowlby wrote: Hi Ken, Under 7.3.x this option was removed, you need to test via: SELECT * from table where field IS NULL; thanx - works in both 7.1 and 7.3 - why do these guys keep fooling around with these thangs?

Re: [SQL] testing for null value in integer field?

2003-12-19 Thread Guy Fraser
select . where intnumber IS NULL Geoffrey wrote: How does one check for an unset value in an integer field? I've tried such things as: select . where intnumber = '' select .. where intnumber = ? select . where intnumber = NULL Thanks. ---(end of

Re: [SQL] picking max from list

2003-12-10 Thread Guy Fraser
8652 28652 08895 18894 Ultimately I want to know the group number for EACH rd_pk with the highest run number. Can this be done in one query? Or will I need to code with a loop? Thanks Jodi -- Guy Fraser Network Administrator

Re: [SQL] selecting duplicate records

2003-09-23 Thread Guy Fraser
; if there are multiple dupes, they may get picked multiple times in the second query :-(.] -- Guy Fraser Network Administrator The Internet Centre 780-450-6787 , 1-888-450-6787 There is a fine line between genius and lunacy, fear not, walk the line with pride. Not all things will end up as you wanted, but you

Re: [SQL] [GENERAL] Request for advice: Table design

2003-06-19 Thread Guy Fraser
definitely filing this for use in a future,near term project. Guy Fraser wrote: Hi As an additional note; Older data is moved into a seperate table to reduce the number of records that require regular vacuuming. Since the tables would contain similar data it is simple to use union selections in a view

Re: [SQL] Creating Views with Column Names based on Distinct

2003-06-11 Thread Guy Fraser
Hi CREATE VIEW user_stuff ...select comand that displays what you want... ; This might be what you want ?:-) CREATE VIEW user_stuff SELECT username AS Username,userpassword AS Pass/Attribute,startdate::TEXT AS Date/Value FROM user UNION SELECT

Re: [SQL] Calculating with the time

2003-05-31 Thread Guy Fraser
Is this what you are looking for? test=# select 'now'::time as test,'2003-05-30 14:51:38-06'::timestamptz as stamp into temp cruft; SELECT test=# select test,stamp,test - stamp::time as diff from cruft; test | stamp | diff -++-

Convert a text list to text array? Was: [SQL] Denormalizing duringselect

2003-03-04 Thread Guy Fraser
The email at the bottom gave me an idea, but it doesn't quite work: CREATE AGGREGATE accumulate( BASETYPE = text, SFUNC = textcat, STYPE = text, INITCOND = '' ); -- SELECT ('{' || ltrim(accumulate(',' || tablename),',') || '}') as cruft FROM pg_tables WHERE hasindexes = 'f';

Re: [SQL] Passing arrays

2003-02-19 Thread Guy Fraser
Would it not be more reasonable to have array_dims return an int or int[]? Has anyone ever seen an array that does not start at 1? The other problem I find with array_dims returning text is when you have a multi-dimentional array like this IIRC; array_dims('{{asd,fgh,jkl},{zxc,vbn,mlk}}') =

Re: [SQL] CSV import

2003-01-31 Thread Guy Fraser
FYI In text files on a Mac. the EOL character is a CR only. What a messy thing this whole EOL cruft is. To convert between these text formats on linux is easy if you have dos2unix. The dos2unix on linux can perform many format conversions to and from unix,dos and mac formats. On BSD you need

Re: [SQL] CSV import

2003-01-28 Thread Guy Fraser
Hi You will need two text utilities {dos2unix and sed} to do this in the simplest way. They are fairly standard text utilities and are probably already on your machine. This is how I would do it : sed s/\//g file_name.txt \ | dos2unix \ | pgsql -c COPY table_name FROM STDIN USING DELIMITERS

Re: [SQL] converting microsoft sql server 2000 sql-code for postgresql

2003-01-28 Thread Guy Fraser
Hi You should use date instead of datetime since the data is only a date and a date type uses less storage than a timestamp. For time only data use type time or timetz if you want the timezone as well. For data with a date and time use timestamp or timestamptz if you want to include the

Re: [SQL] SQL to list databases?

2003-01-24 Thread Guy Fraser
Hi To make it easier to do this in SQL you can create a view like this : CREATE VIEW db_list AS SELECT d.datname as Name, u.usename as Owner, pg_catalog.pg_encoding_to_char(d.encoding) as Encoding FROM pg_catalog.pg_database d LEFT JOIN pg_catalog.pg_user u ON d.datdba =

Re: [SQL] Scheduling Events?

2003-01-24 Thread Guy Fraser
Hi I would agree that cron is probably the best solution. You could have cron perform a query that has a trigger and performs all the tasks you need done. As well you could create a trigger on other queries that would perform the other things as well, but make sure it isn't a heavily used

Re: [SQL] Getting multiple rows in plpgsql function

2003-01-24 Thread Guy Fraser
NOTE: This is a feature in 7.3 it was either added or fixed, so you will not be able to do this unless you are using version 7.3. Remember to backup with pg_dumpall before you upgrade. This is a sample sent to me earlier this week, that iterates an integer array: Cut Here

[SQL] Could someone help me fix my array_list function?

2003-01-20 Thread Guy Fraser
Hi I am trying to write a function to step through an array and output each value as a set {list}, I think. This is what I want to do: select attribute,array_list(values,1,sizeof(values)) as value from av_list; Turn : attr6 | {val3,val7,val4,val5} Into : attr6 | val3 attr6 | val7 attr6 |