Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2006, 02:26 PM
Registered User
 
Join Date: Apr 2006
Location: Temple Hills, MD, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to garrydawkins Send a message via Yahoo to garrydawkins
Default erron handling


Hey Gang, I have a number of errors. Can someone help.
Server: Msg 170, Level 15, State 1, Procedure swr_get_work_requ, Line 28
Line 28: Incorrect syntax near '@LOG_PK'.
Server: Msg 170, Level 15, State 1, Procedure swr_get_work_requ, Line 33
Line 33: Incorrect syntax near 'LOG_PK'.
Server: Msg 137, Level 15, State 1, Procedure swr_get_work_requ, Line 49
Must declare the variable '@LOG_PK'.
Server: Msg 137, Level 15, State 1, Procedure swr_get_work_requ, Line 52
Must declare the variable '@LOG_PK'.
Server: Msg 137, Level 15, State 1, Procedure swr_get_work_requ, Line 54
Must declare the variable '@LOG_PK'.
Server: Msg 170, Level 15, State 1, Procedure swr_get_work_requ, Line 61
Line 61: Incorrect syntax near 'whatevertemptablenameis'.
Server: Msg 137, Level 15, State 1, Procedure swr_get_work_requ, Line 64
Must declare the variable '@Rtn_Code'.

Code:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[swr_get_work_requ]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[swr_get_work_requ]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.swr_get_work_requ
-----------------------------------------------------------------------------------------
-- DESCRIPTION: Saves a Work Order Trade for a Work Order into f_WO_Trades
-- Outputs:
-- Two output fields
-- WOT_PK int Primary Key of Work Request Trade.
-- Being returned as output parm instead of recordset so it's easier
-- to use value inside other stored procedures.
-- RTN_CODE int 0 = success.
-- $Header: X:\\cvsroot/SOB/Database/TMA/script/swr_get_work_requ.sql,v 1.1 2006/04/08 17:27:27 hstaples Exp $
-- $Revision: 1.1 $
-- $Date: 2006/04/08 17:27:27 $
-- $Log: swr_get_work_requ.sql,v $
-- Revision 1.1 2006/04/08 17:27:27 hstaples
-- Initial CheckIn. Tested OK.
--
-----------------------------------------------------------------------------------------

( @Effective_Date datetime
)

AS
SELECT


DECLARE @LOG_PK int
DECLARE @SWR_STATUS varchar(45)
SET @SWR_STATUS = ''

-- TODO: Create temp table (wide enough to hold all fields in SELECT)
LOG_PK,
LOG_REQUESTOR,
LOG_REQ_PHONE,
LOG_CHAR_60_1,
LOG_CHAR_30_4,
LOG_CN_FK,
LOG_CREATE_DATE,
LOG_REQUEST,
(LOG_STATUS),
'TBD' As LOG_TYPE,
LOG_FU_FK,
LOG_FB_PK,
LOG_LT_FK,
LOG_CREATE_DATE

DECLARE crsLog As SELECT LOG_PK FROM f_Requests
FETCH NEXT FROM crsLog INTO @LOG_PK
WHILE @@FETCH_STATUS <> -1
BEGIN
    EXEC swr_get_work_requ_stat @LOG_PK, @SWR_STATUS out
    -- TODO; INSERT RECORD INTO TEMPTABLE, all other fields and the value @SWR_STATUS plugged into the field @LOG_STATUS
    FETCH NEXT FROM crsLog INTO @LOG_PK
END
CLOSE crsLog
DEALLOCATE crsLog

-- Return Result Set
SELECT * FROM whatevertemptablenameis ORDER BY LOG_PK
DROP whatevertemptablenameis

-- TODO: Set Return Code
SET @Rtn_Code = -990

GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO



Garry Dawkins
 
Old April 10th, 2006, 03:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

There are a number of invalid statements in this stored procedure definition:

1. What's that SELECT doing there all by itself after the AS clause?

2. What are all those LOG... lines doing after the single line comment -- TODO...?

3. What is that DECLARE crslog ... statement doing? It is certainly not declaring any datatype (e.g. CURSOR, etc).

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com




Similar Threads
Thread Thread Starter Forum Replies Last Post
File handling vijayma VB How-To 3 June 7th, 2006 01:30 AM
Handling SqlServer bijgupt ASP.NET 1.0 and 1.1 Professional 4 May 29th, 2006 12:20 AM
Error Handling twbit BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 3rd, 2005 09:18 PM
error handling Abhinav_jain_mca SQL Server 2000 1 August 24th, 2004 06:13 AM
Cookie Handling mahulda General .NET 1 August 23rd, 2004 06:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.