[SQL] the value of OLD on an initial row insert

2013-09-20 Thread James Sharrett
I have a number of trigger functions on a table that are performing various calculations. The table is a column-wise orientation with multiple columns that could be updated on a single row. In one of the triggers, I'm performing a calculation but don't want the code to run if the OLD and NEW valu

Re: [SQL] how can I replace all instances of a pattern

2013-03-26 Thread James Sharrett
Thanks Ken! I missed that option going through the documentation. > -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] how can I replace all instances of a pattern

2013-03-26 Thread James Sharrett
Sorry, caught a typo. Mytext1 is correctly replaced because only one instance of the character (space) is in the string. This deals with the correct characters but only does the first instance of the character so the output is: 'Mytext1' 'Mytext 2' (wrong) 'Mytext-3' (wrong) 'M

[SQL] how can I replace all instances of a pattern

2013-03-26 Thread James Sharrett
I'm trying remove all instances of non-alphanumeric or underscore characters from a query result for further use. This is part of a function I'm writing that is in plpgsql Examples: Original value 'My text1' 'My text 2' 'My-text-3' 'My_text4' 'My!text5' Desired 'Myt

Re: [SQL] returning the number of rows output by a copy command from a function

2013-01-16 Thread James Sharrett
Integer On 1/16/13 12:21 PM, "Adrian Klaver" wrote: >On 01/16/2013 09:16 AM, James Sharrett wrote: >> The problem I have is that I get nothing back when the COPY is run >>inside >> the function other than what I explicitly return from the function so I >>

Re: [SQL] returning the number of rows output by a copy command from a function

2013-01-16 Thread James Sharrett
since the format and information in the string (when run outside of the function) are exactly the same. On 1/16/13 11:42 AM, "Adrian Klaver" wrote: >On 01/16/2013 08:30 AM, James Sharrett wrote: >> I have a function that generates a table of records and then a SQL >> sta

Re: [SQL] returning the number of rows output by a copy command from a function

2013-01-16 Thread James Sharrett
again just to get a count. On 1/16/13 11:36 AM, "Rob Sargent" wrote: >On 01/16/2013 09:30 AM, James Sharrett wrote: >> I have a function that generates a table of records and then a SQL >> statement that does a COPY into a text file. I want to return the >> n

[SQL] returning the number of rows output by a copy command from a function

2013-01-16 Thread James Sharrett
I have a function that generates a table of records and then a SQL statement that does a COPY into a text file. I want to return the number of records output into the text file from my function. The number of rows in the table is not necessarily the number of rows in the file due to summarization

Re: [SQL] ERROR: missing FROM-clause entry for table "new"

2012-09-14 Thread James Sharrett
> I'm trying to define a trigger function that looks for changes in table A > (table the trigger for the function is on) and write a delta record into table > B. So if a record has a value of 100 in table A, and it is updated to 50, the > function should write ­50 in table B. I can get the trigger

[SQL] ERROR: missing FROM-clause entry for table "new"

2012-09-13 Thread James Sharrett
I'm trying to define a trigger function that looks for changes in table A (table the trigger for the function is on) and write a delta record into table B. So if a record has a value of 100 in table A, and it is updated to 50, the function should write ­50 in table B. I can get the trigger to work

[SQL] returning values from dynamic SQL to a variable

2012-09-09 Thread James Sharrett
I have a PG function ( using plpgsql) that calls a number of sub functions also in plpgsql. I have two main problems that seem to be variations on the same theme of running dynamic SQL from a variable with the EXECUTE statement and returning the results back to a variable defined in the calling fu

[SQL] returning values to variables from dynamic SQL

2012-09-08 Thread James Sharrett
I have a PG function ( using plpgsql) that calls a number of sub functions also in plpgsql. I have two main problems that seem to be variations on the same theme of running dynamic SQL from a variable with the EXECUTE statement and returning the results back to a variable defined in the calling fu