Skip to content

Instantly share code, notes, and snippets.

@Warchant
Created January 4, 2019 19:37
Show Gist options
  • Select an option

  • Save Warchant/5c861d00ec84b65fbe7bc9025a4af94b to your computer and use it in GitHub Desktop.

Select an option

Save Warchant/5c861d00ec84b65fbe7bc9025a4af94b to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION
get_detail_text_google(item_id integer)
RETURNS TEXT AS
$$
declare
_ret TEXT;
_art TEXT;
_brand TEXT;
_country TEXT;
_har TEXT;
_sostav TEXT;
_typecontrol TEXT;
_item_id integer;
BEGIN
select i.id,
b.name,
t.name,
i.art,
country.name
into
_item_id, _brand, _typecontrol, _art, _country
from item i,
brand b,
typecontrol t,
itemhascountry ihc,
country
where i.id = 1
AND i.brand = b.id
AND i.type_control = t.id
AND i.id = ihc.item;
_ret := _typecontrol ||
' от производителя ' || _brand ||
' станет хорошим приобретением для вашего дома и прослужит не один год. Информация о товаре:' ||
'Страна производитель: ' || _country ||
'Производитель: ' || _brand ||
'Гарантия: ';
return _ret;
END;
$$ LANGUAGE plpgsql;
select get_detail_text_google(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment