inner subprograms ... Was: syntax question

2021-06-03 Thread Bryn Llewellyn
> br...@momjian.us wrote: > > Oh, I thought he wanted to declare a function inside the function that could > be called only by that function, like private functions in Oracle packages > can do. Yes, you can create a function that defines a function that can be > called later. I guess you coul

Re: syntax question

2021-06-03 Thread Marc Millas
no pb: I am french, so quite skilled on that topic :-) there is only 50 bottles of various malt on the presentoir close to my desk so I must stay reasonnable :-) Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Thu, Jun 3, 2021 at 11:17 PM Adrian Klaver wrote: > On 6/3/21 1:01 PM

Re: syntax question

2021-06-03 Thread Adrian Klaver
On 6/3/21 1:01 PM, Marc Millas wrote: thanks Adrian, exactly what I was missing :-) about knowing if I should... We have to create a set of triggers (insert, update, delete) within a huge set of tables. and that list of tables, and structure of them  can be customized, maintained, ... so we we

Re: syntax question

2021-06-03 Thread Guyren Howe
I know it would be non-standard, but I would love to see Postgres support the likes of nested functions. I know that would be non-standard, but Postgres has lots of non-standard features that make it more like a real programming language and considerably more productive. On Jun 3, 2021, 12:34 -

Re: syntax question

2021-06-03 Thread Marc Millas
I take note of this. thanks Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Thu, Jun 3, 2021 at 10:23 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Thu, Jun 3, 2021 at 1:02 PM Marc Millas wrote: > >> about knowing if I should... >> We have to create a set of trigg

Re: syntax question

2021-06-03 Thread David G. Johnston
On Thu, Jun 3, 2021 at 1:02 PM Marc Millas wrote: > about knowing if I should... > We have to create a set of triggers (insert, update, delete) within a huge > set of tables. and that list of tables, and structure of them can be > customized, maintained, ... > so we were looking for a standard s

Re: syntax question

2021-06-03 Thread Marc Millas
thanks Adrian, exactly what I was missing :-) about knowing if I should... We have to create a set of triggers (insert, update, delete) within a huge set of tables. and that list of tables, and structure of them can be customized, maintained, ... so we were looking for a standard script to automa

Re: syntax question

2021-06-03 Thread Marc Millas
good reading, thanks Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Thu, Jun 3, 2021 at 9:21 PM Tom Lane wrote: > Adrian Klaver writes: > > On 6/3/21 12:01 PM, Bruce Momjian wrote: > >> On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote: > >>> within a function, I want

Re: syntax question

2021-06-03 Thread Bruce Momjian
On Thu, Jun 3, 2021 at 03:21:15PM -0400, Tom Lane wrote: > Adrian Klaver writes: > > On 6/3/21 12:01 PM, Bruce Momjian wrote: > >> On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote: > >>> within a function, I want to create another function. > > >> You can't create functions inside of

Re: syntax question

2021-06-03 Thread Tom Lane
Adrian Klaver writes: > On 6/3/21 12:01 PM, Bruce Momjian wrote: >> On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote: >>> within a function, I want to create another function. >> You can't create functions inside of functions; same for procedures. > Sure you can: Yeah. The actual p

Re: syntax question

2021-06-03 Thread Adrian Klaver
On 6/3/21 12:01 PM, Bruce Momjian wrote: On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote: Hi, within a function, I want to create another function. no pb. but if I write: declare bidule text; begin bidule:='myfunc'; create function bidule() ... it does create a function named bidu

Re: syntax question

2021-06-03 Thread Bruce Momjian
On Thu, Jun 3, 2021 at 08:58:03PM +0200, Marc Millas wrote: > Hi, > > within a function, I want to create another function. > no pb. > but if I write: > declare bidule text; > begin > bidule:='myfunc'; > create function bidule() ... > > > it does create a function named bidule and not myfunc. >

syntax question

2021-06-03 Thread Marc Millas
Hi, within a function, I want to create another function. no pb. but if I write: declare bidule text; begin bidule:='myfunc'; create function bidule() ... it does create a function named bidule and not myfunc. so I am obviously missing something too obvious. can someone help ? thanks Marc MI

Re: plperl syntax question

2020-03-12 Thread David G. Johnston
On Thursday, March 12, 2020, Rob Sargent wrote: > > The example I saw for qq on the perl site > > print(qq(Welcome to GeeksForGeeks)); > > doesn’t have any quotes in arg to qq > Correct. It also says: qq() operator in Perl can be used in pl

