Function For Newly INSERTED VALUE

Поиск
Список
Период
Сортировка
От shreedhar
Тема Function For Newly INSERTED VALUE
Дата
Msg-id 002601c25a2c$7372f610$1201a8c0@a4005
обсуждение исходный текст
Список pgsql-admin
Hi All,

The following function is possible where input is 'Sequence Name' and output
is 'Inserted value' language 'plpgsql'

DECLARE
 sequence ALIAS FOR $1;
 inserted_rec integer;
 sql text;
BEGIN
 sql := 'SELECT INTO inserted_rec *  from ' || sequence;
 EXECUTE sql;
 IF inserted_rec.last_value IS NULL THEN
   RETURN 0;
 ELSE
   RETURN inserted_rec.last_value;
 END IF;
END;

The same is working for the following

DECLARE
 sequence ALIAS FOR $1;
 inserted_rec integer;
 sql text;
BEGIN
SELECT INTO inserted_rec *  from  sequencename;
 IF inserted_rec.last_value IS NULL THEN
   RETURN 0;
 ELSE
   RETURN inserted_rec.last_value;
 END IF;
END;

How can I make use the top one.

With Best Regards,
Sreedhar Bhaskararaju 1,2nd Main Road, KottuGardens, Chennai - 600 085 Ph :
4475111 Email : shreedhar@lucidindia.net


В списке pgsql-admin по дате отправления:

Предыдущее
От: "Marc Mitchell"
Дата:
Сообщение: TPS benchmarks for an active system
Следующее
От: Krammer Clemens
Дата:
Сообщение: disk spin down