Skip to content
Advertisement

Tag: loops

Avoid ‘out of shared memory error’ in PostgreSQL function

I have two tables, a table called companies_display with information about publicly traded companies such as ticker symbol, market cap etc. and a partitioned table stock_prices with the historical stock prices for each company. I want to calculate the beta of each stock and write that into companies_display. For that I wrote the function calculate_beta(ticker) that calculates it: The function

LOOP/FOR statement on oracle script

I’m running an ansible playbook that runs an sqlplus script to an Oracle DB. Basically the script creates a CSV file with some server info. The query is pretty much autogenerated, so it will be difficult change it. The problem is that this query brings all the 5000 server and I need only 200. I want to add a LOOP/FOR

Is there a way to loop through selected columns in plsql

I have a table TestTable with columns of col_test1, col_test2, col_test3 … and I want to create a loop that accesses each of these columns individually and find the max value and place it in the variable made in the declare block and simply dbms.out.put it. The output I get is just the string ‘col_test1’which should be 50. This is

Python – Running a SQL in a loop based on column value

I am trying to build a SQL query that runs based on certain conditions (if a column is filled run Query 1 else Query 2 and so on) as shown below: I am trying to build something like the above but the number of fields as variable (fields like col_a and col_b) are 6 in number. Is there a way

SQL Query, loop through data

I have a database with the following fields: UserID, DateRecorded and Score. A new entry is added to the table each time the score is updated. Here is an example of a user record: From the query I would like it to show me only the scores of all users with the earliest DateRecorded. Although not much familiar with cursors,

Advertisement