首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

有个sql server 存储过程 的SELECT 结果想调用到DW,不知道怎做解决思路

2012-03-16 
有个sql server 存储过程 的SELECT 结果想调用到DW,不知道怎做下面是我的SQL SERVER 存储过程生成的临时表

有个sql server 存储过程 的SELECT 结果想调用到DW,不知道怎做
下面是我的SQL SERVER 存储过程

生成的临时表#tempprod想在DW里显示,不知道怎样做

if not exists(select * from tempdb..sysobjects where id=object_id( 'tempdb..#tempprod '))
  create table #tempprod(prod_no char(8) primary key,prod_name char(50),prod_size char(20),last_add char(12),monad char(4),prod_price_db numeric(9,2),corp_price numeric(9,2),lest_num numeric(9,3),ml numeric(9,2))
else
  delete from #tempprod
declare @myprodno char(8),@myprodname char(50) ,@myprodsize char(20),@mylastadd char(12)
declare @mymonad char(4),@myprodpricedb numeric(9,2)
declare @mycorpprice numeric(9,2),@ml numeric(9,2)
declare @ml1 numeric(9,2),@ml2 numeric(9,2),@formvalue1 numeric(9,2),@formvalue2 numeric(9,2)
declare @formvalue3 numeric(9,2),@formvalue4 numeric(9,2),@formvalue5 numeric(9,2),@formvalue6 numeric(9,2)
declare @rndmycorpprice numeric(9,2),@mylestnum numeric(9,2)
declare cur_prod cursor for select p.prod_no,prod_name,prod_size,last_add,monad,prod_price_db,corp_price,c.lest_num from product p left join prod_dep c on p.prod_no=c.prod_no
 open cur_prod
 fetch next from cur_prod into @myprodno,@myprodname,@myprodsize,@mylastadd,@mymonad,@myprodpricedb,@mycorpprice,@mylestnum
  while @@fetch_status=0
  begin
  if @myprodpricedb is null
  set @myprodpricedb=0
  if @mycorpprice is null
  set @mycorpprice=0
  if @mylestnum is null
  set @mylestnum=0
  set @formvalue1=@myprodpricedb-@mycorpprice/1.35
  set @formvalue2=@myprodpricedb-(@mycorpprice-0.5)/1.3
  set @formvalue3=@myprodpricedb-(@mycorpprice-4.5)/1.2
  set @formvalue4=@myprodpricedb-(@mycorpprice-14.5)/1.1
  set @formvalue5=@myprodpricedb-(@mycorpprice-24.5)/1.08
  set @formvalue6=@myprodpricedb-(@mycorpprice-184.5)
  set @rndmycorpprice=round(@mycorpprice,2)
  if (@rndmycorpprice>=0 and @rndmycorpprice<=17.40) or (@rndmycorpprice>=17.51 and @rndmycorpprice<=63.30) or (@rndmycorpprice>=64.21 and @rndmycorpprice<=265.29) or (@rndmycorpprice>=284.11 and @rndmycorpprice<=743.78) or (@rndmycorpprice>=749.31 and @rndmycorpprice<=2362.49) or @rndmycorpprice>=2376.75
  begin
  if @rndmycorpprice>=0 and @rndmycorpprice<=17.40
  set @ml=@formvalue1  
  if @rndmycorpprice>=17.51 and @rndmycorpprice<=63.30
  set @ml=@formvalue2
  if @rndmycorpprice>=64.21 and @rndmycorpprice<=265.29
  set @ml=@formvalue3
  if @rndmycorpprice>=284.11 and @rndmycorpprice<=743.78
  set @ml=@formvalue4
  if @rndmycorpprice>=749.31 and @rndmycorpprice<=2362.49
  set @ml=@formvalue5
  if @rndmycorpprice>=2376.75
  set @ml=@formvalue6
  end
  else
  begin
  if @rndmycorpprice>=17.41 and @rndmycorpprice<=17.50
  begin
  set @ml1=@formvalue1
  set @ml2=@formvalue2
  end
  if @rndmycorpprice>=63.31 and @rndmycorpprice<=64.20
  begin
  set @ml1=@formvalue2
  set @ml2=@formvalue3
  end 
  if @rndmycorpprice>=265.30 and @rndmycorpprice<=284.10
  begin
  set @ml1=@formvalue3
  set @ml2=@formvalue4
  end 
  if @rndmycorpprice>=743.79 and @rndmycorpprice<=749.30
  begin
  set @ml1=@formvalue4
  set @ml2=@formvalue5


  end 
  if @rndmycorpprice>=2362.50 and @rndmycorpprice<=2376.74
  begin
  set @ml1=@formvalue5
  set @ml2=@formvalue6
  end 
  if @ml1>0 and @ml2>0
  if @ml1>@ml2
  set @ml=@ml1
  else
  set @ml=@ml2
  if @ml1>0 and @ml2<0
  set @ml=@ml2
  if @ml1<0 and @ml2>0
  set @ml=@ml1
  if @ml1<0 and @ml2<0
  if @ml1>@ml2
  set @ml=@ml1
  else
  set @ml=@ml2
   
  end


insert into #tempprod (prod_no,prod_name,prod_size,last_add,monad,prod_price_db,corp_price,ml,lest_num) values ( @myprodno,@myprodname,@myprodsize,@mylastadd,@mymonad,@myprodpricedb,@mycorpprice,@ml,@mylestnum)

fetch next from cur_prod into @myprodno,@myprodname,@myprodsize,@mylastadd,@mymonad,@myprodpricedb,@mycorpprice,@mylestnum

end
close cur_prod
deallocate cur_prod




select * from #tempprod order by ml desc
 

[解决办法]
看这里
http://topic.csdn.net/u/20110509/15/7eacef43-8499-4bd0-a415-471212200adf.html
[解决办法]
在which data source would you like to use?
中选择storedprocedure.

通常我们都用的是SQL Select
[解决办法]

探讨
在which data source would you like to use?
中选择storedprocedure.

通常我们都用的是SQL Select

[解决办法]
动态构建datastore

热点排行
Bad Request.