Re: plperl syntax question

2020-03-12 Thread David G. Johnston
On Thursday, March 12, 2020, Rob Sargent wrote: > > > On Mar 12, 2020, at 7:44 PM, stan wrote: > > On Thu, Mar 12, 2020 at 06:37:02PM -0700, David G. Johnston wrote: > > On Thursday, March 12, 2020, stan wrote: > > > my $rv3 = spi_exec_query('$stmt'); > What am I doing wrong here? > > > Putting

Re: plperl syntax question

2020-03-12 Thread Rob Sargent
> On Mar 12, 2020, at 7:44 PM, stan wrote: > > On Thu, Mar 12, 2020 at 06:37:02PM -0700, David G. Johnston wrote: >> On Thursday, March 12, 2020, stan wrote: >>> >>> my $rv3 = spi_exec_query('$stmt'); >>> What am I doing wrong here? >>> >> >> Putting a variable name into a single-quoted str

Re: plperl syntax question

2020-03-12 Thread stan
On Thu, Mar 12, 2020 at 06:37:02PM -0700, David G. Johnston wrote: > On Thursday, March 12, 2020, stan wrote: > > > > my $rv3 = spi_exec_query('$stmt'); > > What am I doing wrong here? > > > > Putting a variable name into a single-quoted string and expecting it to > resolve to the contents of sai

Re: plperl syntax question

2020-03-12 Thread stan
On Thu, Mar 12, 2020 at 06:00:01PM -0600, Rob Sargent wrote: > > > > On Mar 12, 2020, at 5:16 PM, stan wrote: > > > > On Thu, Mar 12, 2020 at 04:58:08PM -0600, Rob Sargent wrote: > >> > >> > >>> On Mar 12, 2020, at 4:49 PM, stan wrote: > >>> > >>> On Thu, Mar 12, 2020 at 04:45:58PM -0600, R

Re: plperl syntax question

2020-03-12 Thread David G. Johnston
On Thursday, March 12, 2020, stan wrote: > > my $rv3 = spi_exec_query('$stmt'); > What am I doing wrong here? > Putting a variable name into a single-quoted string and expecting it to resolve to the contents of said variable instead of being treated as a literal. David J.

Re: plperl syntax question

2020-03-12 Thread Rob Sargent
> On Mar 12, 2020, at 4:34 PM, stan wrote: > > I am trying to run a query in plperl that uses a Perl variable from the > same function. > > Here is the code snippet: > > my $stmt = qq("SELECT employee_key from employee where id = '$user' ;"); > elog( NOTICE, "stmt = $stmt" ); > my $rv3 = spi

plperl syntax question

2020-03-12 Thread stan
I am trying to run a query in plperl that uses a Perl variable from the same function. Here is the code snippet: my $stmt = qq("SELECT employee_key from employee where id = '$user' ;"); elog( NOTICE, "stmt = $stmt" ); my $rv3 = spi_exec_query('$stmt'); Here is the runtime output: NOTICE: stmt

Re: Syntax question about returning value from an insert

2019-12-26 Thread stan
On Wed, Dec 25, 2019 at 09:17:22PM -0800, Adrian Klaver wrote: > On 12/25/19 4:48 PM, Rob Sargent wrote: > > > > > > > On Dec 25, 2019, at 3:10 PM, stan wrote: > > > There is more that that. There is a project number, so the actuall key > > > represents the combination of project number, and c

Re: Syntax question about returning value from an insert

2019-12-25 Thread Adrian Klaver
On 12/25/19 3:09 PM, stan wrote: On Wed, Dec 25, 2019 at 02:34:43PM -0800, Adrian Klaver wrote: On 12/25/19 12:39 PM, stan wrote: Other approaches have been suggested, e.g. use a traditional FK relationship. The big unknown in you present system is what: SELECT cost_category_key from t2 w

Re: Syntax question about returning value from an insert

2019-12-25 Thread Adrian Klaver
On 12/25/19 4:48 PM, Rob Sargent wrote: On Dec 25, 2019, at 3:10 PM, stan wrote: There is more that that. There is a project number, so the actuall key represents the combination of project number, and cost category, Thire is a constraint on T2 that assures that these combinations will be uni

Re: Syntax question about returning value from an insert

