Re: [SQL] SQL formatter?

2002-09-25 Thread Philip Hallstrom
Looks to be windows based, but... http://www.techno-kitten.com/PBL_Peeper/Online_Manual/SQL_Formatter/sql_formatter.html first hit when searching on google for "sql formatter". there were a lot of other options... You might look at how some of those C code indenter's work. Seems like some of

Re: [SQL] Getting current transaction id

2002-09-25 Thread Michael Paesold
Tom Lane wrote: > Michael Paesold <[EMAIL PROTECTED]> writes: [snip] > > If it's not working I will have to implement my own transactions table. > > That's what I'd recommend. Transaction IDs are internal to the database > and are not designed for users to rely on. > > regards, tom lane Well

[SQL] SQL formatter?

2002-09-25 Thread Andrew Perrin
Does anyone know of a routine for formatting SQL statements in a structured way? Standalone or for emacs would be fine. I'm thinking of something that could take a long SQL text statement and format it, e.g.: select foo from bar where baz and bop and not boo; becomes SELECT foo FROM

Re: [SQL] Getting current transaction id

2002-09-25 Thread Tom Lane
Michael Paesold <[EMAIL PROTECTED]> writes: > I just read it's possible to get the MVCC last version numbers. Is it also > possible to get the current transaction id? Well, there's the brute force way: insert a tuple in some table and look at its xmin. Offhand I don't think we provide a SQL func

Re: [SQL] Timestamp Error - 7.2

2002-09-25 Thread Josh Berkus
Keith, > We have moved from 7.1 to 7.2 and get the following error when > extracting dates. > > Bad timestamp external representation ' ' > > > eg. INSERT INTO mytable VALUES('1', '2001-09-24') The error, as you have described it, is highly unlikely. You will need to provide more informatio

Re: [SQL] Is there a better way than this to get the start and end of a month?

2002-09-25 Thread Dmitry Tkach
Sorry, the previous message was wrong... This is better: create function month_start (date) as 'select date_trunc ('month', $1)::date;' language 'sql'; create function month_end (date) as 'select month_start ($1) - 1 + interval '1 month'; language 'sql'; I hope, it helps... Dima David S

Re: [SQL] Is there a better way than this to get the start and end of a month?

2002-09-25 Thread Dmitry Tkach
Well, month_end could be more straightforward as something like select month_start ($1) + interval '1 day' - interval '1 month'; Dima David Stanaway wrote: > Here are the 2 functions I have at the moment. I was wondering if > someone had a better way? > > CREATE OR REPLACE FUNCTION month_start

Re: [SQL] database abstraction -> functions

2002-09-25 Thread Dmitry Tkach
Jeroen Olthof wrote: > Hi, > > When developing applications is a good thing to create abstraction between > different layers > The one concerning the database would be the persistence layer. To create > such abstraction I want all mij datababase activitie runned through > functions. But how can