Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for the creation of the DB for Postgres #3

Open
stephane303 opened this issue Jan 21, 2024 · 1 comment
Open

Error for the creation of the DB for Postgres #3

stephane303 opened this issue Jan 21, 2024 · 1 comment

Comments

@stephane303
Copy link

stephane303 commented Jan 21, 2024

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;

@AnghelLeonard
Copy link
Collaborator

I used PostgreSQL 13. I'm glad that you made it work :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants