Thursday, April 28, 2016

PostgreSQL: check element contained in array

Contained:
select 1 = any (array[2, 4, 6]);
NOT contained:
select 1 != all (array[2, 4, 6]);

Wednesday, April 27, 2016

perl: append line on top of file

perl -pi -e 'print "use \\MBQT\\framework\\Session;\n" if $. == 1' <file>

Friday, April 15, 2016

PostgreSQL: get / set sequence value

Get latest sequence value:
select last_value from identity_id_seq;
Set sequence:
select setval('identity_id_seq', 2000041);

Sunday, April 3, 2016

PostgreSQL: Convert table into array

See http://stackoverflow.com/questions/32647297/convert-table-into-array-of-custom-types
Any PostgreSQL table has a virtual column named as table of record type with fields related to table's columns.
E.g.
_param_array := array(select foo from prov_db.get_rz_addon_param_list(i_co_id) as foo);

Friday, April 1, 2016