473,385 Members | 1,506 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.

PRINT debug messages and CURSOR in stored procedure confuses DTS; "Invalid Pointer"

I have the following stored procedure that is called from the source of
a transformation in a DTS package. The first parameter turns on PRINT
debug messages. The second, when equals 1, turns on the openning,
fetching, and closing of a cursor. Things are fine if only one of the
two parameters was set to 1.

When run with both parameters turned on, "dba_test_dts 1, 1", DTS
source (tab) preview fails because it thinks no row was returned. "No
rowset was returned from the SQL statement". Understanbly then the
transformation step would also fail with the "Invalid Pointer" error.

As you'd see, I have SET NOCOUNT ON in the code. Has anyone
experienced this? Is this a known bug? This occurs in SQL Server 2000
running on Windows Server 2003.
-----------------------------------------------------------------------------------------------------------------
CREATE PROC dba_test_dts ( @debug BIT = NULL, @cur BIT = NULL )

AS

-- Always have these 2 options set or unset so DTS would not error out
-- with the Invalid Pointers message.

SET NOCOUNT ON

SET ANSI_WARNINGS OFF

DECLARE @FMT_FILE_NAME VARCHAR(256)
DECLARE @OUTPUT_FILE_NAME VARCHAR(256)

DECLARE @emp_id INT
DECLARE @lastname VARCHAR(70)

