I have a SELECT INTO
query like the following in a procedure :
declare
employee_data record;
item record
begin
select * into employee_data from employees where emp_id=10;
Now I am using a column from the employee_data
variable in another query:
FOR item in
SELECT CONCAT(E.first_name,' ',E.last_name) AS employee_name,
E.email AS employee_email
INTO notify_users_data
FROM employee_info E
WHERE E.emp_id = ANY(ARRAY employee_data.notify_users)
LOOP
Here, the notify_users
column in employee
table is of type jsonb
and it is an array like ["2001", "3457"]
When I try to save this query, it is showing a syntax error
error:syntax error at or near employee_data: WHERE E.emp_id = ANY(ARRAY employee_data
How can I use the result in WHERE ANY ?