Using Flyway not able to set variable for postgress - postgresql

Good Day!
PostgreSQL using flyway not able to create variable but using PostgreSQL client or command line its working well.
Below code is working well in client application [like DBeaver]
#set TEST = 'testing by us';
but when I add sql in flyway file its give error
#set TEST = 'testing by us';
SQL State : 42601 Error Code : 0 Message : ERROR: syntax error at or near "#" Position: 1
Location : db/migration/pgsql/_env/V1__zopn_obsolete.sql
(C:\workspace\zara-flyway\target\classes\db\migration\pgsql_env\V1__zopn_obsolete.sql)
Line : 1 Statement : #set TEST = 'testing by us'
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at
or near "#"

Related

Trying to run Oracle Stored Procedure Results in: ORA-00900: invalid SQL statement

How can I run the following code in DBEAVER? It will not execute the stored procedure and I have been told the code is OK to execute in SQL+ and Toad.
set serveroutput on;
set autoprint on;
var x0 refcursor;
var x1 refcursor;
exec pkg_organisation.p_list_org_by_uuid(123456, :x0, :x1);
I asked a DB dev to run this in toad, I dont have a licence and the procedure works as expected, but I would like to run this in DBEAVER.
With the set statements left in I get the following error:
SQL Error [922] [42000]: ORA-00922: missing or invalid option
Error : 922, Position : 4, Sql = set serveroutput on, OriginalSql = set serveroutput on, Error Msg = ORA-00922: missing or invalid option
ORA-00922: missing or invalid option
And if I remove these (as it appears this is what DBEAVER complains about), I get the following error:
SQL Error [900] [42000]: ORA-00900: invalid SQL statement
Error : 900, Position : 0, Sql = var x0 refcursor, OriginalSql = var x0 refcursor, Error Msg = ORA-00900: invalid SQL statement
ORA-00900: invalid SQL statement
I am using the Execute Script option to try to run the stored procedure and I would like to be able to get up and running with testing the procedures.

Running dumps in query runner

I had a project which was unfortunately being developed only using the synchronize: true option until now.
I decided to change it and what i did was create a dump and then ran it in the query runner. and found myself stuck in an error.
I did something like : [Database = postgres , ORM = typeorm]
pg_dump db > db.sql
this created a sql file i copied it's content and pasted in query runner which gives me an error like:
driverError: error: syntax error at or near "."

Attempting to run a query and set the count to a low number

PostgreSQL syntax problem.
Query below will run but result is:
ERROR: out of memory for query result
SELECT
AD.ADDRESS_DETAIL_PID as ADDRESS_DETAIL_PID,
AD.STREET_LOCALITY_PID as STREET_LOCALITY_PID,
AD.LOCALITY_PID as LOCALITY_PID,
AD.BUILDING_NAME as BUILDING_NAME
When the query is amended to:
set FETCH_COUNT=1000
SELECT
AD.ADDRESS_DETAIL_PID as ADDRESS_DETAIL_PID,
AD.STREET_LOCALITY_PID as STREET_LOCALITY_PID,
AD.LOCALITY_PID as LOCALITY_PID,
AD.BUILDING_NAME as BUILDING_NAME
the result is:
ERROR: syntax error at or near "SELECT" LINE 3: SELECT
^ SQL state: 42601 Character: 23
except that when a colon ; is included at the end the rssult is:
ERROR: unrecognized configuration parameter "fetch_count" SQL state:
42704
I am seeking help with the syntax.
FETCH_COUNT is a psql interval variable and is not executed on the server.
SET is a SQL command that's executed on the server and cannot be used for setting psql internal variables. use \set instead.
\set FETCH_COUNT 1000

Error writing to database in Moodle in Find and Replace tool

I have moved my moodle database files from old server URLold= (https://example1.com) to new server URLnew=(https://example2.com). Now I want to replace URLold with URLnew in database tables using find and replace tool provided by moodle. But when i perform the operation I am getting this error. What should i do? Please help.
Error I am getting
Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table = REPLACE(table, 'https://example1.com', 'https://example2.com')' at line 1
UPDATE mdl_pma_history SET table = REPLACE(table, ?, ?)
[array (
0 => 'https://example1.com',
1 => 'https://example2.com',
)]
Error code: dmlwriteexception
Stack trace:
line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 895 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 6787 of /lib/adminlib.php: call to mysqli_native_moodle_database->execute()
line 74 of /admin/tool/replace/index.php: call to db_replace()
So I got the answer on my own
Had to delete the mdl_pma_history table that was causing the error. The Steps i followed are as follows.
Exported the table to .sql file
Deleted the table because it was not allowing the script to run
Once the script (Find and replace) ran successfully imported the
table back
Done.

Is DB2 CLPPLUS editor able to do xquery

I am new to the CLPPlus editor and I'm trying a simple query that works if I execute it from a file like this
db2 -td% -svf C:\query.sql
and the query.sql file contains:
SELECT tx.ID,XMLQUERY('for $e in $d/Client/Address return data($e)' passing tx.contactinfo as "d") FROM clients tx %
If I just place the query as it is in the CLP or CLPPLUS editor as it is I get errors.
Error FROM CLP: SQL0104N An unexpected token "for $e in $d/Client/Ad"
was found following "LECT tx.ID,XMLQUERY(". Expected tokens may
include: "
Error from CLPPLUS: SQL16002N An XQuery expression has an unexpected
token "in" following "for ". Expected tokens may include: "is". Error
QName=err:XPST0003.