Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Sql Programmer: Help Please

Status
Not open for further replies.

aliiiish

Programmer
Dec 19, 2005
13
CA
Hi Guys,

I am a new programmer and I was given a code to fix....I just would like to know what does this portion of code do (i.e the write flag part):


Description: Exports Style info to flat file.
CREATE PROCEDURE dbo.msp_EIExportStyleCornell
@intSessionNo int
, @intType int -- 0 = Write output file; 1 = SELECT for output
, @intExportCount int = NULL
AS
SET NOCOUNT ON

DECLARE @chvCmdLine varchar(1024)
, @chvPath varchar(512)
, @chvDateStamp varchar(8)
, @chvFileName varchar(50)
, @intIDENT int
, @chvFileWrite varchar(5)
, @intOriginalCount int
, @chvHeaderValue varchar(5)
, @dteDateValue smalldatetime

-- FILE WRITE FLAG
IF (@intExportCount = 0 OR @intExportCount IS NULL)
BEGIN
SET @chvFileWrite = ' > '
SET @chvHeaderValue = '-1'
SET @intOriginalCount = @intExportCount

END
ELSE
BEGIN
SET @chvFileWrite = ' >> '
SET @chvHeaderValue = '-1'
SET @intOriginalCount = @intExportCount

CREATE TABLE #tmp_Count([intCount] [int])

INSERT INTO #tmp_Count
EXEC(' SELECT MAX(Interface_Out_Id)
FROM(SELECT TOP ' + @intExportCount + ' Interface_Out_Id
FROM Interface_Out
WHERE SessionNo = ' + @intSessionNo + ') TMP ')

SELECT @intExportCount = intCount FROM #tmp_Count
END

IF @intType = 0
BEGIN

-- FILE WRITE FLAG
IF (@intExportCount = 0 OR @intExportCount IS NULL)
BEGIN

-- CREATE FILE NAME
SET @chvDateStamp = RIGHT(DATEPART(yy, getdate()), 2) + RIGHT('0' + CAST(DATEPART(mm, getdate()) as varchar(2)), 2)
+ RIGHT('0' + CAST(DATEPART(dd, getdate()) as varchar(2)), 2)
SELECT @chvFileName = 'style_upc_' + RTRIM(LTRIM(country_cd)) + '_' + @chvDateStamp + '.txt' FROM _Constant

SET @dteDateValue = CONVERT(smalldatetime, CONVERT(varchar(50), DATEPART(mm, getdate()) + '-' + DATEPART(dd, getdate()) + '-' + DATEPART(yy, getdate()) ) )
 
Are you referring to this part?:
Code:
-- FILE WRITE FLAG  
 IF (@intExportCount = 0 OR @intExportCount IS NULL)  
 BEGIN  
  SET @chvFileWrite = ' > '  
  SET @chvHeaderValue = '-1'  
  SET @intOriginalCount = @intExportCount   
  
 END  
 ELSE  
 BEGIN  
  SET @chvFileWrite = ' >> '  
  SET @chvHeaderValue = '-1'  
  SET @intOriginalCount = @intExportCount

This code is simply setting some variable values based on previous variable results.

Jim


Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top