Re: Learning Plpgsql ??

From: Steve_Miller(at)sil(dot)org
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Learning Plpgsql ??
Date: 2003-01-28 17:50:12
Message-ID: OFE0057D9E.976D1929-ON86256CBC.0061F01D@sil.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I took this code from a different message:

>CREATE or REPLACE FUNCTION up_seq() RETURNS text AS '
> DECLARE
> row RECORD; qrystr TEXT;
> BEGIN
> -- select sequence information from seq table
> [ sequence_name, table_name, pk_column]
> FOR row IN SELECT * FROM swim_seq_temp LOOP
>
> qrystr :=
> ''SELECT setval(''
> || quote_literal(row.sequence_name)
> || '', ( SELECT max(''
> || quote_ident(row.pk_column)
> || '') FROM ''
> || quote_ident(row.table_name)
> || ''))'';
> EXECUTE qrystr;
>
> END LOOP;
> RETURN ''done'';
> END;
>' LANGUAGE 'plpgsql';

I'm heartened that we have the capabilities to execute dynamic a string
like this. However, in SQL Server, this sort of operation slows down the
database, because it has to produce a new execution plan. Is the same true
for Postgresql?

The way SQL Server gets some time back is by the use of sp_executesql. Is
there some equivalent in Postgresql?

Steve

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Art Fore 2003-01-28 17:54:22 Re: postgresql with SuSE 8.0
Previous Message Antonio Scotti 2003-01-28 16:19:20 Re: Passing parameters to a Trigger