2

I am trying to write a script to run in DBeaver (Version 24.0.0) it determines what schema update scripts to run based on a table in the database that records the schema updates already run. It then tries to use the dbeaver @include to run the needed update scripts.

It looks something like: **

**@set db_dir = '<path of update scripts>'
<code that inserts into a temp table, upgrade_files, the filenames of the schema update files not already recorded in the database>
do $$
DECLARE
 file upgrade_file%ROWTYPE;
 file_location text;
BEGIN
 FOR file in (select * from upgrade_files) loop
 file_location = ${db_dir} ||file.filename;
 raise info 'file: %', file_location;
 @include ${file_location}
 end loop;
end $$**;

**

If I run this I get "Syntax error at or near @".If I comment out the @include statement in the for loop it runs fine and prints out the correct filenames, including path, to be run. Any help figuring out what I am doing wrong or another approach would be appreciated.

asked Jun 26 at 17:09

1 Answer 1

2

You are mixing up DBeaver syntax with that of what appears to be Postgres' PL/pgSQL. The entire DO $$ ... $$ block gets sent to the Postgres server for execution, and Postgres has no idea what @include means, because it's apparently a DBeaver thing.

Use one programming concept at a time.

answered Jun 26 at 17:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.