CREATE PROCEDURE [dbo].[spSubmitPollRecord]
	@option_id	int,
	@user_id varchar(50)
AS
BEGIN
	DECLARE @votes int, @success BIT
	SET @success = 0
	BEGIN TRANSACTION
		INSERT INTO tblPollRecord (
			option_id,
			user_id
			) 
		VALUES(
			@option_id,
			@user_id
			)
		IF @@ERROR = 0
		BEGIN	
			SELECT @votes = option_votes FROM tblPollOption
			WHERE option_id = @option_id
			UPDATE tblPollOption SET option_votes = (@votes+1)
			WHERE option_id = @option_id
			IF @@ERROR = 0 
				SELECT @success = 1
		END
	IF @success = 1
	BEGIN
		COMMIT TRANSACTION
	END
	ELSE
	BEGIN
		ROLLBACK TRANSACTION
	END
END
