How to write a Cursor for PostgreSQL. Learn how to Open, Move, Fetch, Close., and Update/Delete DB.

Veröffentlicht am: 05 September 2022
auf dem Kanal: Software Nuggets
3,971
66

How to write a Cursor that loops over a result set, and allow the program to evaluate each row.

table of contents:
00:00 begin
00:12 - build a table and insert data
00:44 - build a basic cursor
06:42 - learn how to fetch
09:42 - learn how to loop
11:54 - learn how to loop in reverse
13:47 - learn how to update base table (and how to use random() function)
17:44 - learn how to delete from base table
21:25 - closing message from software nuggets


Access a cursor in PL/pgSQL goes through cursor variables, which are always of the special data type refcursor.
How to declare a rowset object using the database.tablename%ROWTYPE
How to open and close a cursor
How to use the cursor move method to reposition the current pointer
How to the the curosr fetch method using the directions: first, last, prior, next and relative
How to use the special variable "found" to exit a loop

Use the built-in RANDOM function and LIMIT the number of Records to be used in a Cursor.

How to use raise notice to print a response to the Messages tab.

#softwareNuggets, #postgresql


Auf dieser Seite können Sie das Online-Video How to write a Cursor for PostgreSQL. Learn how to Open, Move, Fetch, Close., and Update/Delete DB. mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Software Nuggets 05 September 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,971 Mal angesehen und es wurde von 66 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!