473,386 Members | 1,621 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,386 software developers and data experts.

Fix Failure result due to no records found

I have a query that takes blobs that have been created within the last
day out of sql server and places them on a disk drive. The query is a
stored proc which runs in a DTS job. The job shows failure when there
are no pdf's created in the last day, how do I correct this??
Here is my stored proc code:
CREATE PROCEDURE [dbo].[sp_PDFExport] AS
begin
set quoted_identifier off

declare @pk int

declare @where_clause varchar(100)

declare @file_name varchar (50)

declare @debug varchar (50)

Declare @cmd varchar (50)

--debug

/*if @Debug = 1
print @cmd
exec Master..xp_cmdShell @cmd */
-- begin cursor

DECLARE LOOKUP CURSOR FOR select pr.[id]
from plan_report pr, plan_version pv
where pv.plan_id = pr.plan_id and pv.status = '30' and pr.create_time
>= pv.update_time and pr.create_time (Getdate()-1)
OPEN LOOKUP

FETCH NEXT FROM LOOKUP INTO @pk
-- Loop through the list

WHILE @@FETCH_STATUS = 0

BEGIN
SET @where_clause = 'Where' + '[ID]' + '=' + cast(@pk as
varchar(10))
SET @file_name = 'F:\NPPDFs\'+cast(@pk as varchar(10))+'.pdf'

exec sp_textcopy @srvname = 'MILNPPRODSQL',

@login = 'sa',

@password = '<sa password>',

@dbname = '<db name>',

@tbname = 'Plan_Report',

@colname = 'document',

@filename = @file_name,

@whereclause = @where_clause,

@direction = 'o' -- 'o' for output, 'i' for input

-- loop cursor

SET @pk = NULL

SET @where_clause = NULL

SET @file_name = NULL

FETCH NEXT FROM LOOKUP INTO @pk
END
-- cleanup

CLOSE LOOKUP

DEALLOCATE LOOKUP

end
GO

May 7 '07 #1
4 2314
Connie (cs*****@rwbaird.com) writes:
I have a query that takes blobs that have been created within the last
day out of sql server and places them on a disk drive. The query is a
stored proc which runs in a DTS job. The job shows failure when there
are no pdf's created in the last day, how do I correct this??
Here is my stored proc code:
Yeah, we've seen your stored procedure a couple of times now. :-) But
what about the error message? Does the procedure produce an error? Don't
you get that later on when you try to move the stuff?

Anyway, post the error message and the code that produces it. Then you
may get more than guesses in return.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 7 '07 #2
MC
I dont know where exactly do you get an error and what the error is but in
general you could issue count(*) from the table (same select as in a cursor,
only put count instead of id). Then you can set variable value with the
results of the count. After that, its just handling the package depending on
the var value....
MC
"Connie" <cs*****@rwbaird.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
>I have a query that takes blobs that have been created within the last
day out of sql server and places them on a disk drive. The query is a
stored proc which runs in a DTS job. The job shows failure when there
are no pdf's created in the last day, how do I correct this??
Here is my stored proc code:
CREATE PROCEDURE [dbo].[sp_PDFExport] AS
begin
set quoted_identifier off

declare @pk int

declare @where_clause varchar(100)

declare @file_name varchar (50)

declare @debug varchar (50)

Declare @cmd varchar (50)

--debug

/*if @Debug = 1
print @cmd
exec Master..xp_cmdShell @cmd */
-- begin cursor

DECLARE LOOKUP CURSOR FOR select pr.[id]
from plan_report pr, plan_version pv
where pv.plan_id = pr.plan_id and pv.status = '30' and pr.create_time
>>= pv.update_time and pr.create_time (Getdate()-1)

OPEN LOOKUP

FETCH NEXT FROM LOOKUP INTO @pk
-- Loop through the list

WHILE @@FETCH_STATUS = 0

BEGIN
SET @where_clause = 'Where' + '[ID]' + '=' + cast(@pk as
varchar(10))
SET @file_name = 'F:\NPPDFs\'+cast(@pk as varchar(10))+'.pdf'

