Re: [GENERAL] Best way to insert a row with two columns having the value based on the same argument generated by another postgres function.

2016-07-07 Thread Sándor Daku
On 7 July 2016 at 08:56, Silk Parrot wrote: > Hi, > >I am trying to build a user database. The steps for creating a new user > are: > > 1. Use gen_salt to create a salt. > 2. Compute the hash based on the salt and password and store both the hash > and the salt into a new row. > > > The pl/pg

Re: [GENERAL] Retrieving value of column X days later

2016-08-07 Thread Sándor Daku
On 7 August 2016 at 21:23, Tim Smith wrote: > Hi, > > Let's say I've got a table : > > create table test ( > when date, > foo numeric, > bar numeric, > alice numeric, > bob numeric); > > insert into test values ('2016-01-01',1,2,3,4); > insert into test values ('2016-01-02',5,6,7,8); > insert int

Re: [GENERAL] Check if there 6 last records of same type without gaps

2016-09-06 Thread Sándor Daku
On 6 September 2016 at 12:32, Alexander Farber wrote: > Good afternoon, > > for a 2-player game I store moves in the following 9.5.4 table: > > CREATE TYPE words_action AS ENUM ('play', 'skip', 'swap', 'resign'); > > CREATE TABLE words_moves ( > mid SERIAL PRIMARY KEY, > action wo

Re: [GENERAL] Check if there 6 last records of same type without gaps

2016-09-06 Thread Sándor Daku
On 6 September 2016 at 14:23, Alexander Farber wrote: > Thank you, Sandor - > > On Tue, Sep 6, 2016 at 1:30 PM, Sándor Daku wrote: > >> >> Get the last 6 record and >> >> 1. ... action='SKIP' as isskip ... then you can group on and count the >

Re: [GENERAL] Check if there 6 last records of same type without gaps

2016-09-06 Thread Sándor Daku
On 6 September 2016 at 15:19, Alexander Farber wrote: > Hello Charles and other, please excuse my stupidity, but - > > On Tue, Sep 6, 2016 at 2:52 PM, Charles Clavadetscher < > clavadetsc...@swisspug.org> wrote: > >> >> You must group by played, as the message suggests. You are implicitly >> sele

Re: [GENERAL] Passing varchar parameter to INTERVAL

2016-09-07 Thread Sándor Daku
On 7 September 2016 at 15:05, Alexander Farber wrote: > Good afternoon, > > when trying to create a custom function to temporary ban a user: > > CREATE OR REPLACE FUNCTION words_ban_user( > IN in_uid integer, > IN in_until varchar,-- '1 week' OR '1 month' OR '1 year' >

Re: [GENERAL] Partition

2016-03-18 Thread Sándor Daku
On 18 March 2016 at 10:55, Leonardo M. Ramé wrote: > Hi, I have read and re-read the Partitioning chapter ( > http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html), but I > still don't see how to implement this use case: > > One table storing current data, let's call it the "master tab

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Sándor Daku
On 30 March 2016 at 11:19, Deole, Pushkar (Pushkar) wrote: > select * from t order by record_date desc limit 5; > > > > this will return the recent 5 records.. what I want is the oldest 5 > records (in last 30 days) > > > > *From:* pgsql-general-ow...@postgresql.org [mailto: > pgsql-general-ow...

Re: [GENERAL] Fetching last n records from Posgresql

2016-03-30 Thread Sándor Daku
On 30 March 2016 at 11:36, Deole, Pushkar (Pushkar) wrote: > I am sorry I didn’t clarify my requirement properly.. I want the ‘n’ > oldest records, however, they should sorted with the recent record first > and I want this to happen in the query itself so I don’t have to care about > sorting thro

Re: [GENERAL] Is it possible to delete a single value from an enum type?

2016-03-31 Thread Sándor Daku
On 31 March 2016 at 14:35, Nik Mitev wrote: > Hi, > > In summary, I am looking for the opposite functionality to 'ALTER TYPE > typename ADD VALUE IF NOT EXISTS new_value' > e.g. 'ALTER TYPE typename DELETE VALUE IF NOT USED unused_value'. The > [IF NOT USED] condition is optional, I can work arou

Re: [GENERAL] Query from two tables return error

2016-04-01 Thread Sándor Daku
On 1 April 2016 at 11:33, arnaud gaboury wrote: > I have one table email.mail.mailusers : > >Table "email.mailusers" >Column| Type | > Modifiers | Storage > | Stats target | Description > >

Re: [GENERAL] Multi-row constraints, how to avoid unnecessary trigger execution?

2016-04-06 Thread Sándor Daku
On 6 April 2016 at 18:32, Tobia Conforto wrote: > I have a complex data validation requirement that spans many rows and > possibly more than one table. > > The application must be able to perform several data manipulation > statements that could invalidate the requirement between one another, and

Re: [GENERAL] Thoughts on "Love Your Database"

2016-05-04 Thread Sándor Daku
On 4 May 2016 at 13:36, Szymon Lipiński wrote: > > > On 4 May 2016 at 13:13, Chris Travers wrote: > >> A few observations >> >> On Wed, May 4, 2016 at 12:31 PM, Geoff Winkless >> wrote: >> >>> On 4 May 2016 at 06:46, dandl wrote: >>> > I'm a strong believer in putting the business code next to