Return to site

Postgresql for loop insert

broken image

Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread. If you have extra questions about this answer, please click ' Comment'. If the answer is the right solution, please click ' Accept Answer' and kindly upvote it. SELECT MyTable INNER JOIN tL on MyTable.ID=tL.ID Do what you want here with the data stored in tblLoop for the given RowNum Use a table variable to hold numbered rows containg MyTable's ID valuesĭECLARE TABLE (RowNum int IDENTITY (1, 1) Primary key NOT NULL,ĭECLARE NVarChar(10) DECLARE NVarChar(100) I would do something like this in Python (just an example what I want to achieve, I want/need PostgreSQL solution. And I would like to loop through the list of the views (structure is the same) and do the inserts. Destination table is always the same, but source views are different.

broken image

When you do not like use Cursor,Maybe while is your best choice,please try this: DECLARE int SET = 0 - Loop Counter I want to do for loop, which would insert into from select.

broken image