내가 작성한 스토리지 프로세스
39725 단어 저장 프로세스
-- : 10
---2011-11-11 lp,
IF exists (select * from SysObjects where name='sp_reportlist' and type='p')
drop procedure sp_reportlist
go
CREATE PROCEDURE sp_reportlist
@stockcode nvarchar(20)
as
if(@stockcode!='')
begin
SELECT top 10 T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE
WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' ' WHEN T1.Grade=3 THEN ' '
WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE
WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate,
T1.TargetPrice,T2.ReportDate FROM StockReview T1,Report T2,Company T3 where (T1.stockcode=@stockcode or T1.stockname=@stockcode) and T1.ReportID = T2.ReportID
and T2.CompanyID = T3.SourceID order by T2.ReportDate desc
end
else -- 10
begin
SELECT top 10 T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE
WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' ' WHEN T1.Grade=3 THEN ' '
WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE
WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate,
T1.TargetPrice,T2.ReportDate FROM StockReview T1,Report T2,Company T3 where T1.ReportID = T2.ReportID
and T2.CompanyID = T3.SourceID order by T2.ReportDate desc
end
GO
---- : stockcode
-- stockcode ,
IF exists (select * from SysObjects where name='sp_allreportlist' and type='p')
drop procedure sp_allreportlist
go
CREATE PROCEDURE sp_allreportlist
@stockcode nvarchar(20)
as
if(@stockcode!='')
begin
SELECT T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE
WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' ' WHEN T1.Grade=3 THEN ' '
WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE
WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate,
T1.TargetPrice,T2.ReportDate FROM (select ReportID,StockCode,Grade,GradeUpdate,TargetPrice from StockReview where stockcode=@stockcode or stockname=@stockcode) T1 left join Report T2 on T1.ReportID = T2.ReportID left join Company T3
on T2.CompanyID = T3.SourceID order by T2.ReportDate desc
end
else
begin
SELECT T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' '
WHEN T1.Grade=3 THEN ' ' WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate, T1.TargetPrice,T2.ReportDate
FROM StockReview T1 , Report T2,Company T3
where T1.ReportID = T2.ReportID and T2.CompanyID = T3.SourceID
order by T2.Reportdate desc
end
GO
--- : stockcode
IF exists (select * from SysObjects where name='sp_allreportcount' and type='p')
drop procedure sp_allreportcount
go
CREATE PROCEDURE sp_allreportcount
@stockcode nvarchar(20)
as
if(@stockcode!='')
begin
SELECT count(T1.ReportID) FROM (select ReportID,StockCode,Grade,GradeUpdate,TargetPrice from StockReview where stockcode=@stockcode or stockname=@stockcode) T1 left join Report T2 on T1.ReportID = T2.ReportID left join Company T3
on T2.CompanyID = T3.SourceID
end
else
begin
SELECT count( T1.ReportID) FROM StockReview T1 , Report T2,Company T3
where T1.ReportID = T2.ReportID and T2.CompanyID = T3.SourceID
end
GO
exec sp_allreportcount '000001'
exec sp_allreportlist '' --
exec sp_reportpagelist '000001' ,10,10
--- : , @endrecord-@num+1 @endrecord
IF exists (select * from SysObjects where name='sp_reportpagelist' and type='p')
drop procedure sp_reportpagelist
go
CREATE PROCEDURE sp_reportpagelist
@stockcode nvarchar(20),
@num int, --
@endrecord int -- 0
as
if(@stockcode!='') -- @stockcode
begin
select * from ( select top (@num) * from (
SELECT top (@endrecord) T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE
WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' ' WHEN T1.Grade=3 THEN ' '
WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE
WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate,
T1.TargetPrice,T2.ReportDate FROM
(select ReportID,StockCode,Grade,GradeUpdate,TargetPrice from StockReview where stockcode=@stockcode or stockname=@stockcode) T1
left join Report T2 on T1.ReportID = T2.ReportID left join Company T3
on T2.CompanyID = T3.SourceID order by T2.ReportDate desc
) TT order by TT.ReportDate) TTT order by TTT.ReportDate desc
end
else --
begin
select * from ( select top (@num) * from (
SELECT top (@endrecord) T1.ReportID,T1.StockCode,T2.ReportTitle,T3.SourceID,T3.CompanyName,T3.CompanyShortName,
CASE
WHEN T1.Grade=0 THEN ' ' WHEN T1.Grade=1 THEN ' ' WHEN T1.Grade=2 THEN ' ' WHEN T1.Grade=3 THEN ' '
WHEN T1.Grade=4 THEN ' ' WHEN T1.Grade=5 THEN ' ' END AS Grade,
CASE
WHEN T1.GradeUpdate=0 THEN '--' WHEN T1.GradeUpdate=1 THEN ' ' WHEN T1.GradeUpdate=2 THEN ' '
WHEN T1.GradeUpdate=3 THEN ' ' END AS GradeUpdate,
T1.TargetPrice,T2.ReportDate FROM
(select ReportID,StockCode,Grade,GradeUpdate,TargetPrice from StockReview) T1
left join Report T2 on T1.ReportID = T2.ReportID left join Company T3
on T2.CompanyID = T3.SourceID order by T2.ReportDate desc
) TT order by TT.ReportDate) TTT order by TTT.ReportDate desc
end
GO
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java 호출 Oracle 스토리지 프로세스 상세 정보Java 호출 Oracle 스토리지 프로세스 상세 정보 단계: 1. Oracle 스토리지 프로세스 작성 2. 데이터베이스 작성 연결 도구 클래스 얻기 3. 간단한 응용 프로그램 호출 저장 프로세스 작성 구현: 1. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.