Pgsql Variable Assignment method

Source: Internet
Author: User

1, online generally said the method is as follows:

: =, assignment, e.g. user_id: = 20;

Select into assignment, such as SELECT INTO Myrec * from emp WHERE empname = myname

2, I present today is a more general and more practical assignment method

Select ... into ...

Examples of Use:

A variable, select INTO user_id;

Multiple variables, select 20,30,50 into A,B.C;

3, in the storage function (that is, in the stored procedure) and into is also very common.

For example, when stitching characters, go directly into.

Select ' Update student set remark = ' ' | | Now () | | ' where student.id = ' | | $ into sql_str_run;
Execute Sql_str_run;

Pgsql Variable Assignment method

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.