[PHP/MSSQL]Stored procedure problem
First of all HELLO,
For mine website i need to call this stored procedure,
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
/****** Object: Stored Procedure dbo.spWebReplyClanBoard Script Date: 5/10/2007 3:42:10 PM ******/
--------------------------------------------------------------------------------------------------------
-- 게시물 답글
ALTER PROC [dbo].[spWebReplyClanBoard]
@Seq int,
@UserID varchar(20),
@Subject varchar(50),
@Content varchar(4000),
@FileName varchar(128),
@Link varchar(255),
@HTML smallint,
@GR_ID int,
@GR_Depth int,
@GR_Pos int
AS
SET NOCOUNT ON
DECLARE @CLID int
DECLARE @ParentThread int
DECLARE @PrevThread int
SELECT @CLID = CLID FROM ClanBoard(NOLOCK) Where Seq = @Seq
SELECT @ParentThread = Thread FROM ClanBoard(NOLOCK) Where Seq = @Seq
SELECT @PrevThread = @ParentThread -1000 FROM ClanBoard(NOLOCK) where GR_ID =@GR_ID and GR_Depth = '0'
BEGIN TRAN
UPDATE ClanBoard
SET Thread = Thread - 1
Where Thread < @ParentThread and Thread > @PrevThread
IF (@@ERROR <> 0) BEGIN
ROLLBACK TRAN
RETURN
END
UPDATE ClanBoard SET GR_Pos =GR_Pos+1
WHERE GR_ID = @GR_ID and GR_Pos = @GR_Pos
IF (@@ERROR <> 0) BEGIN
ROLLBACK TRAN
RETURN
END
SET @GR_Depth = @GR_Depth+1;
SET @GR_Pos = @GR_Pos + 1;
INSERT INTO ClanBoard (CLID, UserID, Subject, Content, Regdate, ReadCount, FileName, Link, HTML, GR_ID, GR_Depth, GR_Pos, Thread)
VALUES (@CLID, @UserID, @Subject, @Content, GetDate(), 0, @FileName, @Link, @HTML, @GR_ID, @GR_Depth, @GR_Pos, @ParentThread-1)
IF (@@ERROR <> 0) BEGIN
ROLLBACK TRAN
RETURN
END
COMMIT TRAN
But when i use this query
Code:
{mssql_query("
DECLARE @RC int
DECLARE @Seq int
DECLARE @UserID varchar(20)
DECLARE @Subject varchar(50)
DECLARE @Content varchar(4000)
DECLARE @FileName varchar(128)
DECLARE @Link varchar(255)
DECLARE @HTML smallint
DECLARE @GR_ID int
DECLARE @GR_Depth int
DECLARE @GR_Pos int
DECLARE @CLID int
EXECUTE @RC = [$DB].[dbo].[spWebReplyClanBoard]
@Seq = '".$_SESSION['seq']."'
,@UserID = '".$user."'
,@Subject = '".$sub."'
,@Content = '".$messs."'
,@FileName = '0'
,@Link = '0'
,@HTML = '0'
,@GR_ID = '0'
,@GR_Depth = '0'
,@GR_Pos = '0'"); ?> <meta http-equiv="refresh" content="1;URL=boardcontent.php?show=<? echo $_SESSION['seq'] ; ?>
I will get an error of that CLID must be declared, when i added CLID to mine declaration i will get cannot insert NULL value for CLID??
Does someone have some expertice with this??
Sorry for mine English,
Re: [PHP/MSSQL]Stored procedure problem
Because it's NULL, lol.
Check the result of this query:
Code:
SELECT @CLID = CLID FROM ClanBoard(NOLOCK) Where Seq = @Seq
Re: [PHP/MSSQL]Stored procedure problem
I check the stored procedure in the database and if i run it there its OK.
But i found it out. The value $_SESSION['Seq'] wasn't correct. The page had an value of 0 there. So the procedure run it with @Seq = '0'.
The Result for CLID = NULL after that. So error.
SOLVED Maybe closed