Jump to content
Fórum Script Brasil
  • 0

Tabela em Function



2 answers to this question

Recommended Posts

  • 0

Tem que criar uma consulta dinâmica:

create table tabela (id integer);
insert into tabela (id) values (1), (2), (3);

create function teste(text) returns setof tabela as
return query execute format('select * from %s', $1);
$$ language plpgsql

select * from teste('tabela');
(3 rows)

Link to comment
Share on other sites

  • 0

Desculpa Kakao mas não deu certo.

if not aux in(select campox from tabelax) then

insert into tabelax

(campoy, campox)

(query execute format('select toascii(%s), '||aux||' from %s where toascii(%s) ~ '||aux,$2,$1,$2));

end if;

para retornar um simples select ele até aceita mas para fazer algo mais sério ele não faz

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...