Re: [GENERAL] Function

2017-10-27 Thread Raymond O'Donnell
On 26/10/17 15:00, Marcio Farah wrote: Good morning for all I´m beginer in PL/pgSQL functions and I have one difficulty. The function bellow should return many records but return just one. The loop just do the first INSERT INTO and get out. If you run SELECT

[GENERAL] Function

2017-10-27 Thread Marcio Farah
Good morning for all I´m beginer in PL/pgSQL functions and I have one difficulty. The function bellow should return many records but return just one. The loop just do the first INSERT INTO and get out. CREATE OR REPLACE FUNCTION geo_output.funcao30(num integer) RETURNS TABLE (quadro_id integer,

Re: [GENERAL] Function to return per-column counts?

2017-09-28 Thread Melvin Davidson
On Thu, Sep 28, 2017 at 3:31 PM, Seamus Abshere wrote: > > > > Does anybody have a function lying around (preferably pl/pgsql) that > > > > takes a table name and returns coverage counts? > > > > > > What is "coverage count"? > > Ah, I should have explained better. I meant

Re: [GENERAL] Function to return per-column counts?

2017-09-28 Thread Seamus Abshere
> > > Does anybody have a function lying around (preferably pl/pgsql) that > > > takes a table name and returns coverage counts? > > > > What is "coverage count"? Ah, I should have explained better. I meant how much of a column is null. Basically you have to 0. count how many total records in a

Re: [GENERAL] Function to return per-column counts?

2017-09-28 Thread John McKown
On Thu, Sep 28, 2017 at 12:15 PM, Tomas Vondra wrote: > > > On 09/28/2017 04:34 PM, Seamus Abshere wrote: > > hey, > > > > Does anybody have a function lying around (preferably pl/pgsql) that > > takes a table name and returns coverage counts? > > > > What is

Re: [GENERAL] Function to return per-column counts?

2017-09-28 Thread Tomas Vondra
On 09/28/2017 04:34 PM, Seamus Abshere wrote: > hey, > > Does anybody have a function lying around (preferably pl/pgsql) that > takes a table name and returns coverage counts? > What is "coverage count"? cheers -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL

[GENERAL] Function to return per-column counts?

2017-09-28 Thread Seamus Abshere
hey, Does anybody have a function lying around (preferably pl/pgsql) that takes a table name and returns coverage counts? e.g. #> select * from column_counts('cats'::regclass); column_name | all_count | present_count | null_count | coverage | --- name | 300 |

Re: [GENERAL] Function not inserting rows

2017-08-23 Thread rob stone
Hello, On Wed, 2017-08-23 at 17:23 +0200, Frank Foerster wrote: > > > > But the created statement looks syntax-wise identical to the pgadmin- > statement (except for the forced error of course): > > select * from api_dev.add_texts_to_item( 444, array['PGADM1', > 'PGADM2'] ); > > > I don't

Re: [GENERAL] Function not inserting rows

2017-08-23 Thread ivay
Thanks, that was it. I did not commit as i was calling "only" a select-statement. Thanks 2017-08-23 18:20 GMT+02:00 Daniele Varrazzo : > On Wed, Aug 23, 2017 at 4:23 PM, Frank Foerster > wrote: > > > Any ideas ? > > commit? > > -- Daniele >

Re: [GENERAL] Function not inserting rows

2017-08-23 Thread Daniele Varrazzo
On Wed, Aug 23, 2017 at 4:23 PM, Frank Foerster wrote: > Any ideas ? commit? -- Daniele -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Function not inserting rows

2017-08-23 Thread David G. Johnston
On Wed, Aug 23, 2017 at 8:23 AM, Frank Foerster wrote: > > sql = "select * from api_dev.add_texts_to_item( %s, %s ); x x" > i get the following python-error: > psycopg2.ProgrammingError: FEHLER: Syntaxfehler bei »s« > LINE 1: ...dd_texts_to_item( 1234,

[GENERAL] Function not inserting rows

2017-08-23 Thread Frank Foerster
Hi, i have the following question: Given an empty database with only schema api_dev in it, a table and a function is created as follows: CREATE TABLE api_dev.item_texts ( item_id integer, item_text text ) WITH ( OIDS=FALSE ); CREATE OR REPLACE FUNCTION api_dev.add_texts_to_item(

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread John R Pierce
On 6/8/2017 6:36 PM, marcinha rocha wrote: |UPDATEtablea a SETmigrated =yes WHEREa.id =row.id;| On my original select, the row will have migrated = false. Maybe All I need to put is a limit 2000 and the query will do the rest? SELECT does not return data in any determinate order unless you

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread David G. Johnston
On Thursday, June 8, 2017, marcinha rocha wrote: > On Thursday, June 8, 2017, marcinha rocha hotmail.com > > > wrote: > >> On my original select, the row will have

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread marcinha rocha
On Thursday, June 8, 2017, marcinha rocha > wrote: On my original select, the row will have migrated = false. Maybe All I need to put is a limit 2000 and the query will do the rest? You shoud try to avoid the for

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread David G. Johnston
On Thursday, June 8, 2017, marcinha rocha wrote: > On my original select, the row will have migrated = false. Maybe All I > need to put is a limit 2000 and the query will do the rest? > > You shoud try to avoid the for loop, but yes a limit 2000 on the for loop

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread marcinha rocha
On 6/8/2017 5:53 PM, marcinha rocha wrote: > Hi guys! I have the following queries, which will basically select > data, insert it onto a new table and update a column on the original > table. I'm sure your example is a gross simplification of what you're really doing, but if that's really all

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread John R Pierce
On 6/8/2017 5:53 PM, marcinha rocha wrote: Hi guys! I have the following queries, which will basically select data, insert it onto a new table and update a column on the original table. I'm sure your example is a gross simplification of what you're really doing, but if that's really all

Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread David G. Johnston
On Thursday, June 8, 2017, marcinha rocha wrote: > When I call the function, it must execute 2000 rows and then stop. Then > when calling it again, it must start from 2001 to 4000, and so on > > You can do this is with plain sql with the help of a CTE. Insert

[GENERAL] Function with limit and offset - PostgreSQL 9.3

2017-06-08 Thread marcinha rocha
Hi guys! I have the following queries, which will basically select data, insert it onto a new table and update a column on the original table. CREATE or REPLACE FUNCTION migrate_data() RETURNS integer; declare row record; BEGIN FOR row IN EXECUTE ' SELECT id

[GENERAL] Function out there to identify pseudo-empty fields, e.g. "n/a", "--", etc?

2017-02-16 Thread Peter Devoy
Hi all Just wondering if anyone has come across a function which can identify typical user-inputted placeholder values? English language is my scope so typical examples would be "not applicable", "n/a", "na", "none", "--", etc. I know it would be trivial to create but no sense in reinventing

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-23 Thread Lucas Possamai
Just an update here: IF (TG_OP = 'INSERT') THEN > UPDATE public.companies SET client_code_increment = > (client_code_increment + 1) WHERE id = NEW.company_id; The line above was updating the client_code_increment even if the customer was inserting data by hiimself, which is wrong. The

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-06 Thread Berend Tober
drum.lu...@gmail.com wrote: It's working now... Final code: ALTER TABLE public.companies ADD COLUMN client_code_increment integer; ALTER TABLE public.companies ALTER COLUMN client_code_increment SET NOT NULL; ALTER TABLE public.companies ALTER COLUMN client_code_increment SET

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread drum.lu...@gmail.com
It's working now... Final code: ALTER TABLE public.companies ADD COLUMN client_code_increment integer; > ALTER TABLE public.companies ALTER COLUMN client_code_increment SET NOT > NULL; > ALTER TABLE public.companies ALTER COLUMN client_code_increment SET > DEFAULT 1000; > COMMIT TRANSACTION; > >

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread Berend Tober
David G. Johnston wrote: ​Berend already identified the problem for you. Thank you. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread Melvin Davidson
On Thu, May 5, 2016 at 6:17 PM, David G. Johnston < david.g.johns...@gmail.com> wrote: > > If I change that to company_id, I get the error: column "company_id" does >> not exist, because that column is inside USERS and not COMPANIES. >> >> > ​change that what is "that" > > ​Provide the

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread David G. Johnston
> If I change that to company_id, I get the error: column "company_id" does > not exist, because that column is inside USERS and not COMPANIES. > > ​change that what is "that" ​Provide the actual code you ran that resulted in "column "company_id" does not exist"​ Your attempts at brevity

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread David G. Johnston
> > > > 2) You have a where clause: company_id = NEW.id >> 3) NEW refers to users >> 4) NEW.id is obstensibly a USER ID >> > > > No... > > ​Which one of the three do you disagree with? ​

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread drum.lu...@gmail.com
> > > 1) You attached users_code_seq() to a trigger on the users table. > yes > 2) You have a where clause: company_id = NEW.id > 3) NEW refers to users > 4) NEW.id is obstensibly a USER ID > No... CREATE OR REPLACE FUNCTION users_code_seq() >RETURNS "trigger" AS $$ > DECLARE code

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread David G. Johnston
On Thu, May 5, 2016 at 1:22 PM, drum.lu...@gmail.com wrote: > > > On 6 May 2016 at 02:29, David G. Johnston > wrote: > >> On Thu, May 5, 2016 at 3:54 AM, Alban Hertroys >> wrote: >> >>> >>> > On 05 May 2016, at 8:42,

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread drum.lu...@gmail.com
On 6 May 2016 at 02:29, David G. Johnston wrote: > On Thu, May 5, 2016 at 3:54 AM, Alban Hertroys wrote: > >> >> > On 05 May 2016, at 8:42, drum.lu...@gmail.com wrote: >> >> > The final function code is: >> > >> > CREATE OR REPLACE FUNCTION

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread David G. Johnston
On Thu, May 5, 2016 at 3:54 AM, Alban Hertroys wrote: > > > On 05 May 2016, at 8:42, drum.lu...@gmail.com wrote: > > > The final function code is: > > > > CREATE OR REPLACE FUNCTION users_code_seq() > >RETURNS "trigger" AS $$ > > DECLARE code character varying; > > BEGIN

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread Alban Hertroys
> On 05 May 2016, at 8:42, drum.lu...@gmail.com wrote: > The final function code is: > > CREATE OR REPLACE FUNCTION users_code_seq() >RETURNS "trigger" AS $$ > DECLARE code character varying; > BEGIN > IF NEW.code IS NULL THEN > SELECT client_code_increment INTO STRICT

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread drum.lu...@gmail.com
> > >> SELECT client_code_increment INTO STRICT NEW.code FROM >> public.companies WHERE id = >> NEW.id ORDER BY client_code_increment DESC; >> > > > > I am pretty sure the above line is wrong. NEW.id refers to users.id, not > the companies.id. Also, the implementation presents a

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread Berend Tober
drum.lu...@gmail.com wrote: I'm just having some problem when doing: INSERT INTO public.users (id,email,encrypted_password,sign_in_count,created_at,updated_at,company_id) VALUES (66,'tes...@test.com ','password','0','2016-05-03 00:01:01','2016-05-03

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-05 Thread drum.lu...@gmail.com
I'm just having some problem when doing: INSERT INTO public.users > (id,email,encrypted_password,sign_in_count,created_at,updated_at,company_id) > VALUES (66,'tes...@test.com','password','0','2016-05-03 > 00:01:01','2016-05-03 00:01:01','15'); - see that I'm not providing the "code" column

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread John R Pierce
On 5/4/2016 9:56 PM, drum.lu...@gmail.com wrote: If I comment the line: *ELSEIF NEW.code IS NULL THEN*, the data is inserted into the users.code column. in the table definition, whats the default value of 'code' ? -- john r pierce, recycling bits in santa cruz

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread drum.lu...@gmail.com
On 5 May 2016 at 16:56, drum.lu...@gmail.com wrote: > CREATE OR REPLACE FUNCTION users_code_seq() >>RETURNS "trigger" AS $$ >> BEGIN >> >> IF (TG_OP = 'INSERT') THEN >> UPDATE public.company_seqs SET last_seq = (last_seq + 1) WHERE >> company_id =

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread drum.lu...@gmail.com
> > CREATE OR REPLACE FUNCTION users_code_seq() >RETURNS "trigger" AS $$ > BEGIN > > IF (TG_OP = 'INSERT') THEN > UPDATE public.company_seqs SET last_seq = (last_seq + 1) WHERE > company_id = NEW.company_id; > > ELSEIF NEW.code IS NULL THEN > SELECT last_seq

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread Berend Tober
David G. Johnston wrote: On Wed, May 4, 2016 at 2:57 PM, drum.lu...@gmail.com ... I would expect a minimum of respect from the members of this list, but seems you got none. If someone would need my help, I'd never insult him/her like you guys are doing. If my questions are too

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread David G. Johnston
On Wed, May 4, 2016 at 2:57 PM, drum.lu...@gmail.com wrote: > >> >> 1) I just may be over-sensitive to this, but after Adrian Klaver referred >> you to a ten-years old post that the above looks an awful lot similar too, >> it sure would be nice to see some attribution >>

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread drum.lu...@gmail.com
> > > > 1) I just may be over-sensitive to this, but after Adrian Klaver referred > you to a ten-years old post that the above looks an awful lot similar too, > it sure would be nice to see some attribution > rather than claiming it as your own with "...what *I* did..." > I would expect a

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-04 Thread Berend Tober
On Tuesday, May 3, 2016, drum.lu...@gmail.com > wrote: * This is what I did... |-- Creating the table CREATE TABLE public.company_seqs (company_id BIGINTNOT NULL, last_seq

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread David G. Johnston
On Tuesday, May 3, 2016, drum.lu...@gmail.com wrote: > >- This is what I did... > > -- Creating the tableCREATE TABLE public.company_seqs(company_id BIGINT NOT > NULL, > last_seq BIGINT NOT NULL DEFAULT 1000,CONSTRAINT company_seqs_pk PRIMARY KEY > (company_id)); > >

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread drum.lu...@gmail.com
- This is what I did... -- Creating the tableCREATE TABLE public.company_seqs(company_id BIGINT NOT NULL, last_seq BIGINT NOT NULL DEFAULT 1000,CONSTRAINT company_seqs_pk PRIMARY KEY (company_id)); -- Creating the function CREATE OR REPLACE FUNCTION users_code_seq() RETURNS "trigger" AS'

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Mike Sofen
From: David G. Johnston Sent: Tuesday, May 03, 2016 2:46 PM To: drum.lu...@gmail.com …The only other reasonable option is change your model and requirements to something less complex. Seriously, get yourself the books I have recommended and study them BEFORE you continue attempting

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread David G. Johnston
On Tue, May 3, 2016 at 5:06 PM, Melvin Davidson wrote: > > > On Tue, May 3, 2016 at 7:53 PM, drum.lu...@gmail.com > wrote: > >> >>> >>> I agree that having thousands of sequences can be hard to manage, >>> especially in a function, but you did not

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Melvin Davidson
On Tue, May 3, 2016 at 7:53 PM, drum.lu...@gmail.com wrote: > >> >> I agree that having thousands of sequences can be hard to manage, >> especially in a function, but you did not state that fact before, >> only that you wanted separate sequences for each company. That >>

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread drum.lu...@gmail.com
> > > > I agree that having thousands of sequences can be hard to manage, > especially in a function, but you did not state that fact before, > only that you wanted separate sequences for each company. That > being said, here is an alternate solution. > Yep.. that was my mistake. > > 1. CREATE

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Melvin Davidson
On Tue, May 3, 2016 at 5:53 PM, Adrian Klaver wrote: > On 05/03/2016 02:27 PM, drum.lu...@gmail.com wrote: > >> >> >> On 4 May 2016 at 01:18, Melvin Davidson > > wrote: >> >> >> >> On Tue, May 3, 2016 at 1:21 AM,

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Adrian Klaver
On 05/03/2016 02:27 PM, drum.lu...@gmail.com wrote: On 4 May 2016 at 01:18, Melvin Davidson > wrote: On Tue, May 3, 2016 at 1:21 AM, David G. Johnston > wrote:

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread David G. Johnston
On Tue, May 3, 2016 at 2:27 PM, drum.lu...@gmail.com wrote: > On 4 May 2016 at 01:18, Melvin Davidson wrote: >> >> On Tue, May 3, 2016 at 1:21 AM, David G. Johnston < >> david.g.johns...@gmail.com> wrote: >> >>> Well.. I don't need to add a

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Adrian Klaver
On 05/03/2016 02:27 PM, drum.lu...@gmail.com wrote: On 4 May 2016 at 01:18, Melvin Davidson > wrote: On Tue, May 3, 2016 at 1:21 AM, David G. Johnston > wrote:

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread drum.lu...@gmail.com
On 4 May 2016 at 01:18, Melvin Davidson wrote: > > > On Tue, May 3, 2016 at 1:21 AM, David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> >>> Well.. I don't need to add a constraint if I already have a default >>> value, that's right... >>> >> >> Wrong >> >> David

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-03 Thread Melvin Davidson
On Tue, May 3, 2016 at 1:21 AM, David G. Johnston < david.g.johns...@gmail.com> wrote: > >> Well.. I don't need to add a constraint if I already have a default >> value, that's right... >> > > Wrong > > David J. > What you need is a TRIGGER function & TRIGGER that will select and assign the

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-02 Thread David G. Johnston
> > > Well.. I don't need to add a constraint if I already have a default value, > that's right... > Wrong David J.

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-02 Thread drum.lu...@gmail.com
On 3 May 2016 at 12:44, drum.lu...@gmail.com wrote: > This is what I've done: > > > -- 1 - Creating the Sequence: > > CREATE SEQUENCE users_code_seq >> INCREMENT 1 >> MINVALUE 1 >> MAXVALUE 9223372036854775807 >> START 1000; >> CACHE 1; > > > -- 2 -

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-02 Thread David G. Johnston
On Mon, May 2, 2016 at 5:44 PM, drum.lu...@gmail.com wrote: > This is what I've done: > > > -- 1 - Creating the Sequence: > > CREATE SEQUENCE users_code_seq >> INCREMENT 1 >> MINVALUE 1 >> MAXVALUE 9223372036854775807 >> START 1000; >> CACHE 1; > > >

Re: [GENERAL] Function PostgreSQL 9.2

2016-05-02 Thread drum.lu...@gmail.com
This is what I've done: -- 1 - Creating the Sequence: CREATE SEQUENCE users_code_seq > INCREMENT 1 > MINVALUE 1 > MAXVALUE 9223372036854775807 > START 1000; > CACHE 1; -- 2 - Setting the DEFAULT ALTER TABLE public.users ALTER COLUMN code SET DEFAULT >

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-21 Thread Karsten Hilbert
On Wed, Apr 20, 2016 at 03:55:50PM -0700, Adrian Klaver wrote: > >If I am following, this duplicates the information in > >companies.client_code_increment, in that they both return the last > >non-user code. Of course this assumes, as David mentioned, that the > >client is not

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread Adrian Klaver
On 04/20/2016 03:33 PM, drum.lu...@gmail.com wrote: If I am following, this duplicates the information in companies.client_code_increment, in that they both return the last non-user code. Of course this assumes, as David mentioned, that the client is not using a numeric code

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread John R Pierce
On 4/20/2016 3:33 PM, drum.lu...@gmail.com wrote: The customer can add any value into users.code: code CHARACTER VARYING, what if he puts in a non-unique value ? But he also can let it blank/null if he wants to. That's when the trigger do its job.. Put a value (starting in 1000) in

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread drum.lu...@gmail.com
> > > > If I am following, this duplicates the information in > companies.client_code_increment, in that they both return the last non-user > code. Of course this assumes, as David mentioned, that the client is not > using a numeric code system. Then you are left trying to figure whether a >

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread David G. Johnston
On Wed, Apr 20, 2016 at 2:51 PM, drum.lu...@gmail.com wrote: > 1 - The customer can add any value into users.code column > 2 - The customer can chose between *add or no**t* add the value on > users.code column > 3 - If users.code is null (because the customer's chosen not

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread John R Pierce
On 4/20/2016 2:51 PM, drum.lu...@gmail.com wrote: 1 - The customer can add any value into users.code column 2 - The customer can chose between *add or no**t* add the value on users.code column 3 - If users.code is null (because the customer's chosen not to add any value in there), a

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread drum.lu...@gmail.com
On 21 April 2016 at 09:44, Adrian Klaver wrote: > On 04/19/2016 07:34 PM, drum.lu...@gmail.com wrote: > >> Information. eg.: >> >> >> The schema for the tables. >> >> Why is not just adding a DEFAULT value to the users.code not an >> option? >> >> >> >> The

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-20 Thread Adrian Klaver
On 04/19/2016 07:34 PM, drum.lu...@gmail.com wrote: Information. eg.: The schema for the tables. Why is not just adding a DEFAULT value to the users.code not an option? The customer can add their own value to the users.code column. That's why I can't have a default value.

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread Mike Sofen
This is such a poorly designed, hacked together “thing” – it isn’t a database, it’s someone’s idea of how to store data when they don’t know how to store data, like they moved it from Access or Excel. Just start over and design a proper relational schema with best practices and you’ll

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread drum.lu...@gmail.com
Just forgot to say: [...] > > >> >> Does increment_client_code relate to users or some other table, say >> clients? >> >> > nope.. there is no link between them > > If the users.code is empty/null, then the trigger has to get the last number from client_code_increment and put on the

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread drum.lu...@gmail.com
> > Information. eg.: > > The schema for the tables. > > Why is not just adding a DEFAULT value to the users.code not an option? > > The customer can add their own value to the users.code column. That's why I can't have a default value. > What the default code should be or how it is to be

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread Adrian Klaver
On 04/19/2016 03:23 PM, drum.lu...@gmail.com wrote: Hi all, I've got two tables: - users - companies I'm trying to create a function that: * if users.code is empty, it gives a default value * And the increment_client_code in company should auto increment for the next client code

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread drum.lu...@gmail.com
On 20 April 2016 at 10:38, David G. Johnston wrote: > On Tue, Apr 19, 2016 at 3:23 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> Hi all, >> >> I've got two tables: >> >> - users >> - companies >> >> I'm trying to create a function that: >> >> >>-

Re: [GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread David G. Johnston
On Tue, Apr 19, 2016 at 3:23 PM, drum.lu...@gmail.com wrote: > Hi all, > > I've got two tables: > > - users > - companies > > I'm trying to create a function that: > > >- if users.code is empty, it gives a default value >- And the increment_client_code in company

[GENERAL] Function PostgreSQL 9.2

2016-04-19 Thread drum.lu...@gmail.com
Hi all, I've got two tables: - users - companies I'm trying to create a function that: - if users.code is empty, it gives a default value - And the increment_client_code in company should auto increment for the next client code What I've done so far: DROP FUNCTION IF EXISTS

Re: [GENERAL] Function fixing - PostgreSQL 9.2

2016-03-01 Thread drum.lu...@gmail.com
> > >>> *Question:* Payments in a Pending state cannot be invoiced and are excluded from the Invoice Runs section, but they are showing in the count mechanic. How can I solve this? >>> >>> ​In 9.2 you probably need to convert the count into a conditional sum: >>> >>>

Re: [GENERAL] Function fixing - PostgreSQL 9.2

2016-02-29 Thread David G. Johnston
On Mon, Feb 29, 2016 at 6:14 PM, drum.lu...@gmail.com wrote: > > > On 1 March 2016 at 11:35, David G. Johnston > wrote: > >> On Mon, Feb 29, 2016 at 2:56 PM, drum.lu...@gmail.com < >> drum.lu...@gmail.com> wrote: >> >>> *Question:* >>> >>>

Re: [GENERAL] Function fixing - PostgreSQL 9.2

2016-02-29 Thread drum.lu...@gmail.com
On 1 March 2016 at 11:35, David G. Johnston wrote: > On Mon, Feb 29, 2016 at 2:56 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> *Question:* >> >> Payments in a Pending state cannot be invoiced and are excluded from the >> Invoice Runs section, but

Re: [GENERAL] Function fixing - PostgreSQL 9.2

2016-02-29 Thread David G. Johnston
On Mon, Feb 29, 2016 at 2:56 PM, drum.lu...@gmail.com wrote: > *Question:* > > Payments in a Pending state cannot be invoiced and are excluded from the > Invoice Runs section, but they are showing in the count mechanic. > > How can I solve this? > ​In 9.2 you probably need

[GENERAL] Function fixing - PostgreSQL 9.2

2016-02-29 Thread drum.lu...@gmail.com
There is a number beside each color flag, and a number in the "sub status" drop down. Instead of "the number of jobs that have billable items that can be invoiced, it shows the "the number of jobs that have "something" billable but not yet invoiced." And since those payments cannot be invoiced

Re: [GENERAL] Function error

2016-01-14 Thread Albe Laurenz
Sachin Srivastava wrote: > In my function the problem is that global variables defined inside the > function. > These variables are visible to functions defined inside a function. > If we move these inner functions to outside of the main function, > they will lose the visibility of the global

Re: [GENERAL] Function error

2016-01-13 Thread Albe Laurenz
Sachin Srivastava wrote: > I am getting the below error for function, please see the bold line in > "Function code", please suggest > what I will do to correct this code. > > --- > > ERROR: syntax error at or near "*" > LINE 35: SELECT * from logError(msg text) is >

[GENERAL] Function error

2016-01-13 Thread Sachin Srivastava
Dear Team, I am getting the below error for function, please see the bold line in "Function code", please suggest what I will do to correct this code. --- ERROR: syntax error at or near "*" LINE 35: SELECT * from logError(msg text) is ^ CONTEXT: invalid

Re: [GENERAL] Function error

2016-01-13 Thread Adrian Klaver
On 01/13/2016 01:18 AM, Sachin Srivastava wrote: > > Dear Team, > > I am getting the below error for function, please see the bold line in > "Function code", please suggest what I will do to correct this code. > > --- > > ERROR: syntax error at or near "*" > LINE 35:

Re: [GENERAL] Function error

2016-01-13 Thread David G. Johnston
On Wed, Jan 13, 2016 at 10:06 PM, Sachin Srivastava wrote: > Dear Albe, > > Thanks for your support !!! > > In my function the problem is that global variables defined inside the > function. These variables are visible to functions defined inside a > function. > ​Holy

Re: [GENERAL] Function error

2016-01-13 Thread Sachin Srivastava
Dear Albe, Thanks for your support !!! In my function the problem is that global variables defined inside the function. These variables are visible to functions defined inside a function. If we move these inner functions to outside of the main function, they will lose the visibility of the

Re: [GENERAL] Function error

2016-01-08 Thread Pavel Stehule
Hi 2016-01-08 8:59 GMT+01:00 Sachin Srivastava : > Hi, > > Also there is any command to see the invalid and valid function in > postgres database. > No, Postgres is not a Oracle. All functions in database are valid. But it means some different than in Oracle. That's

Re: [GENERAL] Function error

2016-01-08 Thread Sachin Srivastava
Hi, I am also getting "syntax error for below function (just some lines of function where I am getting syntax error), please suggest why? -- Image path AND mk1.subscriber_id(+)=pcat_catalog_item.subscriber_id AND

Re: [GENERAL] Function error

2016-01-08 Thread Pavel Stehule
2016-01-08 10:08 GMT+01:00 Sachin Srivastava : > Hi, > > I am also getting "syntax error for below function (just some lines of > function where I am getting syntax error), please suggest why? > Using Oracle's outer join syntax, not ANSI SQL syntax Regards Pavel >

Re: [GENERAL] Function error

2016-01-08 Thread Sachin Srivastava
Hi, Also there is any command to see the invalid and valid function in postgres database. Regards, SS On Fri, Jan 8, 2016 at 1:18 PM, Sachin Srivastava wrote: > Thanks Charles !!! > > On Fri, Jan 8, 2016 at 1:15 PM, Sachin Srivastava >

Re: [GENERAL] Function error

2016-01-08 Thread Sachin Srivastava
Because I have migrated the database from Oracle to Postgres through ORA2PG. So how I will change it, please suggest. On Fri, Jan 8, 2016 at 2:54 PM, Pavel Stehule wrote: > > > 2016-01-08 10:08 GMT+01:00 Sachin Srivastava : > >> Hi, >> >> I am

Re: [GENERAL] Function error

2016-01-08 Thread Pavel Stehule
2016-01-08 10:52 GMT+01:00 Sachin Srivastava : > Because I have migrated the database from Oracle to Postgres through > ORA2PG. > > So how I will change it, please suggest. > http://stackoverflow.com/questions/2269156/converting-from-oracle-join-to-postgres-join > On

Re: [GENERAL] Function error

2016-01-08 Thread Sachin Srivastava
Thanks Pavel for your help !!! On Fri, Jan 8, 2016 at 3:28 PM, Pavel Stehule wrote: > > > 2016-01-08 10:52 GMT+01:00 Sachin Srivastava : > >> Because I have migrated the database from Oracle to Postgres through >> ORA2PG. >> >> So how I will

Re: [GENERAL] Function error

2016-01-07 Thread Charles Clavadetscher
alues returned that you need. Bye Charles > -Original Message- > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Sachin Srivastava > Sent: Freitag, 8. Januar 2016 08:24 > To: pgsql-general@postgresql.org > Subject: [

Re: [GENERAL] Function error

2016-01-07 Thread Sachin Srivastava
Thanks Pavel !!! On Fri, Jan 8, 2016 at 1:05 PM, Pavel Stehule wrote: > Hi > > > > 2016-01-08 8:24 GMT+01:00 Sachin Srivastava : > >> Dear Concern, >> >> >> >> I am creating below function *“create_catexp_ss_master()” *and getting >> error as

Re: [GENERAL] Function error

2016-01-07 Thread Sachin Srivastava
Thanks Charles !!! On Fri, Jan 8, 2016 at 1:15 PM, Sachin Srivastava wrote: > Thanks Pavel !!! > > On Fri, Jan 8, 2016 at 1:05 PM, Pavel Stehule > wrote: > >> Hi >> >> >> >> 2016-01-08 8:24 GMT+01:00 Sachin Srivastava :

[GENERAL] Function error

2016-01-07 Thread Sachin Srivastava
Dear Concern, I am creating below function *“create_catexp_ss_master()” *and getting error as below, I have already created dependent function firstly successfully *(“create_catexp_ss_1” and “create_catexp_ss_2”) *but still getting error, please suggest why? ERROR: syntax error at or near

Re: [GENERAL] Function error

2016-01-07 Thread Pavel Stehule
Hi 2016-01-08 8:24 GMT+01:00 Sachin Srivastava : > Dear Concern, > > > > I am creating below function *“create_catexp_ss_master()” *and getting > error as below, I have already created dependent function firstly > successfully *(“create_catexp_ss_1” and

Re: [GENERAL] Function in PostgreSQL

2015-12-09 Thread Albe Laurenz
Sachin Srivastava wrote: > Do you know if it is possible to create a function in postgres that has > errors in the syntax of the > creation sql? It would help our conversion process if we could get all of our > various functions > present in postgres even if they aren’t in 100% working shape. Is

[GENERAL] Function in PostgreSQL

2015-12-09 Thread Sachin Srivastava
Hi, Do you know if it is possible to create a function in postgres that has errors in the syntax of the creation sql? It would help our conversion process if we could get all of our various functions present in postgres even if they aren’t in 100% working shape. Is there any way to ignore

Re: [GENERAL] function null composite behavior

2015-10-26 Thread Rikard Pavelic
On Sun, 25 Oct 2015 22:31:03 +0100 Rikard Pavelic wrote: > I assume there is no way to get sql like result from plpgsql > function? I should try harder ;) Managed to get it working using array and array_agg. Regards, Rikard -- Rikard Pavelic https://dsl-platform.com/

  1   2   3   4   5   6   7   >