exec sp_textcopy @srvname = 'MILNPPRODSQL',

@login = 'sa',

@password = '<sa password>',

@dbname = '<db name>',

@tbname = 'Plan_Report',

@colname = 'document',

@filename = @file_name,

@whereclause = @where_clause,

@direction = 'o' -- 'o' for output, 'i' for input

-- loop cursor

SET @pk = NULL

SET @where_clause = NULL

SET @file_name = NULL

FETCH NEXT FROM LOOKUP INTO @pk
END
-- cleanup

CLOSE LOOKUP

DEALLOCATE LOOKUP

end
GO

May 8 '07 #3
On May 8, 1:00 am, "MC" <marko.culoNOS...@gmail.comwrote:
I dont know where exactly do you get an error and what the error is but in
general you could issue count(*) from the table (same select as in a cursor,
only put count instead of id). Then you can set variable value with the
results of the count. After that, its just handling the package depending on
the var value....

MC

"Connie" <csaw...@rwbaird.comwrote in message

news:11**********************@u30g2000hsc.googlegr oups.com...
I have a query that takes blobs that have been created within the last
day out of sql server and places them on a disk drive. The query is a
stored proc which runs in a DTS job. The job shows failure when there
are no pdf's created in the last day, how do I correct this??
Here is my stored proc code:
CREATE PROCEDURE [dbo].[sp_PDFExport] AS
begin
set quoted_identifier off
declare @pk int
declare @where_clause varchar(100)
declare @file_name varchar (50)
declare @debug varchar (50)
Declare @cmd varchar (50)
--debug
/*if @Debug = 1
print @cmd
exec Master..xp_cmdShell @cmd */
-- begin cursor
DECLARE LOOKUP CURSOR FOR select pr.[id]
from plan_report pr, plan_version pv
where pv.plan_id = pr.plan_id and pv.status = '30' and pr.create_time
>= pv.update_time and pr.create_time (Getdate()-1)
OPEN LOOKUP
FETCH NEXT FROM LOOKUP INTO @pk
-- Loop through the list
WHILE @@FETCH_STATUS = 0
BEGIN
SET @where_clause = 'Where' + '[ID]' + '=' + cast(@pk as
varchar(10))
SET @file_name = 'F:\NPPDFs\'+cast(@pk as varchar(10))+'.pdf'
exec sp_textcopy @srvname = 'MILNPPRODSQL',
@login = 'sa',
@password = '<sa password>',
@dbname = '<db name>',
@tbname = 'Plan_Report',
@colname = 'document',
@filename = @file_name,
@whereclause = @where_clause,
@direction = 'o' -- 'o' for output, 'i' for input
-- loop cursor
SET @pk = NULL
SET @where_clause = NULL
SET @file_name = NULL
FETCH NEXT FROM LOOKUP INTO @pk
END
-- cleanup
CLOSE LOOKUP
DEALLOCATE LOOKUP
end
GO- Hide quoted text -

- Show quoted text -
Sorry here is more detail. Last week we had determined that on step 2
I was experiencing a failure due to loss of connection to our Pegasus
server. This time I got an error on step 1 which is the code above
and here is the error message:
Executed as user: US\svcsqlserver. ...Move /Y F:\NPPDFs\*.* \\Mil-
Pegasus-01\Optical\NaviplanOptical001\The filename, directory name, or
volume label syntax is incorrect.DTSRun: Loading... DTSRun:
Executing... DTSRun OnStart: DTSStep_DTSExecuteSQLTask_1 DTSRun
OnFinish: DTSStep_DTSExecuteSQLTask_1 DTSRun OnStart:
DTSStep_DTSCreateProcessTask_1 DTSRun OnError:
DTSStep_DTSCreateProcessTask_1, Error = -2147220330 (80040496)
Error string: CreateProcessTask 'DTSTask_DTSCreateProcessTask_1':
Process returned code 1, which does not match the specified
SuccessReturnCode of 0. Error source: Microsoft Data
Transformation Services (DTS) Package Help file:
sqldts80.hlp Help context: 4900 Error Detail Records:
Error: -2147220330 (80040496); Provider Error: 0 (0) Error
string: CreateProcessTask 'DTSTask_DTSCreateProcessTask_1': Process
returned code 1, which does not match the specified SuccessReturnCode
of 0. Erro... Process Exit Code 1. The step failed.

