I have code like this:
CREATE FUNCTION gantistok (@id VARCHAR(8),
@id_t INT)
RETURNS INT
BEGIN
DECLARE @tahu INT,
@tempe INT,
@hasil INT;
SELECT @tahu = CONVERT(INT, stok)
FROM barang
WHERE id_barang = @id;
SELECT @tempe = CONVERT(INT, jumlah)
FROM det_trans
WHERE id_det_trans = @id_t;
SET @hasil = @tahu - @tempe;
RETURN @hasil
END
Why doesn’t it work? I am getting this error:
Msg 402, Level 16, State 1, Procedure gantistok, Line 5
The data types text and varchar are incompatible in the equal to operator.
you are using wrong syntax
it should be
CONVERT(expr,type)and type must be
SIGNED[INTEGER]REFERENCE