Differences between Oracle and MSSQL Stored Procedures

Source: Internet
Author: User

Stored Procedure 

I. Multi-table join query and updating stored procedures

SQL stored procedure
Alter procedure [DBO]. [getevent]
@ Scswid nvarchar (20) = NULL,
@ Todate datetime,
@ Fromdate datetime
As
Select notes. note_id,
Notes. Note,
Scsw_calendar.date_time
From scsw_calendar
Left Outer Join notes on scsw_calendar.note_id = notes. note_id
Where scsw_calendar.scsw_id = scswid
Order by patient. patientid

Stored Procedure

1. Stored Procedure for querying data
Procedure getevent (scswid in varchar2, fromdate in date, todate in date, refout out refcursor)
Is
Begin
Open refout
Select notes. note_id,
Notes. Note,
Scsw_calendar.date_time
From scsw_calendar
Left join notes on scsw_calendar.note_id = notes. note_id
Where scsw_calendar.scsw_id = scswid
And scsw_calendar.date_time> = fromdate
And scsw_calendar.date_time <todate
Order by scsw_calendar.date_time;
End getevent;

2. Stored Procedure for updating data:
Procedure updatearticlesubmodel
(
Articlesubid number,
Articletitle nvarchar2,
Articlekeyword nvarchar2,
Articlecontent clob,
Createperson nvarchar2,
Changedate date,
Settop number,
Articlesubstyleid number,
Checked number
)
As
Begin
Update "articlesubmodel"
Set "articletitle" = articletitle,
"Articlekeyword" = articlekeyword,
"Articlecontent" = articlecontent,
"Createperson" = createperson,
"Createdate" = changedate,
"Settop" = settop,
"Articlesubstyleid" = articlesubstyleid,
"Checked" = checked
Where "articlesubid" = articlesubid;
Commit;
Exception when others then
Rollback;
End updatearticlesubmodel;
3. Stored Procedure for data deletion
Procedure deletearticlesubmodel
(
Articlesubid number
)
As
Begin
Delete from "articlesubaccessories"
Where "articlesubid" = articlesubid;
Delete from "articlesubmodel"
Where "articlesubid" = articlesubid;
Commit;
Exception when others then
Rollback;
End deletearticlesubmodel;

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.