I have the following function called as pro(). From which I want to return the strings by union all of two select statements and product output.
Function: pro()
My try:
create or replace function pro()
returns varchar as
$$
declare
sql varchar;
q varchar;
begin
sql := 'SELECT DISTINCT CAST(COUNT(ProductNumber) as varchar) ||'' - Count of the product Number '' as Descp
FROM product
UNION ALL
SELECT DISTINCT CAST(COUNT(ProductName) AS varchar) || '' - Count of the product Name '' as Descp
FROM product';
raise info '%',sql;
execute sql into q;
return q;
end;
$$
language plpgsql;
Calling Function:
select pro();
This returning only the first part of select statement:
______________________________________
|pro |
|character varying |
|______________________________________|
|6 - Count of the product Number |
|______________________________________|
But the expected result should be:
______________________________________
|pro |
|character varying |
|______________________________________|
|6 - Count of the product Number |
|______________________________________|
|6 - Count of the product Name |
|______________________________________|