Asynchronous query execution with psycopg2 and Redshift - amazon-redshift

I have a Redshift cluster and use psycopg2 library with Lambda to call stored procedures in Redshift.
I have two stored procedures and use
cur = conn.cursor()
cur.execute("call stored_procedure_1()")
to run the procedure in Redshift.
I believe this is a synchronous operation?
I would like to call both the stored procedures asynchronously, without having to wait for one to complete before calling the other.
Is it possible to do this with psycopg on Redshift?
Thank you.

Related

Call a stored procedure, and return at once in Postgres?

In Postgresql, I need to call multiple stored procedures sequentially. Is this calling process sequential? That is to say, wait for the execution of each stored procedure to end before executing the next stored procedure? Or, is this an asynchronous call?
Postgres version used is 14.5.
As long as you execute SQL statement is a single database session, they are guaranteed to be executed synchronously and sequentially.

postgres alternative to bulk collect limit from oracle pl/sql

I've a procedure in Oracle PL/SQL which fetches transactional data based on certain condition, then performs some logical calculations. I used cursor to store the SQL and then I used FETCH (cursor) BULK COLLECT INTO (table type variable) LIMIT 10000, iterated over this table variable to perform calculation and ultimately storing the value in a DB table. Once 10000 rows have been processed, query will be executed to fetch next set of records,
This helped me limiting number of times SQL is executed via cursor and limiting the number of records loaded into memory.
I am trying to migrate this code to plpgsql. How can I achieve this functionality in plpgsql?
You cannot achieve this functionality in PostgreSQL.
I wrote an extension https://github.com/okbob/dbms_sql . It can be used for reduce of necessary work related to migration from Oracle to Postgres.
But you don't need this feature in Postgres. Although PL/pgSQL is similar to PL/SQL, the architecture is very different - and bulk collect operations are not necessary.

Executing MySQL procedure from Azure Data Factory

I wanted to 'Call' MySql (Azure) Procedure from Azure Data Factory. I can with SQL Server Procedure from ADF but not MySQL Procedures.
How can this be achieved, are there any other service which can be integrated with ADF to call this mysql procedures
We can call the Azure SQL for MySQL stored procedure in query operation at Source.
For example, I create a stored procedure and call it successfully in Data Factory:
Query operation: Call GetData():
There are many limits that the stored procedure must be query or have return value.
Others have posted the feedback:
We can continue to vote it up and Data Factory could see it. Hope they can think about provide the full stored procedure feature support.
You can use lookup Activity if you just need to call the Stored procedure. I tried today for the stored procedure (which update the table) and it worked.

Can postgresql stored procedures operate on a separate database?

Can postgresql (specifically 9.6) stored procedures read/modify a separate database, or can they only operate on data within the local database where they are defined?
Postgres 9.6 does not have stored procedures, which were introduced with Postgres 11.
You probably mean Postgres functions, which have been there since time immemorial. It's a widespread misconception to call those "stored procedures".
Both are confined to the database in which they are executed - as Postgres will tell you if you try to prefix a database name to an object name:
ERROR: cross-database references are not implemented:
Unless you use the Foreign Data Wrapper infrastructure (you probably want the additional module postgres_fdw with that) or dblink, which allow exactly that after all ...
How to use (install) dblink in PostgreSQL?
Persistent inserts in a UDF even if the function aborts
How do I do large non-blocking updates in PostgreSQL?

Is there an equivalent to Oracles CQN in PostgreSQL?

we have to convert an Ooracle database to PostgreSQL. Our database is using triggers and CQN (Continous Query Notification).
Triggers should be save. But we need a functionality in PostgreSQL which mimics CQN.
We use CQN to call a PL/SQL procedure after a commit of a table. In CQN you can define a query, which will be called after a commit. When this query returns a result, then the PL/SQL procedure will be called.
Is there a way to call a procedure in PostgreSQL, when the content of a defined table changed in a transaction?
Sounds like this feature from postgres would look like CQN, although it's definitely not calling SPs(and the transactional MVCC model of postgres means it'd be potentially dangerous to do so)
postgresql listen