postgresql

“x is a procedure, use ”call“” when I am already using call

空扰寡人 提交于 2021-02-05 07:09:34
问题 I'm using Postgres 12 and have written this procedure: CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER) LANGUAGE plpgsql AS $$ BEGIN UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id; END; $$; It works perfectly if I open up psql on the command line and run call reduceStock(1,1); However, calling it from my Java program as follows: CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}"); stmt.setInt(1,

“x is a procedure, use ”call“” when I am already using call

廉价感情. 提交于 2021-02-05 07:09:23
问题 I'm using Postgres 12 and have written this procedure: CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER) LANGUAGE plpgsql AS $$ BEGIN UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id; END; $$; It works perfectly if I open up psql on the command line and run call reduceStock(1,1); However, calling it from my Java program as follows: CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}"); stmt.setInt(1,

In NodeJS how to save JSON object as text with node-postgres module?

故事扮演 提交于 2021-02-05 05:51:10
问题 Finally i move forward from postgresql 9.1 to postresql 9.3 that supports JSON data type. Then the same code function properly. However i think that what i want to do in the first place can be done... if someone know how i still want to know. Enviroment node v0.10.28 pg v3.3.0 postgresql 9.1 I got this insert query INSERT INTO sessions(sid, user_id, session_object) VALUES ('id1', 1, '{"id":"fX2HkXYLclB","data": testing"}') RETURNING session_id When testing it from pgAdmin (or command line) it

In NodeJS how to save JSON object as text with node-postgres module?

三世轮回 提交于 2021-02-05 05:51:08
问题 Finally i move forward from postgresql 9.1 to postresql 9.3 that supports JSON data type. Then the same code function properly. However i think that what i want to do in the first place can be done... if someone know how i still want to know. Enviroment node v0.10.28 pg v3.3.0 postgresql 9.1 I got this insert query INSERT INTO sessions(sid, user_id, session_object) VALUES ('id1', 1, '{"id":"fX2HkXYLclB","data": testing"}') RETURNING session_id When testing it from pgAdmin (or command line) it

Is there a configuration for removing LiquiBase DATABASE CHANGELOGLOCK automatically after a certain time or on app restart?

北战南征 提交于 2021-02-04 21:51:22
问题 We have SpringBoot 2 driven HA java application in which we use PostgreSQL underneath. For certain reasons like unexpected crashes or Exceptions, Liquibase ends up with a stale DATABASECHANGELOGLOCK which was never released. This results in subsequent deployments of the app failing with app waiting for the change lock and then exiting as follows: 2020-03-04T11:10:31.78+0200 SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1 2020-03-04T11:10:31.78+0200 Waiting for changelog lock....

Is there a configuration for removing LiquiBase DATABASE CHANGELOGLOCK automatically after a certain time or on app restart?

故事扮演 提交于 2021-02-04 21:50:05
问题 We have SpringBoot 2 driven HA java application in which we use PostgreSQL underneath. For certain reasons like unexpected crashes or Exceptions, Liquibase ends up with a stale DATABASECHANGELOGLOCK which was never released. This results in subsequent deployments of the app failing with app waiting for the change lock and then exiting as follows: 2020-03-04T11:10:31.78+0200 SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1 2020-03-04T11:10:31.78+0200 Waiting for changelog lock....

PSQL [error] - value being recognized as a column

微笑、不失礼 提交于 2021-02-04 21:36:34
问题 I just started learning database a couple of days ago. I'm running into this problem where my value is being recognized as a column, and it's spitting out an error. This is my News table: id | bodyText | url | createdAt | updatedAt ----+----------+-----+-----------+----------- this is the command I ran in psql: INSERT INTO "News" ("bodyText") VALUES ("this is a test"); and this is the error I'm getting: ERROR: column "this is a test" does not exist LINE 1: INSERT INTO "News" ("bodyText")

PSQL [error] - value being recognized as a column

孤人 提交于 2021-02-04 21:36:03
问题 I just started learning database a couple of days ago. I'm running into this problem where my value is being recognized as a column, and it's spitting out an error. This is my News table: id | bodyText | url | createdAt | updatedAt ----+----------+-----+-----------+----------- this is the command I ran in psql: INSERT INTO "News" ("bodyText") VALUES ("this is a test"); and this is the error I'm getting: ERROR: column "this is a test" does not exist LINE 1: INSERT INTO "News" ("bodyText")

Quicksight custom query postgresql functions

亡梦爱人 提交于 2021-02-04 20:59:22
问题 I'm trying to create a DataSet for a Quicksight analysis. I'm using a custom query on a Postgresql Data Source. Problem comes whenever I use Postgresql functions inside my query. The same query does, in fact, work on IntelliJ DataGrip and PgAdmin, for example, but I get a pretty unexpected error that states as follows: QuickSight could not generate any output column after applying transformation. Check transform(s) and try again. SELECT users.name AS "User", accounts.id AS "Account ID",

Why postgres returns unordered data in select query, after updation of row?

折月煮酒 提交于 2021-02-04 19:13:27
问题 I am bit confused over default ordering of the rows returned by postgres. postgres=# select * from check_user; id | name ----+------ 1 | x 2 | y 3 | z 4 | a 5 | c1\ 6 | c2 7 | c3 (7 rows) postgres=# update check_user set name = 'c1' where name = 'c1\'; UPDATE 1 postgres=# select * from check_user; id | name ----+------ 1 | x 2 | y 3 | z 4 | a 6 | c2 7 | c3 5 | c1 (7 rows) Before any updation, it was returning rows ordered by id, but after updation, the order has changed. So my question is