у меня проблема с кросс-таблицей в функции - PullRequest
0 голосов
/ 07 января 2019

ОШИБКА: синтаксическая ошибка в или около "VALUES" LINE 14:, $$ VALUES ('01'), ('02'), ('03'), ('04'), ('05'), ('06'), ...

CREATE OR REPLACE FUNCTION search_id_person(id_person1 integer,sal integer) RETURNS VOID AS
$$
BEGIN

SELECT *
FROM   crosstab(
   'select personely.person.name,personely.person.family,unit.title,org.orgname(org.unit.id_child),mahane.sal ,personely.mahane.mah,personely.mahane.sum1
from personely.mahane
inner join personely.person on personely.person.id_person=personely.mahane.id_person
    inner join personely.karkard on personely.person.id_person=personely.karkard.id_person
    inner join org.unit on org.unit.id_unit=personely.person.id_unit
    where mahane.sal::integer = $2 and personely.person.id_person=$1
    ORDER  BY personely.person.id_person   ' 
    , $$VALUES ('01'), ('02'), ('03'), ('04'), ('05'), ('06'), ('07'), ('08'), ('09'), ('10'), ('11'), ('12')$$
   ) AS a ("نام" text,"نام خانوادگی" text,"واحد" text,"سازمان" text,"سال" text, "فروردین" int , "اردیبهشت" int, "خرداد" int, "تیر" int, "مرداد" int, "شهریور" int, "مهر" int, "آبان" int, "آدر" int, "دی" int, "بهمن" int, "اسفند" int);                                                                                
END ;

1 Ответ

0 голосов
/ 07 января 2019

Вы вложили $$ цитаты. Заменить

$$VALUES ('01'), ('02'), ('03'), ('04'), ('05'), ('06'), ('07'), ('08'), ('09'), ('10'), ('11'), ('12')$$ 

с

$values$VALUES ('01'), ('02'), ('03'), ('04'), ('05'), ('06'), ('07'), ('08'), ('09'), ('10'), ('11'), ('12')$values$
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...