473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to replicate the SQL Server 2005 Procedure to DB2?

ALTER PROCEDURE TEST_UPF


AS

DECLARE @LOGON VARCHAR(32);

DECLARE @LEVEL INT;
DECLARE @LOGON_COUNT INT;

DECLARE LOGON_CUR cursor for
SELECT LOGON FROM dbo.USER_PRODUCT_FACT_RPL
WHERE LEVEL = 4;


DECLARE LOGON_CNT_CUR cursor for
SELECT COUNT(*) LOGON FROM dbo.USER_PRODUCT_FACT_RPL
WHERE LEVEL = 4;


OPEN LOGON_CUR ;
OPEN LOGON_CNT_CUR ;

FETCH NEXT FROM LOGON_CNT_CUR INTO @LOGON_COUNT

WHILE(@LOGON_COUNT <> 0)
BEGIN

FETCH NEXT FROM LOGON_CUR INTO @LOGON

INSERT PROCE_LOGONS_OUTPUT_NARSIMHA_TEST
SELECT DISTINCT W.PARENT,W.LOGON,W.CUSTOMER_NUMBER,W.LEVEL, 0
FROM dbo.USER_PRODUCT_FACT_RPL W
WHERE W.[LOGON] = @LOGON

SELECT @LEVEL= LEVEL FROM PROCE_LOGONS_OUTPUT_NARSIMHA_TEST WHERE LOGON = @LOGON

WHILE @LEVEL > 1
BEGIN

INSERT INTO PROCE_LOGONS_OUTPUT_NARSIMHA_TEST
SELECT DISTINCT w.PARENT,c.LOGON,c.CUSTOMER_NUMBER,W.LEVEL,@LEVEL-1
FROM dbo.USER_PRODUCT_FACT_RPL W, PROCE_LOGONS_OUTPUT_NARSIMHA_TEST C
WHERE C.PARENT = W.LOGON AND W.LEVEL = @LEVEL-1
AND C.LOGON=@LOGON AND W.PARENT IS NOT NULL



SET @LEVEL = @LEVEL - 1
END

SET @LOGON_COUNT = @LOGON_COUNT - 1

END
CLOSE LOGON_CUR;
DEALLOCATE LOGON_CUR;

CLOSE LOGON_CNT_CUR;
DEALLOCATE LOGON_CNT_CUR;

SELECT * FROM PROCE_LOGONS_OUTPUT_NARSIMHA_TEST
order by logon,level

GO
Aug 14 '07 #1
0 922

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chris Auer | last post by:
Hopeing this is something I can accomplish. I use MS-SQL for close to 100 CMS web servers. Everytime I create a new website I have to create a new database and then use the export from SQL to SQL...
17
by: Danieltbt05 | last post by:
just installed SQL server 2000 and using my client , i can't locate the server. I used SQL query analyzer to search but no servers were found. Error message is as below Server : Msg17,level...
1
by: chloe.crowder | last post by:
Hi We're trying to use call a stored procedure to update information in a remote Ingres database. We've linked the server, and can read information using SELECT * FROM OPENQUERY (..........),...
9
by: billmiami2 | last post by:
I was playing around with the new SQL 2005 CLR functionality and remembered this discussion that I had with Erland Sommarskog concerning performance of scalar UDFs some time ago (See "Calling...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
2
by: sqlgirl | last post by:
Hi, We have 2 servers. Server1 is a 2000 box, with SP3 (yes I know it is not up to date). Server2 is a 2005 box, SP2. I set up Server1 (2000) to have a linked server to Server2 (2005). The...
1
by: DR | last post by:
what are the memory caps for threads running as a CLR stored procedure executed by sql server 2005? is it limited by OS only or also by sql servers memory limits? e.g. lets say my clr stored...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.