Basically the stored proc is runs

DECLARE LOOKUP CURSOR FOR select pr.[id]
from plan_report pr, plan_version pv
where pv.plan_id = pr.plan_id and pv.status = '30' and pr.create_time
>= pv.update_time and pr.create_time (Getdate()-1)
and there are no blobs (PDF's) returned by the select above so the
procedure fails as there are no PDF's to move to (SET @file_name = 'F:
\NPPDFs\'+cast(@pk as varchar(10))+'.pdf') @file_name.

Does that help (or make better sense)

Thanks much :)

May 8 '07 #4
Connie (cs*****@rwbaird.com) writes:
Sorry here is more detail. Last week we had determined that on step 2
I was experiencing a failure due to loss of connection to our Pegasus
server. This time I got an error on step 1 which is the code above
and here is the error message:
Executed as user: US\svcsqlserver. ...Move /Y F:\NPPDFs\*.* \\Mil-
Pegasus-01\Optical\NaviplanOptical001\The filename, directory name, or
volume label syntax is incorrect.DTSRun: Loading... DTSRun:
Executing... DTSRun OnStart: DTSStep_DTSExecuteSQLTask_1 DTSRun
...
Basically the stored proc is runs

DECLARE LOOKUP CURSOR FOR select pr.[id]
from plan_report pr, plan_version pv
where pv.plan_id = pr.plan_id and pv.status = '30' and pr.create_time
= pv.update_time and pr.create_time (Getdate()-1)

and there are no blobs (PDF's) returned by the select above so the
procedure fails as there are no PDF's to move to (SET @file_name = 'F:
\NPPDFs\'+cast(@pk as varchar(10))+'.pdf') @file_name.
I can't see that your stored procedure attempts to perform a MOVE
command, so the code for the procedure does not matter. Apparently
you have something that invokes MOVE in the DTS job. I guess you need
to add a check somewhere in your DTS job so that it does not try to
move any files that aren't there.

Since I don't know what your DTS job looks like, I can't really suggest
how that should be done. Actually, since I have no experience of DTS,
I would probably not be able to anyway.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 8 '07 #5

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

Similar topics

3
by: Margo | last post by:
Hi there I am fairly new to php & MySQL. I have been trying to set up a query and limit the result 12 records per page - 2 columns by 6 rows. Each record contains various fields. I have been...
10
by: x2164 | last post by:
hi all, Linux 2.4.28 Glibc 2.2.5 gcc 2.95.3 I'm new to Python. I've compiled Python 2.4 from tar file.
2
by: nt | last post by:
I am having a problem with a regular backup of an SQL Server (MSDE 2000) database to a local drive. I initiate the backup once a week, by issuing the required T-SQL, via ADO. In this case, the...
4
by: vani | last post by:
HI All, We are working on a search application, where the number of records in the database are in millions. For certain search conditions, the search result results in more than million...
3
by: Dave | last post by:
I have always taken it for granted that once RI is in place, no orphan records can be created, and that RI can't be put in place while orphans exist, but today I came across a situation where that...
24
by: anders | last post by:
Hi! Im trying to add a A record to a domain name in MS DNS with C#, it's done from a webpage with this code: ManagementClass rr = new ManagementClass(@"root\MicrosoftDNS",...
4
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
8
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() {...
5
by: Tony M. | last post by:
I just want to share a discovery. I was using a sub routine to call itself, a recursive loop. In it I used ADO to process records, and I was getting a "Catastrophic Failure", almost always...
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: 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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.