We all use the pattern of temporary creating a function for upgrade script,
declaring it (copy pasting from last script) and then calling it, then
deleting it.

This very verbose can be replaced with DO instruction which does
essentially the same.

# existing declaration

```sql

CREATE OR REPLACE FUNCTION __tmp_count() RETURNS VOID AS
  $procedure$
  DECLARE
    i int;
  BEGIN
   i:= (select count(*) from vms)  -- useless count just for the demo
END;
  $procedure$
  LANGUAGE plpgsql;

SELECT __tmp_count();
DROP FUNCTION __tmp_acount();

```

Can be replaced with

```sql

DO $$
  DECLARE
  i int;
  BEGIN
    i := (select count(*) from vms) -- useless count for demo
  END
$$;

```

Not tested but tons of less lines to code. Exist in version 9.0.23 and above
_______________________________________________
Devel mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/devel

Reply via email to