psql

“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,

psql authentication fails with --host=localhost

半城伤御伤魂 提交于 2021-01-29 05:30:42
问题 With the command: psql --dbname=mattermost --username=mmuser --password then if I place the password it succeeds, but if I write: psql --host=localhost --dbname=mattermost --username=mmuser --password then the same password gives authentication fails How can I resolve this? 回答1: So in this one try using psql --host=127.0.0.1 --dbname=mattermost --username=mmuser --password check the pg_hba.conf for further info. So if below line in your pg_hba.conf file host all all localhost trust then it

Is there a way to set the max width of a column when displaying JSONB results in psql?

大兔子大兔子 提交于 2021-01-28 09:15:37
问题 I have a problem that is somewhat similar to this question: Is there a way to set the max width of a column when displaying query results in psql?. I have a number of tables in Postgres with large JSONB documents. When I use psql from Emacs, it grinds to a halt trying to display fields with these documents. Ideally, I just want to see the first X characters of a document when I select * from a given table. I tried: \pset columns 20 To no avail. Is there some permutation of columns and format

Is there a way to set the max width of a column when displaying JSONB results in psql?

耗尽温柔 提交于 2021-01-28 09:11:01
问题 I have a problem that is somewhat similar to this question: Is there a way to set the max width of a column when displaying query results in psql?. I have a number of tables in Postgres with large JSONB documents. When I use psql from Emacs, it grinds to a halt trying to display fields with these documents. Ideally, I just want to see the first X characters of a document when I select * from a given table. I tried: \pset columns 20 To no avail. Is there some permutation of columns and format

Trying to use “\i [filename]” in psql, getting “invalid argument”

落花浮王杯 提交于 2020-12-07 08:33:07
问题 Using Windows 10, Postgres 11. I have a file C:\Users\myname\some path\query.sql containing a typical SELECT query: select a.id,m.toagentid,m.maxstart from agent a left join mostrecentfromtopair m on a.id=m.fromagentid When I'm in the psql terminal, and I try to run this query as follows: \i "C:\Users\myname\some path\query.sql" then I get this error: \i: Invalid argument How should I be running this .SQL file? 回答1: You can use single quotes and slashes: \i 'C:/Users/myname/some path/query