IF ( @debug = 1 )
BEGIN
PRINT '=== BEGIN ==='
PRINT 'Stored Procedure dts_calling_stored_proc'
PRINT 'Begin timestamp: ' + CONVERT(VARCHAR(32), CURRENT_TIMESTAMP,
109 )
PRINT 'Server : ' + @@SERVERNAME
PRINT 'Host Name/ID : ' + HOST_NAME() + '/' + CONVERT(VARCHAR(32),
HOST_ID())
PRINT 'Database : ' + DB_NAME()
PRINT 'User/NT User : ''' + USER_NAME() + '''/''' + SYSTEM_USER +
''''
PRINT 'DEBUG FLAG : ' + CONVERT( CHAR(1), @DEBUG )
PRINT '=== BEGIN ==='
PRINT SPACE(1)
END

IF ( EXISTS ( SELECT 1 FROM sysobjects WHERE
id=object_id(N'Employees_temp') ) )
DROP TABLE Employees_temp

CREATE TABLE Employees_temp
(
emp_id INTEGER
, lastname VARCHAR(70)
)

INSERT INTO Employees_temp
(
[emp_id]
,[lastname]
)
SELECT EmployeeID
, lastname
FROM Employees

IF ( @cur = 1 )
BEGIN

DECLARE curEmp CURSOR FOR
SELECT emp_id
, lastname
FROM Employees_temp

OPEN curEmp

FETCH NEXT FROM curEmp
INTO
@emp_id, @lastname

WHILE ( @@FETCH_STATUS = 0 )
BEGIN
FETCH NEXT FROM curEmp
INTO
@emp_id, @lastname
END

CLOSE curEmp
DEALLOCATE curEmp

END

SELECT emp_id
, lastname
FROM Employees_temp

GO

Dec 8 '06 #1
2 22822
As you'd see, I have SET NOCOUNT ON in the code. Has anyone
experienced this? Is this a known bug? This occurs in SQL Server 2000
running on Windows Server 2003.
I haven't run into this before but I can see how PRINT statements in a
transformation task could confuse DTS. I did a little experimenting and
found that DTS was fine as long as the PRINT statements ran after the SELECT
statement that returned the proc result. If you must have the debug
functionality, consider saving the messages into local variables for
printing after the result set is returned.

Separately, I don't understand the purpose of the cursor here. It seems
tome that the entire body of the proc could be replace with the query below.

SELECT
EmployeeID AS emp_id,
lastname
FROM Employees
WHERE @cur = 1
--
Hope this helps.

Dan Guzman
SQL Server MVP

"Bill_DBA" <bi***********@yahoo.comwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
>I have the following stored procedure that is called from the source of
a transformation in a DTS package. The first parameter turns on PRINT
debug messages. The second, when equals 1, turns on the openning,
fetching, and closing of a cursor. Things are fine if only one of the
two parameters was set to 1.

When run with both parameters turned on, "dba_test_dts 1, 1", DTS
source (tab) preview fails because it thinks no row was returned. "No
rowset was returned from the SQL statement". Understanbly then the
transformation step would also fail with the "Invalid Pointer" error.

As you'd see, I have SET NOCOUNT ON in the code. Has anyone
experienced this? Is this a known bug? This occurs in SQL Server 2000
running on Windows Server 2003.
-----------------------------------------------------------------------------------------------------------------
CREATE PROC dba_test_dts ( @debug BIT = NULL, @cur BIT = NULL )

AS

-- Always have these 2 options set or unset so DTS would not error out
-- with the Invalid Pointers message.

SET NOCOUNT ON

SET ANSI_WARNINGS OFF

DECLARE @FMT_FILE_NAME VARCHAR(256)
DECLARE @OUTPUT_FILE_NAME VARCHAR(256)

DECLARE @emp_id INT
DECLARE @lastname VARCHAR(70)

IF ( @debug = 1 )
BEGIN
PRINT '=== BEGIN ==='
PRINT 'Stored Procedure dts_calling_stored_proc'
PRINT 'Begin timestamp: ' + CONVERT(VARCHAR(32), CURRENT_TIMESTAMP,
109 )
PRINT 'Server : ' + @@SERVERNAME
PRINT 'Host Name/ID : ' + HOST_NAME() + '/' + CONVERT(VARCHAR(32),
HOST_ID())
PRINT 'Database : ' + DB_NAME()
PRINT 'User/NT User : ''' + USER_NAME() + '''/''' + SYSTEM_USER +
''''
PRINT 'DEBUG FLAG : ' + CONVERT( CHAR(1), @DEBUG )
PRINT '=== BEGIN ==='
PRINT SPACE(1)
END

IF ( EXISTS ( SELECT 1 FROM sysobjects WHERE
id=object_id(N'Employees_temp') ) )
DROP TABLE Employees_temp

CREATE TABLE Employees_temp
(
emp_id INTEGER
, lastname VARCHAR(70)
)

INSERT INTO Employees_temp
(
[emp_id]
,[lastname]
)
SELECT EmployeeID
, lastname
FROM Employees

IF ( @cur = 1 )
BEGIN

DECLARE curEmp CURSOR FOR
SELECT emp_id
, lastname
FROM Employees_temp

OPEN curEmp

FETCH NEXT FROM curEmp
INTO
@emp_id, @lastname

WHILE ( @@FETCH_STATUS = 0 )
BEGIN
FETCH NEXT FROM curEmp
INTO
@emp_id, @lastname
END

CLOSE curEmp
DEALLOCATE curEmp

END

SELECT emp_id
, lastname
FROM Employees_temp

GO
Dec 9 '06 #2
Thanks Dan,

We had a stored procedure to extract for a fixed field file sending to
Peoplesoft on Oracle. The DTS was to map the resultset into the fixed
field file. I just thought if I could log the debug prints for this DTS
job because we run it every week. Upon further testing, even had I do
the PRINTs after the Select in the stored proc, neither DTS nor the SQL
job scheduler could channel those debug prints from the stored
procedure because there are too many re-direction.

I have decided to use BCP over DTS to create the fixed field file. And
call the stored procedure directly from the job scheduler.

Cursor processing in my sample code was indeed a moot step. It was used
to illustrate the PRINT and CURSOR combo problem.

Bill.

Dan Guzman wrote:
As you'd see, I have SET NOCOUNT ON in the code. Has anyone
experienced this? Is this a known bug? This occurs in SQL Server 2000
running on Windows Server 2003.

I haven't run into this before but I can see how PRINT statements in a
transformation task could confuse DTS. I did a little experimenting and
found that DTS was fine as long as the PRINT statements ran after the SELECT
statement that returned the proc result. If you must have the debug
functionality, consider saving the messages into local variables for
printing after the result set is returned.

Separately, I don't understand the purpose of the cursor here. It seems
tome that the entire body of the proc could be replace with the query below.

SELECT
EmployeeID AS emp_id,
lastname
FROM Employees
WHERE @cur = 1
--
Hope this helps.

Dan Guzman
SQL Server MVP
Dec 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Peter Afonin | last post by:
Hello: When I try to access a SQL server or a network share from an ASP.Net application that I run on my computer, I run into security problems (for instance, I cannot execute DTS package using...
0
by: Jim Fisher | last post by:
I've been trying to find the time to get my site up and running before posting this article, but it looks like the trend is leaning toward less free time rather than more. Since this has been...
6
by: murgan | last post by:
Hi people, i am new to this group,this is my first query, friends i want to know the difference between "function pointer" and "pointer to a function" in c lang, so friends please send the...
1
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL:...
1
by: Robinson | last post by:
Hi, I just took a deep breath, made a backup and decided to have a go at converting my 1.1 project to 2.0. All goes well, apart from 10,000 warning messages about references being used before...
0
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
10
by: jonathanemil | last post by:
Hello, I am a 1st semester Computer Science student in a Python class. Our current assignment calls for us to read a list from a file, create a 2-dimensional list from the file, and check to see...
3
by: Renzr | last post by:
I have a C++ package which works very well in the 32-bit Linux-like OS. However, it will lead to a "*** glibc detected *** ./ex2: munmap_chunk(): invalid pointer" in 64-bit (Fedora 7-64), when it...
4
RMWChaos
by: RMWChaos | last post by:
Darnit all, I expect the code I steal from others to work! =D Below is some code that I got to initiate multiple javascripts on page load (rather than using the "onload=" attribute). According the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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.