Re: [SQL] quotes etc

2011-02-22 Thread Kenneth Marshall
On Tue, Feb 22, 2011 at 12:26:41PM -0800, John Fabiani wrote: Hi, I would have thought that there would be a simple built-in function that would escape the quotes as ('D' Andes') to ('D\' Andes'). But I did not see anything? I am I wrong? Johnf The manual goes over many

Re: [SQL] Get days between two dates?

2011-01-31 Thread Kenneth Marshall
On Mon, Jan 31, 2011 at 10:50:43AM -0500, Emi Lu wrote: Good morning, Is there an existing method to get days between two dates? For example, select '2010-01-01'::date - '1999-10-12'::date Returns how many days. Thank you, -- Lu Ying Didn't you just answer your own question?

Re: [SQL] question about reg. expression

2011-01-19 Thread Kenneth Marshall
On Wed, Jan 19, 2011 at 08:17:50AM -0500, Stephen Belcher wrote: Another way to match multiple occurrences is to use curly brackets with a number, like: select 'ab' ~ '^[a-z]{2}$'; It can be done with a range of numbers as well: select 'ab' ~ '^[a-z]{2,4}$'; select 'abab' ~ '^[a-z]{2,4}$';

Re: [SQL] indexing longish string

2010-11-30 Thread Kenneth Marshall
You can use a hash index for this. It's drawback is that it is not yet WAL enabled and if your DB crashes you will need to rebuild the index to fix the corruption. It works well(only) with equality searches. If it is a scenario where you must have WAL, use a function index based on the hash of the

Re: [SQL] Trailing spaces - is there an easier way?

2010-11-04 Thread Kenneth Marshall
On Thu, Nov 04, 2010 at 08:42:21PM +0100, Pavel Stehule wrote: 2010/11/4 Dean Gibson (DB Administrator) postgre...@ultimeth.com: I'm sure this has been asked before, but I couldn't find it: I have a zzz CHAR (8) field.?? It needs to be CHAR because trailing spaces need to be ignored for

Re: [SQL] Question about PQexecParams

