Friday 13 January 2023

PostgreSQL Refcursor || Cursors In PostgreSQL || Part 4 Refcursor Cursor...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.


select refcursor_cursor(1,'lv_refcursor');
fetch all in lv_refcursor;

create or replace function refcursor_cursor(in_actor_id in integer, lv_ref_cur refcursor)
returns refcursor
language plpgsql
as $$
begin
open lv_ref_cur
for select 'Title: '||f.title as Title
from film_actor fa, film f
where fa.film_id = f.film_id
and fa.actor_id = in_actor_id;
return lv_ref_cur;
exception when others then
raise notice 'Something Went Wrong';
end;
$$

Thursday 12 January 2023

PostgreSQL Cursors || Cursors Available In PostgreSQL || Part 3 For Loop...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




call for_loop_cursor(1);

create or replace procedure for_loop_cursor(in_actor_id in integer)
language plpgsql
as $$
declare
lv_string character varying(200);
loop_rec record;
begin
for loop_rec in 
select f.title from film_actor fa,film f 
where fa.film_id = f.film_id 
and actor_id = in_actor_id
LOOP
lv_string := 'Title: '||loop_rec.title;
raise notice '%',lv_string;
end loop;
exception when others then
raise notice 'Something Went Wrong';
end;
$$

Saturday 7 January 2023

PostgreSQL Cursors || Cursors Available In PostgreSQL || Part 2 Paramete...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




call parameterized_cursor(1);

create or replace procedure parameterized_cursor(in_actor_id in integer)
language plpgsql
as $$
declare
lv_string character varying(200);
loop_rec record;
rec1 record;
cur1 cursor(p_film_id integer) for 
select title from film where film_id = p_film_id order by film_id;
begin
for loop_rec in select film_id from film_actor where actor_id = in_actor_id
LOOP
open cur1(loop_rec.film_id);
loop 
fetch cur1 into rec1;
exit when not found;
lv_string := 'Title: '||rec1.title;
raise notice '%',lv_string;
end loop;
close cur1;
end loop;
exception when others then
raise notice 'Something Went Wrong';
end;
$$

Keywords

postgresql cursors parameterized cursor cursors available in postgresql,
parameterized cursor,
parameterised cursor,
cursors available in postgresql,
postgresql cursors,
postgresql,
cursors,
cursor,
postgres,
pg admin,
pg admin 4,
postgres pg admin,
how to create cursor in posgresql,
create cursor in posgresql,
create parameterized cursor,
create parameterised cursor,
fetch cursor,
loop cursor,
exit cursor,
declare cursor,
define cursor,
cursor in procedure,
cursor in function,
knowledge 360,
akram sohail

Wednesday 4 January 2023

PostgreSQL Cursors || Cursors Available In PostgreSQL || Part 1 Simple C...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




call simple_cursor();

create or replace procedure simple_cursor()
language plpgsql
as $$
declare
lv_string character varying(200);
rec1 record;
cur1 cursor for 
select actor_id, first_name, last_name as end_name from actor order by actor_id;
begin
open cur1;
loop 
fetch cur1 into rec1;
exit when not found;
lv_string := 'Actor ID: '||rec1.actor_id||', Actor First Name: '||rec1.first_name||', Actor Last Name: '||rec1.end_name;
raise notice '%',lv_string;
end loop;
close cur1;
exception when others then
raise notice 'Something Went Wrong';
end;
$$



Keywords:

postgresql cursors simple cursor cursors available in postgresql,simple cursor,cursors available in postgresql,postgresql cursors,postgresql,cursors,cursor,postgres,pg admin,pg admin 4,postgres pg admin,how to create cursor in posgresql,create cursor in posgresql,create simple cursor,fetch cursor,loop cursor,exit cursor,declare cursor,define cursor,cursor in procedure,cursor in function,knowledge 360,akram sohail,cursors in postgresql,postgresql cursor syntax