PostgreSQL cursor example

Source: Internet
Author: User
1. The following Code creates a top100cur () function, which returns an anonymous cursor -- dropfunctiontop100cur (); createfunctiontop10

1. The following Code creates a top100cur () function, which returns an anonymous cursor -- drop function top100cur (); create function top10

1. The following Code creates a top100cur () function, which returns an anonymous cursor.

2. The following code will create a function and return a cursor named abc (Can you find the difference? Yes. Whether the cursor is anonymous depends on whether the cursor variable is bound to the open cursor) 3. Return the cursor named by the caller. 4. Return a cursor named $1. 5. Return an anonymous cursor. 6. Return the cursor specified by the caller. different? In 4 and 5, the cursor variable name declared by declare is too special, and the anonymous parameter name is hidden ......)

7. open a cursor variable that is neither declare nor passed in.

Summary:

1. declare variables will cause function parameters to be hidden (for example, after declare $1, the first anonymous parameter will be hidden );

2. declare only declares a cursor and does not open the cursor. A cursor without open is unavailable ~

3. When you open the cursor after declare, if the cursor is unbound (no cursor for XXX When declare is used), an anonymous cursor is obtained after the cursor is opened;

4. The cursor variable of the open operation is either declare or a string passed in as a parameter. In addition, an error is returned!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.