function volatility

From: <maps(at)navigator-info(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: function volatility
Date: 2010-11-22 11:30:31
Message-ID: f295555a0ea00c0f198e1f1ceaa78ed5@navigator-info.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


How to declare function that return set of data from tables? for
example :

CREATE TYPE "public"."cst_test" AS (
  "code" VARCHAR(10),
  "name" VARCHAR(50),
  "quantity" NUMERIC(10,2) );

CREATE OR REPLACE FUNCTION public."sf_test"(id_code VARCHAR)
  RETURNS SETOF "public"."cst_test" AS
$body$
SELECT
  t1.code,
  t1.name,
  t2.quantity
FROM "public"."test_1" t1
  INNER JOIN "public"."test_2" t2 ON t1.id_test1 = t2.id_test1
WHERE t1.code = $1
$body$
LANGUAGE 'sql' ;

It's STABLE, IMMUTABLE OR VOLATILE?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Leif Biberg Kristensen 2010-11-22 12:08:18 Re: function volatility
Previous Message Jan Johansson 2010-11-22 08:23:52 Change Data Capture