You're setting the value after you call the insert.

Do this instead...
set @Requested = 1   <--- I put it here, but it doesn't work
Insert into CallingCardInfo(CustomerUID, Requested)
Values(@CustomerUID, @Requested)


On 11/8/05, sas0riza <[EMAIL PROTECTED]> wrote:
> HI,
>
> I have a SP where I do 2 insertions. The first one inserts the first
> record and the second one, inserts the second record using the PK
> from the first record (which goes into a second table).  I have all
> of this, but my question is:
>
> How/where do I set the value for a column in the second table?
>
> Here's my code:
>
> CREATE procedure sp_InsertNewCard
> @Title varchar(5),
> @LastName varchar(50),
> @FirstName varchar(50),
> @MiddleInitial char(1),
> @Email varchar(200),
> @Phone varchar(12),
> @PhoneExt varchar(10),
> @Error_Code int OUTPUT
>
> as
> declare
> @SQLErrorCode int,
> @CustomerUID int,
> @Requested bit
>
> begin tran InsertNewCard
>
> -- Step 1: Insert the first record
> Insert into Cardholders(Title, LastName, FirstName, MiddleInitial,
> Email, Phone, PhoneExt)
> Values(@Title, @LastName, @FirstName, @MiddleInitial, @Email,
> @Phone, @PhoneExt)
>
> -- Now check for any errors
> Select @SQLErrorCode = @@Error
>
> -- Get the PK for this new record
> Select @CustomerUID = @@identity
>
> -- If we have an error, set the variable and return it, and rollback
> transaction
> if @SQLErrorCode <> 0
> begin
>         rollback tran InsertNewCard
>         set @Error_Code = 1
>         return
> end
>
> -- Step 2: Insert the second record using the PK from the first
> record inserted above
> Insert into CallingCardInfo(CustomerUID, Requested)
> Values(@CustomerUID, @Requested)
>
> set @Requested = 1   <--- I put it here, but it doesn't work
>
> -- Now check for any errors
> Select @SQLErrorCode = @@Error
>
> -- If we have an error, set the variable and return it, and rollback
> transaction
> if @SQLErrorCode <> 0
> begin
>         rollback tran InsertNewCard
>         set @Error_Code = 2
>         return
> end
>
> -- If we have it this far, then the transaction was successful
> commit tran InsertNewCard
> set @Error_Code = 0
> return
> GO
>
>
>
>
> Any help is greatly appreciated.
>
> Thanks!
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>


--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to