Cursors In Postgresql - Step By Step Explanation With Simple Examples | Postges Cursors explanation PART-2
PostgreSQL Cursors Step by Step explanation with simple examples (English, Hindi)
SELECT comp_name,city,total_sales FROM DEMO_TEST.sales
where city = 'Mumbai'; 1st-15 2nd 25--print last 12
SELECT * FROM demo_test.fn_total_sal_vl_ct_v2('my_shop','Mumbai'); --52.00
CREATE OR REPLACE FUNCTION demo_test.fn_total_sal_vl_ct_v2(
comp_nm character varying,
city_nm character varying)
RETURNS numeric -- Total sal amount
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
v_total_sal NUMERIC DEFAULT 0;
v_rec_val record ;
cur_cty_sal SCROLL CURSOR ---stp 1 declare
FOR
SELECT comp_name,city,total_sales FROM DEMO_TEST.sales
where comp_name = comp_nm AND city = city_nm;
BEGIN
OPEN cur_cty_sal; --stp 2 -- open the cursor
FETCH LAST FROM cur_cty_sal INTO v_rec_val; --12 Val -- NEXT, FORWARD,LAST,FIRST,
LOOP
--PRIOR, , BACKWARD
v_total_sal := v_total_sal + v_rec_val.total_sales;
FETCH BACKWARD FROM cur_cty_sal INTO v_rec_val; --12 prior 25
EXIT WHEN NOT FOUND;
raise notice 'Each Values for loop current val: % & total Val: %',v_rec_val.total_sales,
v_total_sal;
END LOOP;
CLOSE cur_cty_sal;
RETURN v_total_sal;
END;
$BODY$;
⭐️ Contents ⭐
⌨️ (0:00) Introduction
⌨️
If you liked the video - please hit the like button. Thanks for watching and thank you for all your support!!
Always looking for suggestions on what video to make next you can type class and chapter.
Please below URL for my other video:-कृपया मेरे अन्य वीडियो के लिए नीचे URL देखें:-
PostgreSQL Aggregation, CUBE, and ROLLUP | PostgreSQL: Group By CUBE, CUBE Aggregate , Power BI CUBE
• PostgreSQL Aggregation, CUBE, and ROL...
PostgreSQL Variable, How to define Variables in PostgreSQL | %TYPE Variable definition in Hindi
• PostgreSQL Variable, How to define Va...
PostgreSQL exception handling, User define exception handling (English, Hindi)
• PostgreSQL exception handling, User d...
PostgreSQL Real life ETL Procedure and Function for All type's of DATA Loading in Hindi Part 2
• PostgreSQL Real life ETL Procedure an...
PostgreSQL Simple Procedure or Function for All type's of DATA Loading in Hindi
• PostgreSQL Simple Procedure or Functi...
PostgreSQL Real life automate function examples | PostgreSQL Parent Child relationship Function
• Video '
PostgreSQL Parent Child relationship Function | PostgreSQL Real life automate function examples
• PostgreSQL Parent Child relationship ...
PostgreSQL Parent Child relationship Function | Hierarchy Rollup Child to Parents real life example
• PostgreSQL Parent Child relationship ...
PostgreSQL Automation - Create table scripts using metadata (Create tables using Oracle ) Part 2
• PostgreSQL Automation - Create table ...
PostgreSQL Automation - Create table scripts using metadata (Create tables using Oracle metadata)
• PostgreSQL Automation Create table sc...
Introduction to PostgreSQL STRING_AGG() function | PostgreSQL Aggregate function in Hindi
• Introduction to PostgreSQL STRING_AGG...
Cursors in PostgreSQL | Cursor best explanation in Hindi | Cursor uses inside Function and Procedure
• Cursors in PostgreSQL | Cursor best e...
POSTGRESQL SELECT LATEST ROW IN EACH GROUP, COLLECT LATEST RECORD FROM ALL HISTORY IN HINDI
• POSTGRESQL SELECT LATEST ROW IN EACH ...
PostgreSQL DROP SCHEMA TABLES, CLEAN SET OF TABLES | Delete data from specific tables in Hindi'
• PostgreSQL DROP SCHEMA TABLES, CLEAN ...
PostgreSQL Save output/result from PostgreSQL to a CSV file | PostgreSQL Copy option | Copy command
• PostgreSQL Save output/result from Po...
PostgreSQL: Show tables in PostgreSQL || How do I see all tables in PostgreSQL (English, Hindi)
• PostgreSQL: Show tables in PostgreSQL...
PostgreSQL DATE, DATETIME, CAST, DATE CONVERSION. NOW,TIME ZONE, EXTRACT, Covert datetime in Hindi
• PostgreSQL DATE, DATETIME, CAST, DATE...
PostgreSQL Exception Handling | Error Handling | Exception When condition | Exception in Hindi
• PostgreSQL Exception Handling | Erro...
PostgreSQL Array Functions and Operators in Hindi | Concept of Arrays | Declaration of Array Types
• PostgreSQL Array Functions and Operat...
CREATE FUNCTIONS IN POSTGRESQL with Return Single row, Multiple row and return table in Hindi
• CREATE FUNCTIONS IN POSTGRESQL with R...
PostgreSQL WITH Recursive Queries | CTE (Common Table Expressions) Recursive in Hindi
• PostgreSQL WITH Recursive Queries | C...
PostgreSQL Trigger with Simple Examples | PostgreSQL Triggers in Hindi | Trigger pros and cons
• PostgreSQL Trigger with Simple Exampl...
PostgreSQL backup, restore, Import, Export & debug CSV Import Issues database with Pgadmin
• PostgreSQL backup, restore, Import, E...
PostgreSQL EXPLAIN , EXPLAIN ANALYZE & VERBOSE | PostgreSQL DB File system | Performance Tuning
• PostgreSQL EXPLAIN , EXPLAIN ANALYZE ...
PostgreSQL Set Operations | UNION | UNION ALL | EXCEPTS | INTERSECT in HINDI
• PostgreSQL Set Operations | UNION | U...
#RK_Malviya_Math_Class_in_Hindi