2010-09-30 Thread Kenneth Marshall
Hi Steve, I am going to follow-up to this post so that the results will be available to other PostgreSQL users. Here is a simple example program for binary transmission of an int8 array using native libpq functions and not the libpqtypes: ---native_binarray_dspam.c-- /*

Re: [SQL] Question about PQexecParams

2010-09-30 Thread Kenneth Marshall
On Thu, Sep 30, 2010 at 10:30:16PM +0400, Dmitriy Igrishin wrote: Hey Kenneth, Thank you for solution. But sorry, personally, I don't clearly understand the benefits of this code compared with using simple array literals or even array constructors... Conversion overheads from text?

Re: [SQL] Question Regarding Unique Index on Table

2010-09-23 Thread Kenneth Marshall
9.0 allows you to defer unique constraints. Ken On Thu, Sep 23, 2010 at 10:18:39AM -0700, Ozer, Pam wrote: Is it possible to disable a unique index? I have a process that's running that inserts duplicate records into a table and then does a cleanup afterwards. I know that I can drop the

Re: [SQL] What does PostgreSQL do when time goes backward?

2010-08-04 Thread Kenneth Marshall
On Wed, Aug 04, 2010 at 07:20:31AM -0400, Frank Bax wrote: John Hasler wrote: How does PostgreSQL react to time being stepped at bootup? My Chrony NTP package might cause it to do so on rare occasions when the hardware clock is way off. This would only happen during bootup. My ntp client

Re: [SQL] Some quick questions

2010-08-04 Thread Kenneth Marshall
On Wed, Aug 04, 2010 at 10:22:12AM -0400, Joshua Gooding wrote: I am using Postgres 8.4 with 10 partition tables. We'll call them reports_00 through reports_09. I have a field that is a BIGINT which is a 13 digit number that is the epoch time, which is the constraint that the table is

Re: [SQL] UUID for Postgresql 8.4

2010-07-21 Thread Kenneth Marshall
On Wed, Jul 21, 2010 at 05:49:53PM +0530, Trinath Somanchi wrote: Hi All, I have a column in my Postgresql database tables which need UUID. Is there any function in Pgsql for UUID generation. Please help me in this regard. -- Regards, --

Re: [SQL] running scripts like oracle sqlplus

2010-06-21 Thread Kenneth Marshall
On Fri, Jun 18, 2010 at 04:24:18PM -0600, Steven Dahlin wrote: I have been trying to figure out how I can run a pgsql script like I can run a plsql script with oracle's sqlplus. Here is a sample script file for what I want to run: declare sysuserid integer := 0; hwcustid integer :=

Re: [SQL] is there a tutorial on window functions?

2010-06-11 Thread Kenneth Marshall
On Fri, Jun 11, 2010 at 04:39:37PM +0200, Thomas Kellerer wrote: John, 11.06.2010 16:17: Hi, I'd like to learn the use of window functions and did not find a tutorial using google (postgres window function tutorial). I'm hoping someone has a link. There is one in the manual:

Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-19 Thread Kenneth Marshall
On Wed, May 19, 2010 at 12:26:07PM +0400, silly sad wrote: On 05/18/10 23:27, Kenneth Marshall wrote: It works using 'now' and I assume that since curtime is now() is NOT the CURRENT timestamp in fact, it is about the timestamp of the current transaction has been started. it is the really

[SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-18 Thread Kenneth Marshall
I am trying to write a function that updates the date column to the current date. According to: http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT you can use CURRENT_DATE. When I try to use it in the following pl/pgSQL function it gives the error:

Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-18 Thread Kenneth Marshall
To follow-up, It works using 'now' and I assume that since curtime is of type DATE that the assignment casts the return automatically to type DATE. Thank you for the ideas. Regards, Ken On Tue, May 18, 2010 at 12:12:46PM -0700, Richard Broersma wrote: On Tue, May 18, 2010 at 12:08 PM, Kenneth

Re: [SQL] How to get CURRENT_DATE in a pl/pgSQL function

2010-05-18 Thread Kenneth Marshall
Okay, this works as well. Thank you for all of the assistance. Regards, Ken On Tue, May 18, 2010 at 09:25:00PM +0200, Pavel Stehule wrote: 2010/5/18 Richard Broersma richard.broer...@gmail.com: On Tue, May 18, 2010 at 12:08 PM, Kenneth Marshall k...@rice.edu wrote: http

Re: [SQL] Tsearch not searching 'Y'

2010-05-03 Thread Kenneth Marshall
On Thu, Apr 29, 2010 at 01:13:40PM -, sandeep prakash dhumale wrote: Hello All, I am trying to get tsearch working for my application but I am facing a problem when alphabet 'Y' is the in the tsquery. can anyone please share some light on it. # SELECT 'hollywood'::tsvector @@

Re: [SQL] Hibernate, web application and only one sequence for all primary keys

2009-09-19 Thread Kenneth Marshall
On Thu, Sep 17, 2009 at 07:47:13AM -0700, rawi wrote: Leo Mannhart wrote: Caveat: If you use the standard sequence generator in hibernate, it is not using the postgres-sequence in the usual manner. hibernate itself caches 50 ID's as sequence numbers by default. This means, hibernate

Re: [SQL] extracting from epoch values in pgsql

2009-09-19 Thread Kenneth Marshall
On Thu, Sep 17, 2009 at 06:34:39PM +0100, Gavin McCullagh wrote: On Thu, 17 Sep 2009, Gavin McCullagh wrote: On Thu, 17 Sep 2009, Frank Bax wrote: Gavin McCullagh wrote: SELECT time, to_timestamp(time) AS ts, EXTRACT('months',to_timestamp(time)) FROM mdl_log; ERROR: syntax