2019-12-25 Thread Rob Sargent
> On Dec 25, 2019, at 3:10 PM, stan wrote: > There is more that that. There is a project number, so the actuall key > represents the combination of project number, and cost category, Thire is a > constraint on T2 that assures that these combinations will be unique. > > When the 1st record for

Re: Syntax question about returning value from an insert

2019-12-25 Thread stan
On Wed, Dec 25, 2019 at 06:09:55PM -0500, stan wrote: > On Wed, Dec 25, 2019 at 02:34:43PM -0800, Adrian Klaver wrote: > > On 12/25/19 12:39 PM, stan wrote: > > > > > > On Wed, Dec 25, 2019 at 11:55:51AM -0800, Adrian Klaver wrote: > > > > On 12/25/19 11:08 AM, stan wrote: > > > > > > > > > > O

Re: Syntax question about returning value from an insert

2019-12-25 Thread stan
On Wed, Dec 25, 2019 at 02:34:43PM -0800, Adrian Klaver wrote: > On 12/25/19 12:39 PM, stan wrote: > > > > On Wed, Dec 25, 2019 at 11:55:51AM -0800, Adrian Klaver wrote: > > > On 12/25/19 11:08 AM, stan wrote: > > > > > > > > On Wed, Dec 25, 2019 at 08:28:45AM -0800, Adrian Klaver wrote: > > > >

Re: Syntax question about returning value from an insert

2019-12-25 Thread Adrian Klaver
On 12/25/19 12:39 PM, stan wrote: On Wed, Dec 25, 2019 at 11:55:51AM -0800, Adrian Klaver wrote: On 12/25/19 11:08 AM, stan wrote: On Wed, Dec 25, 2019 at 08:28:45AM -0800, Adrian Klaver wrote: On 12/25/19 7:26 AM, stan wrote: I am writing a trigger/function to make certain a default item,

Re: Syntax question about returning value from an insert

2019-12-25 Thread Rob Sargent
> On Dec 25, 2019, at 11:56 AM, Adrian Klaver < >> First of all, thanks to both of you for your fast response . >> Let me clarify. >> I have a table that records will be inserted into. Several of the columns >> in this table must be non NULL, and they are actually keys from other >> tables. Lik

Re: Syntax question about returning value from an insert

2019-12-25 Thread stan
On Wed, Dec 25, 2019 at 11:55:51AM -0800, Adrian Klaver wrote: > On 12/25/19 11:08 AM, stan wrote: > > > > On Wed, Dec 25, 2019 at 08:28:45AM -0800, Adrian Klaver wrote: > > > On 12/25/19 7:26 AM, stan wrote: > > > > I am writing a trigger/function to make certain a default item, and its > > >

Re: Syntax question about returning value from an insert

2019-12-25 Thread Adrian Klaver
On 12/25/19 11:08 AM, stan wrote: On Wed, Dec 25, 2019 at 08:28:45AM -0800, Adrian Klaver wrote: On 12/25/19 7:26 AM, stan wrote: I am writing a trigger/function to make certain a default item, and its key exist when an insert is called. EG The trigger gets called on insert to T1 If column c1

Re: Syntax question about returning value from an insert

2019-12-25 Thread stan
On Wed, Dec 25, 2019 at 08:28:45AM -0800, Adrian Klaver wrote: > On 12/25/19 7:26 AM, stan wrote: > > I am writing a trigger/function to make certain a default item, and its key > > exist when an insert is called. EG > > > > The trigger gets called on insert to T1 If column c1 is NULL in the NEW

Re: Syntax question about returning value from an insert

2019-12-25 Thread Adrian Klaver
On 12/25/19 7:26 AM, stan wrote: I am writing a trigger/function to make certain a default item, and its key exist when an insert is called. EG The trigger gets called on insert to T1 If column c1 is NULL in the NEW structure, I need to check table t2 to get the key associated with the default f

Re: Syntax question about returning value from an insert

2019-12-25 Thread Pavel Stehule
Hi st 25. 12. 2019 v 16:26 odesílatel stan napsal: > I am writing a trigger/function to make certain a default item, and its key > exist when an insert is called. EG > > The trigger gets called on insert to T1 If column c1 is NULL in the NEW > structure, I need to check table t2 to get the key a

Syntax question about returning value from an insert

2019-12-25 Thread stan
I am writing a trigger/function to make certain a default item, and its key exist when an insert is called. EG The trigger gets called on insert to T1 If column c1 is NULL in the NEW structure, I need to check table t2 to get the key associated with the default for this column. However, if the def