How to Create a stored procedure for querying information in Oracle!

Source: Internet
Author: User

Usually used to MS-SQL2000, Meng a use of Oracle is really a little uncomfortable. Today, I wrote a query statement. After writing it, I found it was too long. In terms of performance and convenience, it is decided to pass it to the stored procedure for implementation. The idea is there, but I really don't know how to write it on Oracle! (Oracle syntax manuals have not yet been practically studied. They are all used in rare cases !)

First, imitate the existing stored procedure to add its syntax structure.

The format is as follows:

Create Or Replace ProcedureSp_zy_hzqdyl (

V_inpatient_idIn Number,

)Is

Begin
 Select * from a where c =V_inpatient_id
End

Haha !! Finished! PL/SQL Execution, Error!

What's going on !!

Later, I asked my colleagues to understand that the cursor should be used to query data in Oracle!

Create Or Replace ProcedureSp_zy_hzqdyl (


V_inpatient_idIn Number,

C_curOutPa_zy.c_zy
)Is

Begin
 OpenC_curFor
 Select * from a where c =V_inpatient_id
End

Executed in PL/SQL. Successful!

I learned some basic knowledge today!


 

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.