Thread: arrays as pgsql function parameters
how can i pass and access array parameters to a function
On Fri, 7 Jun 2002, Joseph Syjuco wrote: Have a look at the documentation regarding server side programming. Also you can have as examples the contrib/array and the famous contrib/intarray package. > how can i pass and access array parameters to a function > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr
actually i already have and basically the function statments start ascreate function test(_int4) returns integer when i tried to execute the function select test('{1,2,3,4}'); it didnt spew out errors but it didnt output results either -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Achilleus Mantzios Sent: Friday, June 07, 2002 7:24 PM To: Joseph Syjuco Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] arrays as pgsql function parameters On Fri, 7 Jun 2002, Joseph Syjuco wrote: Have a look at the documentation regarding server side programming. Also you can have as examples the contrib/array and the famous contrib/intarray package. > how can i pass and access array parameters to a function > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org
On Fri, 7 Jun 2002, Joseph Syjuco wrote: > actually i already have and basically the function statments start as > create function test(_int4) returns integer > when i tried to execute the function > select test('{1,2,3,4}'); > it didnt spew out errors but it didnt output results either Well, it depends on the code :) Is it C? pg/plsql?? > > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Achilleus Mantzios > Sent: Friday, June 07, 2002 7:24 PM > To: Joseph Syjuco > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] arrays as pgsql function parameters > > > On Fri, 7 Jun 2002, Joseph Syjuco wrote: > > Have a look at the documentation regarding server side programming. > > Also you can have as examples the contrib/array and the famous > contrib/intarray package. > > > how can i pass and access array parameters to a function > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > > > -- Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr
Joseph, > actually i already have and basically the function statments start as > create function test(_int4) returns integer > when i tried to execute the function > select test('{1,2,3,4}'); > it didnt spew out errors but it didnt output results either How about posting a full function definition? We're not telepathic. -Josh
Josh Berkus wrote: > > Joseph, > > > actually i already have and basically the function statments start as > > create function test(_int4) returns integer > > when i tried to execute the function > > select test('{1,2,3,4}'); > > it didnt spew out errors but it didnt output results either > > How about posting a full function definition? > > We're not telepathic. > > -Josh here is the sample function that i got from the internet. hope you can send me a sample function create function foo(_int4) returns int2 as' declare a _int4 alias for $1; i int:=1; begin while a[i] loop i:=i+1; end loop; return i-1; end; ' language 'plpgsql';
can someone have a foreign key constraint that references a view?? -- Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr
On Mon, 10 Jun 2002, Achilleus Mantzios wrote: > > can someone have a foreign key constraint that references > a view?? Not currently in PostgreSQL. Doing so for a general case gets rather involved.
Achilleus Mantzios wrote: > > can someone have a foreign key constraint that references > a view?? No, and this is not planned either. Remember that it is not only required for referential integrity to check if a key exists on INSERT or UPDATE to the referencing table. The system must guarantee that you cannot remove existing keys while they are referenced (or more precise perform the requested referential action). Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #
I would just like to elaborate, and clarify if my understanding is correct: The implication of below is that you need a trigger in the foreign key target table on the DELETE event, so the foreign key table only lets you delete a row if there are no other tables refering to the key you want to delete. Views cannot have triggers, hence cannot have a DELETE trigger, therefore that is why the view cannot be a foreign key target table. Terry Fielder Network Engineer Great Gulf Homes / Ashton Woods Homes terry@greatgulfhomes.com > -----Original Message----- > From: pgsql-general-owner@postgresql.org > [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Jan Wieck > Sent: Monday, June 10, 2002 1:20 PM > To: Achilleus Mantzios > Cc: pgsql-general@postgresql.org; pgsql-sql@postgresql.org > Subject: Re: [GENERAL] [SQL] VIEWs and FOREIGN keys > > > Achilleus Mantzios wrote: > > > > can someone have a foreign key constraint that references > > a view?? > > No, and this is not planned either. Remember that it is not > only required for referential integrity to check if a key > exists on INSERT or UPDATE to the referencing table. The > system must guarantee that you cannot remove existing keys > while they are referenced (or more precise perform the > requested referential action). > > > Jan > > -- > > #============================================================= > =========# > # It's easier to get forgiveness for being wrong than for > being right. # > # Let's break this rule - forgive me. > # > #================================================== > JanWieck@Yahoo.com # > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >