Re: [GENERAL] PL/pgSQL - Help or advice please on using unbound cursors

2012-07-25 Thread Andrew Hastie
Yep, that fixed it. Many thanks for the pointer. From a performance point of view, I did look at using MOVE rather than FETCH before I call UPDATE as I don't actually need to read the data before applying the update. However in this situation, the ROW_COUNT is always zero and can't be used whi

Re: [GENERAL] PL/pgSQL - Help or advice please on using unbound cursors

2012-07-23 Thread Pavel Stehule
Hello dynamic SQL has not impact on FOUND variable - use GET DIAGNOSTICS varname = ROW_COUNT instead. Regards Pavel Stehule 2012/7/23 Andrew Hastie : > Hi all, > > Apologies if the answer to my question is "obvious", but I'm fairly new to > writing functions in PG. I think my problem is has a

Re: [GENERAL] pl/pgsql help

2005-10-25 Thread Oliver Elphick
On Tue, 2005-10-25 at 00:17 +, krishnaa sridharan wrote: > Hi all > When I installed postgresql in my computer, I had pl/pgsql language > selected but still, I dont have any language installed. Can some one > tell me how to install a language. thanks in advance. i am a beginner > so any help wo

Re: [GENERAL] PL/PGSQL help for getting number of rows matched.

2003-11-10 Thread Nigel J. Andrews
On Mon, 10 Nov 2003, Pavel Stehule wrote: > Hello, > > it isn't problem. You can write > > SELECT INTO > IF FOUND THEN > ... > END IF > > or > > SELECT INTO .. > GET DIAGNOSTICS variable = ROW_COUNT; > IF variable > 0 THEN > ... > END IF > > You can see on > http://developer.postgr

Re: [GENERAL] PL/PGSQL help for getting number of rows matched.

2003-11-10 Thread Jaime Casanova
Maybe you can use a for if there is only one row it will do the job just like if there were many rows: FOR referrer_keys IN SELECT * FROM cs_referrer_keys ORDER BY try_order LOOP a_output := a_output || '' IF v_'' || referrer_keys.kind || '' LIKE '' || referrer

Re: [GENERAL] PL/PGSQL help for getting number of rows matched.

2003-11-10 Thread Pavel Stehule
Hello, it isn't problem. You can write SELECT INTO IF FOUND THEN ... END IF or SELECT INTO .. GET DIAGNOSTICS variable = ROW_COUNT; IF variable > 0 THEN ... END IF You can see on http://developer.postgresql.org/docs/postgres/plpgsql-statements.html#PLPGSQL-SELECT-INTO Regards Pavel

Re: [GENERAL] PL/pgSQL help

1999-06-03 Thread Dustin Sallings
On 3 Jun 1999, Anatoly K. Lasareff wrote: # Yes. 'serial' type implements as 'int' type for field and sequence, # which mane is __seq. So you can do this: # # INSERT into Network (parentID, networkName) values (pid, mname); netid # := Network_networkID_seq.last_value; That doesn't te

Re: [GENERAL] PL/pgSQL help

1999-06-03 Thread Tim Joyce
> MH> Question 2: > MH> is there a way to get the value of the newly assigned primary key > MH> after an insert? (rather then following the insert with a select) > > MH> e.g. (this would be nice if it worked (networkID is the PKey)) > MH> INSERT into Network (parentID, networkName) values (pid,

Re: [GENERAL] PL/pgSQL help

1999-06-03 Thread Anatoly K. Lasareff
> "MH" == Mike Haberman <[EMAIL PROTECTED]> writes: MH> I'm a bit new to plpgsql, so this may be an easy question, MH> I've got a function (see below) that inserts into 3 different MH> tables. Each table has a SERIAL type for it's primary key. MH> Question 1: MH> I want to group all 3