I'm developing a Building Block for Blackboard, and have run into a database related issue.
I'm trying to insert four rows into a pgsql table, but only if the table is empty. The query runs as a post-schema update, and is therefore run whenever I re-install the building block. It is vital that I do not simply drop exsisting values and/or replace them (which would be a simple and effective solution otherwise).
Below is my existing query, that does the job, but only for one row. As I mentioned, I'm trying to insert four rows. I can't simply run the insert multiple times, as after the first run, the table would no longer be empty.
Any help will be appriciated.
BEGIN;
INSERT INTO my_table_name
SELECT
nextval('my_table_name_SEQ'),
'Some website URL',
'Some image URL',
'Some website name',
'Y',
'Y'
WHERE
NOT EXISTS (
SELECT * FROM my_table_name
);
COMMIT;
END;