Tag Info

New answers tagged

3

First off, you do not want to use char(50). Use varchar(50) or just text. Read more: Any downsides of using data type “text” for storing strings? Assuming the following rules: Basic slugs never end with a dash. Duplicate slugs are suffixed with a dash and a sequential number (-123). Note that all of the following methods are subject to a race ...


6

This appears to be the cause of the problems, from the same page quoted by ypercube: Trying to update the same row twice in a single statement is not supported. Only one of the modifications takes place, but it is not easy (and sometimes not possible) to reliably predict which one. This also applies to deleting a row that was already updated in the same ...


6

This should work but I'm not really sure if it's the best regarding efficiency: WITH copy_to_other_table AS ( INSERT INTO other_table (column_a, column_b) SELECT column_a, column_b FROM main_table WHERE column_a = 1 ), main_table_deleted AS ( DELETE FROM main_table WHERE column_a = 1 AND NOT EXISTS ...


1

I'm wondering if these views could be re-written using CTEs, to somehow 'pre-fetch' the modified/pre-fixed schemas using the functions, and then query the tables with SELECT INTO to populate data into the view. No, this isn't possible with a view. You could do something broadly along these lines with a multi-statement function (MSUDF), but: This would ...



Top 50 recent answers are included