Error de conversion store procedure
Publicado por Antonio (1 intervención) el 01/05/2010 17:41:56
Hola buenas tardes!
Tengo 2 roblemas iguales en al creacionde 2 store procedures
Estos 2 store procedures trabajan con la BBDD "pubs"
CREATE PROCEDURE sp_incpreullibre
@editorial CHAR(50),@percentatge DECIMAL(4,2)
AS
DECLARE @modificats INT
BEGIN TRANSACTION
IF @editorial=(SELECT COUNT(pub_name) FROM publishers)
BEGIN
UPDATE titles
SET price=(SELECT price*(@percentatge/100) FROM titles t INNER JOIN publishers p ON(t.pub_id=p.pub_id)WHERE pub_name=@editorial)
SET @modificats=(SELECT COUNT(title_id) FROM publishers p INNER JOIN titles t ON(p.pub_id=t.pub_id) WHERE @editorial=pub_name)
END
ELSE
RETURN -1
COMMIT TRANSACTION
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CREATE PROCEDURE sp_infoautor
@autor CHAR(50),
@llibresEscrits INT OUTPUT,@totalVendes DECIMAL(4,2) OUTPUT,@editorialPublicades INT OUTPUT
AS
IF @autor!=(SELECT COUNT(a.au_lname)FROM authors a)
SELECT COUNT(t.title_id)AS TotalLlibres,COUNT(s.qty*t.price)AS TotalVendes,COUNT(p.pub_id)AS TotalEditorials FROM sales s INNER JOIN titles t ON(s.title_id=t.title_id) INNER JOIN publishers p ON(t.pub_id=p.pub_id)
ELSE
BEGIN
SET @llibresEscrits=(SELECT COUNT(t.title_id) FROM titles t INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id) WHERE @autor=a.au_lname)
SET @totalVendes=(SELECT COUNT(s.qty*t.price)FROM sales s INNER JOIN titles t ON(s.title_id=t.title_id)INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id) WHERE @autor=a.au_lname)
SET @editorialPublicades=(SELECT COUNT(p.pub_id)FROM publishers p INNER JOIN titles t ON(p.pub_id=t.pub_id)INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id)WHERE @autor=a.au_lname)
END
Mens 245, Nivel 16, Estado 1, Procedimiento sp_incpreullibre, Línea 8
Error de conversión al convertir el valor varchar 'Bennet
Y no encuentro el error, me quedo atascado aquí.
Muchas gracias a todos.
Saludos!
Tengo 2 roblemas iguales en al creacionde 2 store procedures
Estos 2 store procedures trabajan con la BBDD "pubs"
CREATE PROCEDURE sp_incpreullibre
@editorial CHAR(50),@percentatge DECIMAL(4,2)
AS
DECLARE @modificats INT
BEGIN TRANSACTION
IF @editorial=(SELECT COUNT(pub_name) FROM publishers)
BEGIN
UPDATE titles
SET price=(SELECT price*(@percentatge/100) FROM titles t INNER JOIN publishers p ON(t.pub_id=p.pub_id)WHERE pub_name=@editorial)
SET @modificats=(SELECT COUNT(title_id) FROM publishers p INNER JOIN titles t ON(p.pub_id=t.pub_id) WHERE @editorial=pub_name)
END
ELSE
RETURN -1
COMMIT TRANSACTION
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CREATE PROCEDURE sp_infoautor
@autor CHAR(50),
@llibresEscrits INT OUTPUT,@totalVendes DECIMAL(4,2) OUTPUT,@editorialPublicades INT OUTPUT
AS
IF @autor!=(SELECT COUNT(a.au_lname)FROM authors a)
SELECT COUNT(t.title_id)AS TotalLlibres,COUNT(s.qty*t.price)AS TotalVendes,COUNT(p.pub_id)AS TotalEditorials FROM sales s INNER JOIN titles t ON(s.title_id=t.title_id) INNER JOIN publishers p ON(t.pub_id=p.pub_id)
ELSE
BEGIN
SET @llibresEscrits=(SELECT COUNT(t.title_id) FROM titles t INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id) WHERE @autor=a.au_lname)
SET @totalVendes=(SELECT COUNT(s.qty*t.price)FROM sales s INNER JOIN titles t ON(s.title_id=t.title_id)INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id) WHERE @autor=a.au_lname)
SET @editorialPublicades=(SELECT COUNT(p.pub_id)FROM publishers p INNER JOIN titles t ON(p.pub_id=t.pub_id)INNER JOIN titleauthor ta ON(t.title_id=ta.title_id)INNER JOIN authors a ON(ta.au_id=a.au_id)WHERE @autor=a.au_lname)
END
Mens 245, Nivel 16, Estado 1, Procedimiento sp_incpreullibre, Línea 8
Error de conversión al convertir el valor varchar 'Bennet
Y no encuentro el error, me quedo atascado aquí.
Muchas gracias a todos.
Saludos!
Valora esta pregunta


0