Re: Learning Plpgsql ?? - Mailing list pgsql-novice

From Steve_Miller@sil.org
Subject Re: Learning Plpgsql ??
Date
Msg-id OFE0057D9E.976D1929-ON86256CBC.0061F01D@sil.org
Whole thread Raw
In response to Learning Plpgsql ??  (Jonathon Batson <jonathon@octahedron.com.au>)
List 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



pgsql-novice by date:

Previous
From: Art Fore
Date:
Subject: Re: postgresql with SuSE 8.0
Next
From: Tom Lane
Date:
Subject: Re: Passing parameters to a Trigger