Re: Trigger with conditional predicates

2021-01-04 Thread Alban Hertroys
> On 4 Jan 2021, at 20:02, Dirk Mika wrote: > >>> On 1 Jan 2021, at 16:56, Dirk Mika wrote: >>> >>> Hi all and a happy new Year! >>> >>> We have an Oracle schema that is to be converted to PostgreSQL, where >>> conditional predicates are used in some triggers. >>> >>> In particular, column

Re: Trigger with conditional predicates

2021-01-04 Thread Christophe Pettus
> On Jan 4, 2021, at 11:06, Dirk Mika wrote: > > See thread below: > > https://www.postgresql.org/message-id/VisenaEmail.26.7cbf2947c8d23ceb.1769a2755ff%40tc7-visena > > I found that thread already, but It doesn't not provide a solution to my > problem. One possibility, which is admittedly

Re: Trigger with conditional predicates

2021-01-04 Thread Dirk Mika
>>> In particular, columns are populated with values if they are not specified >>> in the update statement which is used. >>> Usually with an expression like this: >>> >>> IF NOT UPDATING('IS_CANCELED') >>> THEN >>> :new.is_canceled := ...; >>> END IF; >>> >>> I have not

Re: Trigger with conditional predicates

2021-01-04 Thread Dirk Mika
-- Dirk Mika Software Developer mika:timing GmbH Strundepark - Kürtener Str. 11b 51465 Bergisch Gladbach Germany fon +49 2202 2401-1197 dirk.m...@mikatiming.de www.mikatiming.de AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884 Geschäftsführer: Harald Mika, Jörg Mika > > On 1 Jan 2021, at 16:56,

Re: How to generate random string for all rows in postgres

2021-01-04 Thread Rad Akefirad
Got it. Many thanks. On Mon, Jan 4, 2021 at 2:46 PM hubert depesz lubaczewski wrote: > On Mon, Jan 04, 2021 at 02:14:11PM +0100, Hassan Akefirad wrote: > > I have foo table and would like to set bar column to a random string. > I've got the following query: > > update foo > > set bar = array_to_

Re: How to generate random string for all rows in postgres

2021-01-04 Thread hubert depesz lubaczewski
On Mon, Jan 04, 2021 at 02:14:11PM +0100, Hassan Akefirad wrote: > I have foo table and would like to set bar column to a random string. I've > got the following query: > update foo > set bar = array_to_string( > array(select string_agg(substring('0123456789bcdfghjkmnpqrstvwxyz', > round(random()

How to generate random string for all rows in postgres

2021-01-04 Thread Hassan Akefirad
I have foo table and would like to set bar column to a random string. I've got the following query: update foo set bar = array_to_string( array(select string_agg(substring('0123456789bcdfghjkmnpqrstvwxyz', round(random() * 30)::integer, 1), '') from generate_series(1, 9)), ''); But it generates t

Re: Possible trigger bug? function call argument literalised

2021-01-04 Thread Thiemo Kellner
Quoting Adrian Klaver : On 1/3/21 1:44 PM, Thiemo Kellner wrote: So is the below still only going to fire on INSERT? If so it will not deal with functions that disappear after the INSERT, which in the end makes it similar to my suggestion:) The point being you are taking a snapshot in