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;