Re: conditionally terminate psql script

2018-12-18 Thread Torsten Förtsch
On Mon, Dec 17, 2018 at 2:07 PM wrote: > many thanks -- too bad I am still using 9.3 > > not sure if it has been mentioned in the thread so far. But according to the docs, 9.3 psql does support the \gset command. So you should be able to do something like this: select case when exists (select 1

Re: conditionally terminate psql script

2018-12-18 Thread David G. Johnston
On Tue, Dec 18, 2018 at 2:44 PM Steven Lembark wrote: > > there is a \if statement > > Q: What is the "abort cycle command"? [...] > \if :lacks_rows > > \echo foobar lacks rows to process. > \echo goodnight :-) > > ?<--- what goes here to stop execution?

Re: conditionally terminate psql script

2018-12-18 Thread Steven Lembark
On Mon, 17 Dec 2018 13:42:14 +0100 Pavel Stehule wrote: > you need psql from PostgreSQL 10 and higher > > there is a \if statement Q: What is the "abort cycle command"? e.g., select count(1) < 1 as "lacks_rows"; fromfoobar where blah blah \gset \if :lacks_rows

Re: Problem with text search in Postgresql 10

2018-12-18 Thread Tom Lane
Howard News writes: > If I try: > select to_tsquery('english', 'hello'); > I get the error > ERROR:  invalid input syntax for type oid: "english" Huh, should work. What does "\df *.to_tsquery" show? > Any ideas how to fix this? I have read in older support forums that the > problem may be

Problem with text search in Postgresql 10

2018-12-18 Thread Howard News
Hi everyone, a colleague has restored a backup from an older version of Postgres (unknown) to version 10. Everything appears to be working fine with the exception of the text search. If I try: select to_tsquery('english', 'hello'); I get the error ERROR:  invalid input syntax for type

Re: Format an Update with calculation

2018-12-18 Thread Ron
Bret, That's just an example of how to use Postgres' cast syntax.  You'd write: UPDATE im_ci_item_transfer    SET suggested_retail_price=(suggested_retail_price + (suggested_retail_price * .13))::numeric(7,2) WHERE item_code='0025881P2'; I prefer the round() function, though. On 12/18/2018

Re: Format an Update with calculation

2018-12-18 Thread Bret Stern
Thanks again, I don't remember ever using a select in an update. Not sure how to use a select in an update, I'll google around. On Tue, 2018-12-18 at 08:18 +0100, Pavel Stehule wrote: > > > > út 18. 12. 2018 v 8:15 odesílatel Bret Stern > napsal: > > My statement below updates the

Re: IF NOT EXIST

2018-12-18 Thread Adrian Klaver
On 12/18/18 12:02 AM, Alban Hertroys wrote: On 18 Dec 2018, at 7:10, Igor Korot wrote: Hi, ALL, I have a following statement: IF NOT EXIST( SELECT 1 SELECT 1 FROM pg_proc AS proc, pg_namespace AS ns ) CREATE FUNCTION(); Unfortunately trying to execute it thru the ODBC interface with: ret

Re: Format an Update with calculation

2018-12-18 Thread Adrian Klaver
On 12/17/18 11:14 PM, Bret Stern wrote: My statement below updates the pricing no problem, but I want it to be formatted with 2 dec points eg (43.23). Started playing with to_numeric but can't figure it out. Lots of examples with to_char in the manual, but still searching for answer. Can it

Re: Format an Update with calculation

2018-12-18 Thread Andrew Gierth
> "Bret" == Bret Stern writes: Bret> My statement below updates the pricing no problem, but I want it Bret> to be formatted with 2 dec points eg (43.23). UPDATE ... SET suggested_retail_price = round(suggested_retail_price*1.13, 2) WHERE ... assuming suggested_retail_price is already

Re: How to insert bulk data with libpq in C?

2018-12-18 Thread Chris Mair
May I ask the proper (fast) way of inserting bulk data and if possible, an example would be very appreciated. Please note that the data I would like to insert contains arrays (float8[]). By the way, my environment is Windows 10, PostgreSQL 11 and compiling with Visual Studio 2017. That

Re: How to insert bulk data with libpq in C?

2018-12-18 Thread Laurenz Albe
Chris Mair wrote: > > > May I ask the proper (fast) way of inserting bulk data and if possible, > > > an example would be very appreciated. > > > > > > Please note that the data I would like to insert contains arrays > > > (float8[]). > > > > > > By the way, my environment is Windows 10,

Re: How to insert bulk data with libpq in C?

2018-12-18 Thread Chris Mair
May I ask the proper (fast) way of inserting bulk data and if possible, an example would be very appreciated. Please note that the data I would like to insert contains arrays (float8[]). By the way, my environment is Windows 10, PostgreSQL 11 and compiling with Visual Studio 2017. That

Re: How to insert bulk data with libpq in C?

2018-12-18 Thread Laurenz Albe
a wrote: > May I ask the proper (fast) way of inserting bulk data and if possible, an > example would be very appreciated. > > Please note that the data I would like to insert contains arrays (float8[]). > > By the way, my environment is Windows 10, PostgreSQL 11 and compiling with > Visual

Re: IF NOT EXIST

2018-12-18 Thread Alban Hertroys
> On 18 Dec 2018, at 7:10, Igor Korot wrote: > > Hi, ALL, > I have a following statement: > > IF NOT EXIST( SELECT 1 SELECT 1 FROM pg_proc AS proc, pg_namespace AS > ns ) CREATE FUNCTION(); > > Unfortunately trying to execute it thru the ODBC interface with: > > ret = SQLExecDirect(