You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Postgres 12, and I had to modify your script located here db\migration\dev\postgresql\V1.1__Create.sql to make it work:
CREATE OR REPLACE FUNCTION "update_msrp" (IN "id" BIGINT, IN "debit" INT)
RETURNS REAL
AS $$
UPDATE "public"."product"
SET "msrp" = "public"."product"."msrp" - "debit"
WHERE "public"."product"."product_id" = "id"
RETURNING "public"."product"."msrp";
$$ LANGUAGE sql;
=>
ERROR: Actual return type is numeric.return type mismatch in function declared to return real
ERROR: return type mismatch in function declared to return real
SQL state: 42P13
Detail: Actual return type is numeric.
Context: SQL function "update_msrp"
The following is working
CREATE OR REPLACE FUNCTION "update_msrp" (IN "id" BIGINT, IN "debit" INT)
RETURNS NUMERIC
AS $$
UPDATE "public"."product"
SET "msrp" = "public"."product"."msrp" - "debit"
WHERE "public"."product"."product_id" = "id"
RETURNING "public"."product"."msrp";
$$ LANGUAGE sql;
The text was updated successfully, but these errors were encountered:
I am using Postgres 12, and I had to modify your script located here db\migration\dev\postgresql\V1.1__Create.sql to make it work:
CREATE OR REPLACE FUNCTION "update_msrp" (IN "id" BIGINT, IN "debit" INT)
RETURNS REAL
AS $$
UPDATE "public"."product"
SET "msrp" = "public"."product"."msrp" - "debit"
WHERE "public"."product"."product_id" = "id"
RETURNING "public"."product"."msrp";
$$ LANGUAGE sql;
=>
ERROR: Actual return type is numeric.return type mismatch in function declared to return real
ERROR: return type mismatch in function declared to return real
SQL state: 42P13
Detail: Actual return type is numeric.
Context: SQL function "update_msrp"
The following is working
CREATE OR REPLACE FUNCTION "update_msrp" (IN "id" BIGINT, IN "debit" INT)
RETURNS NUMERIC
AS $$
UPDATE "public"."product"
SET "msrp" = "public"."product"."msrp" - "debit"
WHERE "public"."product"."product_id" = "id"
RETURNING "public"."product"."msrp";
$$ LANGUAGE sql;
The text was updated successfully, but these errors were encountered: