Click here to Skip to main content
15,912,021 members
Home / Discussions / Database
   

Database

 
GeneralRe: adding row to database Pin
Frank Kerrigan11-Oct-06 5:33
Frank Kerrigan11-Oct-06 5:33 
GeneralRe: adding row to database Pin
Dave Sexton11-Oct-06 20:40
Dave Sexton11-Oct-06 20:40 
QuestionDB Design Pin
monrobot138-Oct-06 14:44
monrobot138-Oct-06 14:44 
AnswerRe: DB Design Pin
i.j.russell9-Oct-06 0:09
i.j.russell9-Oct-06 0:09 
AnswerRe: DB Design Pin
Colin Angus Mackay9-Oct-06 3:30
Colin Angus Mackay9-Oct-06 3:30 
GeneralRe: DB Design Pin
monrobot139-Oct-06 8:12
monrobot139-Oct-06 8:12 
Questionwriting a stored procedure which makes multiple insertions-- need help Pin
Rocky#8-Oct-06 1:06
Rocky#8-Oct-06 1:06 
AnswerRe: writing a stored procedure which makes multiple insertions-- need help Pin
yahao8-Oct-06 11:37
yahao8-Oct-06 11:37 
there has two mistake in your code:
1.missing a right bracket at the end of "Select @avialbleQty = (..."
2.the var @availableQty is not equal definition

Smile | :)

The code after DEBUG:

CREATE PROCEDURE dbo.BranchBillDetailInsertCombo
(
@BillID numeric(18),
@Quantity int,
@Serial varchar(30),
@prodLineID numeric(18),
@ManID numeric(18),
@ModelID numeric(18),
@PresentAT numeric(18),
@Error_code INT OUTPUT
)
AS
DECLARE @counter int
DECLARE @availableQty int
DECLARE @PurchID numeric(18)

DECLARE purch_cursor CURSOR FOR
SELECT purchid FROM vu_unsoldproducts
WHERE prodLineID = @prodLineID
AND Manid = @Manid
AND ModelID = @ModelID
AND Upper(Serial) = Upper(Serial)
AND presentAT = @presentAT

Select @availableQty = (select count(*) AvailableQty FROM vu_unsoldproducts
Group by serial, prodlineid, manid, modelid
HAVING
prodlineid = @prodLineID
AND
manid = @manid
AND
modelid = @modelID
AND
UPPER(serial) = UPPER(@Serial))

SET @Error_code = 0 -- means there is no error in executing the stored procedure

IF @Quantity >@availableQty
BEGIN
SET @ERROR_CODE = -1
--return -- dubious statement... I dont know the syntax for that.
END

ELSE
BEGIN
OPEN purch_cursor
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert INTO branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)

SET @counter = 1

WHILE (@@FETCH_STATUS = 0) OR (@Counter < @Quantity)
BEGIN
SET @counter = @counter + 1
-- @counter++
FETCH NEXT FROM purch_cursor
INTO @PurchID
Insert InTo branchBillDetail(BillID, purchID)
Values (@BillID, @purchID)

END


CLOSE purch_cursor

DEALLOCATE purch_Cursor
END
GeneralRe: writing a stored procedure which makes multiple insertions-- need help Pin
Rocky#9-Oct-06 7:46
Rocky#9-Oct-06 7:46 
GeneralRe: writing a stored procedure which makes multiple insertions-- need help Pin
yahao9-Oct-06 23:14
yahao9-Oct-06 23:14 
GeneralRe: writing a stored procedure which makes multiple insertions-- need help Pin
yahao9-Oct-06 23:32
yahao9-Oct-06 23:32 
Questionneed help in Stored procedure for inserting multiple records Pin
Rocky#7-Oct-06 9:17
Rocky#7-Oct-06 9:17 
AnswerRe: need help in Stored procedure for inserting multiple records Pin
Private_Void9-Oct-06 8:33
Private_Void9-Oct-06 8:33 
GeneralRe: need help in Stored procedure for inserting multiple records Pin
Rocky#12-Oct-06 7:52
Rocky#12-Oct-06 7:52 
Questionidentity with one column.... Pin
Amit Kumar G7-Oct-06 6:16
Amit Kumar G7-Oct-06 6:16 
AnswerRe: identity with one column.... Pin
Eric Dahlvang9-Oct-06 3:39
Eric Dahlvang9-Oct-06 3:39 
QuestionHow is this possible? Plz help...... Pin
deepak_rai7-Oct-06 4:36
deepak_rai7-Oct-06 4:36 
AnswerRe: How is this possible? Plz help...... Pin
yahao8-Oct-06 12:07
yahao8-Oct-06 12:07 
Questionhow can i get the deferent between tow dates Pin
ashraf hakiem7-Oct-06 1:59
ashraf hakiem7-Oct-06 1:59 
AnswerRe: how can i get the deferent between tow dates Pin
Rocky#8-Oct-06 1:12
Rocky#8-Oct-06 1:12 
QuestionReg. Connection Pooling Pin
aaraaayen6-Oct-06 20:11
aaraaayen6-Oct-06 20:11 
QuestionQuestion on existing syntax in sql statement Pin
leckey6-Oct-06 10:15
leckey6-Oct-06 10:15 
AnswerRe: Question on existing syntax in sql statement Pin
Mike Osbahr6-Oct-06 10:29
Mike Osbahr6-Oct-06 10:29 
GeneralSQL Server 2005 XML fun Pin
Private_Void6-Oct-06 9:25
Private_Void6-Oct-06 9:25 
Question"Transferring" SQL Server Databases Pin
Brendan Vogt6-Oct-06 2:06
Brendan Vogt6-Oct-06 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.