Skip to content
Advertisement

How can i store results of a query in an array?

I have to store last 5 employees_id’s from employees table into an array. I made the query correct and i have the array, but i can’t understand the syntax to store the results in that array. Here’s my code

and here’s my query

How can i store the results from the query in the array? As i need to update those values in another query. I know this can be done in a simpler way with subqueries but i’m doing it this way to better understand the concept of arrays in sql

Advertisement

Answer

Assuming you are using Oracle then you can use a PL/SQL block:

db<>fiddle here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement