`
huangyongxing310
  • 浏览: 477799 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

执行存储过程测试

 
阅读更多

--执行存储过程创建
if (exists (select * from sys.objects where name = 'p_areaChannelDistributionReport'))
    drop proc p_areaChannelDistributionReport
go

create proc p_areaChannelDistributionReport
as
BEGIN
    select COUNT(*) AS num from sa_agreement;

End

--调用、执行存储过程
exec p_areaChannelDistributionReport;





--循环使用
DECLARE @areaId  as varchar(40)

DECLARE cur_area CURSOR FOR 
SELECT nid AS areaId from t_area_info with (nolock) WHERE parentid=1

OPEN cur_area


fetch next from cur_area into @areaId  --将游标向下移1行,获取的数据放入之前定义的变量@id,@name中
while @@fetch_status=0           --判断是否成功获取数据
begin

Print @areaId


fetch next from cur_area into @areaId  --将游标向下移1行
end

close cur_area                   --关闭游标
deallocate cur_area





--定义变量和设置值
DECLARE @areaId  as varchar(40)

Declare @yearString as varchar(6)
Set @yearString ='2021'



--增删改操作


Begin
Delete [areaChannelDistributionReport]
where
Not Exists (Select B.toChannel From #temp_areaChanneltargetValue AS B
WHere  B.toChannel = [areaChannelDistributionReport].toChannel
AND B.channelId = [areaChannelDistributionReport].channelId
AND B.areaId = [areaChannelDistributionReport].areaId
AND B.channelType = [areaChannelDistributionReport].channelType
AND B.khId = [areaChannelDistributionReport].khId
AND B.yearString = [areaChannelDistributionReport].yearString
)

end




Begin
Update [areaChannelDistributionReport]
Set [khId] = B.[khId]
,[khName] = B.[khName]
,[channelId] = B.[channelId]
,[areaId] = B.[areaId]
,[areaName] = B.[areaName]
,[regionId] = B.[regionId]
,[regionName] = B.[regionName]
,[channelType] = B.[channelType]
,[channelTypeName] = B.[channelTypeName]
,[toChannel] = B.[toChannel]
,[targetT1] = B.[targetT1]
,[targetT2] = B.[targetT2]
,[targetT3] = B.[targetT3]
,[targetT4] =   B.[targetT4]
,[targetT5] =    B.[targetT5]
,[targetT6] = B.[targetT6]
,[targetN1] = B.[targetN1]
,[targetN2] = B.[targetN2]
,[targetN3] = B.[targetN3]
,[targetN4] = B.[targetN4]
,[targetN5] = B.[targetN5]
,[yearString] = B.[yearString]
,[targetT31] = B.[targetT31]
,[targetT32] = B.[targetT32]
,[targetT33] = B.[targetT33]
,[targetT41] = B.[targetT41]
,[targetT42] = B.[targetT42]
,[targetT43] = B.[targetT43]
,[targetT44] = B.[targetT44]
,[confirm] = B.[confirm]

From #temp_areaChanneltargetValue AS B
WHere  B.toChannel = [areaChannelDistributionReport].toChannel
AND B.channelId = [areaChannelDistributionReport].channelId
AND B.areaId = [areaChannelDistributionReport].areaId
AND B.channelType = [areaChannelDistributionReport].channelType
AND B.khId = [areaChannelDistributionReport].khId
AND B.yearString = [areaChannelDistributionReport].yearString
end



Begin

insert into [areaChannelDistributionReport] (
khId ,
khName,
channelId,
areaId,
areaName,
regionId,
regionName,
channelType,
channelTypeName,
channelName,
toChannel,
targetT1,
targetT2,
targetT3,
targetT4,
targetT5,
targetT6,
targetN1,
targetN2,
targetN3,
targetN4,
targetN5 ,
yearString ,
targetT31,
targetT32,
targetT33,
targetT41,
targetT42,
  targetT43,
targetT44,
confirm
  )
Select 
khId ,
khName,
channelId,
areaId,
areaName,
regionId,
regionName,
channelType,
channelTypeName,
channelName,
toChannel,
targetT1,
targetT2,
targetT3,
targetT4,
targetT5,
targetT6,
targetN1,
targetN2,
targetN3,
targetN4,
targetN5 ,
yearString,
targetT31,
targetT32,
targetT33,
targetT41,
targetT42,
  targetT43,
targetT44,
confirm
From #temp_areaChanneltargetValue AS B
Where not exists (Select toChannel From [areaChannelDistributionReport]
WHere  B.toChannel = [areaChannelDistributionReport].toChannel
AND B.channelId = [areaChannelDistributionReport].channelId
AND B.areaId = [areaChannelDistributionReport].areaId
AND B.channelType = [areaChannelDistributionReport].channelType
AND B.khId = [areaChannelDistributionReport].khId
AND B.yearString = [areaChannelDistributionReport].yearString
)


end







分享到:
评论

相关推荐

    GBase8s 存储过程和触发器测试方法

    GBase8s 存储过程测试方法 -- '------------------ 存储过程--------------------------------' --在交互式sql交互式工具中执行,创建表 CREATE TABLE COM_T2 (C1 INT,C2 varchar2(10)); INSERT INTO COM_T2 VALUES...

    Python使用cx_Oracle调用Oracle存储过程的方法示例

    本文实例讲述了Python使用cx_Oracle调用Oracle存储过程的方法。分享给大家供大家参考,具体如下: 这里主要测试在Python中通过cx_Oracle调用PL/SQL。 首先,在数据库端创建简单的存储过程。 create or replace ...

    TPC-E基准测试中BrokerVolume事务在Oracle存储过程中的实现

    TPC-E基准测试是一种权威的服务器在线事务处理性能评测基准,测试基准中包含12个基本事务,本文档实现的是以存储过程的方式来实现其中的一个事务:BrokerVolume,在评测中,客户端软件可以通过调用存储过程来对...

    c#调用存储过程两种方法 - - c# sql .net asp.net

    c#调用存储过程两种方法 - - c# sql .net asp.net

    C# 导出存储过程 支持模糊查询

    不需要去存储过程中找,只要输入您存过程的名称就可以找到您想要的存储过程 支持模糊查找,数据库连接测试.非常方便远程和安装使用

    Oracle数据库存储过程技术文档.doc

    4.2.2 插入测试表调试存储过程 38 4.2.3 DBMS_OUTPUT系统内置包 39 附录一 sql*plus工具 40 附录1.1 sql*plus启动和关闭 41 附录1.2 sql*plus 环境设置 42 附录1.3 设置环境参数 42 附录1.4 sqlplus命令的执行 43 ...

    Oracle数据库中存储过程的异步调用

    本文讲述如何在Oracle通过任务和管道的应用,异步调用存储过程的方法。并且介绍了其基本原理和具体实现测试。

    VB6.0 调用存储过程的例子(方法一)

    VB6.0 调用存储过程的例子(方法一) rm1窗体,Copy以下的代码到窗体中,该段代码将测试存储过程ADOTestRPE的返回值、输入参数及输出参数,测试的过程中,可能需要修改链接字符串。

    java调用shell脚本执行sqlldr与存储过程

    在java代码中调用执行shell脚本,sqlldr导数与使用sqlplus在shell调用执行存储过程。 linux环境中有2个dba的用户:oracle、erm 还有1个web用户:erm 在linux环境中,这三个用户都可以直接在任意目录下执行该shell...

    C#连接Firebird并执行包含UDF的存储过程

    Firbird内嵌函数极少,本示例介绍了如何利用ibexpert创建使用UDF的存储过程,并在C#(winform)中调用该存储过程. 打包部署时只需如下: 1.GDS32.DLL (1.5的版本) 2.FirebirdSql.Data.FirebirdClient.dll 3.ib_util.dll ...

    针对存储过程通用的jdbc封装

    针对java调用存储过程写的通用封装,oracle,mssql测试通过,附带测试脚本.以前写过一个,感觉不是很好,这个周末就重写了一个,大家多多提意见,是eclipse工程直接跑junit就行了,所有的东西都在里面.除了存储过程也可以...

    DB2存储过程加密工具与使用手册

    双击左边的树存储过程,存储过程名会自动到右边的输入框,再点击右边执行按钮进行完成加密。 B加密原理 1.把原存储过程备份到本地DATA/SourceFile文件夹下 2.把存储过程导出加密文件DATA/EncryptionFile文件夹下 3...

    开发一个基于JUnit的存储过程自动化测试的Eclipse插件

    13总结14资源列表参考资料本文将以一个真实的项目为背景,从分析过去存储过程的测试方法中存在的问题入手,逐步阐述我们分析问题,寻找问题根源和寻求解决办法的过程,介绍我们开发这个基于JUnit的存储过程自动化...

    实验5 存储过程和触发器1

    2. 查看存储过程 3. 执行存储过程pr_buy 查询某商品在指定日期之间的销售量 5. 查看触发器 6. 通过sql语句更新商品价格,测试tr_update

    转换汉字金额大写存储过程

    金额转换成大写表示,可直接在服务器端执行,以测试可用,需要用到的朋友可下载

    Oracle存储过程中自定义异常

    进入pl/sql测试窗口  2.执行语句  declare  empname varchar2(255);  customize_exp EXCEPTION; –自定义异常  begin  FOR c IN (select d.* from scott.dept d) LOOP  begin  dbms_output.put_...

    集成测试计划模板

    【描述集成测试执行过程中出现的特殊情况的约束准则。】 如,被测模块出现某个致命性错误。测试案例无法继续执行,测试工作需暂停,如果非关联模块可以进行测试则执行非关联模块的测试;当这些问题得到解决后重新...

    利用loadrunner测试ORACLE存储过程的性能

    首先需要安装LR的.NETADD-IN,在开发环境编写代码,做数据库连接,然后调用执行存储过程。装好以后,打开程序,应该看到菜单栏里多了一个:  首先需要安装LR的.NETADD-IN,在开发环境编写代码,做数据库连接,然后...

    C# 访问Oracle示例+PL/SQL+存储过程+触发器 完整示例 测试可用 易懂

    --执行存储过程,测试 declare productname nvarchar2(100); begin proc_getproductnambyid(productid =>'1',productName=>productname); dbms_output.put_line(productname); end; declare productname nvarchar2...

    数据库:存储过程、触发器、索引实验代码

    作业内容—存储过程和触发器、索引实验 一、 存储过程和触发器实验 1. 请在你选用的数据库平台上,针对你的应用场景,对如下操作至少各实现一个存储过程: 1)单表或多表查询 2)数据插入 3)数据删除 4)数据修改 ...

Global site tag (gtag.js) - Google Analytics