469,159 Members | 1,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,159 developers. It's quick & easy.

PostreSql function

I need a help with PostgreSql.
I need to build a function that returns the folowing select and I don't know how to do it.


jose Souza

Expand|Select|Wrap|Line Numbers
  1. "Select pe.pessoa_id, Pessoa_Nome, pessoa_alcunha, sexo_descricao, 
  2. pessoa_rg, pessoa_cpf, ci.cidade_nome, 
  3. es.Estado_nome, pessoa_pai, pessoa_mae, pe.pessoa_DNasc, 
  4. instrucao_descricao, alb_file, EstadoCivil_Descricao,
  5. ci2.cidade_nome, es2.Estado_Id
  6. from
  7. album al, pessoas pe, profile pr, temas te, tabela_similaridade ts, dominio dm, 
  8. cidades ci, estados es, sexo sx, instrucao it, EstadoCivil ec, cidades ci2, estados es2
  9. where
  10. ts.tema1 = te.tem_codigo and
  11. ts.tema2 = 1 and 
  12. ts.valor >= 0.71 and 
  13. dm.dmn_codigo = 1 and 
  14. te.tem_codigo = pr.tem_codigo and
  15. pr.pessoa_id = pe.pessoa_id and
  16. pe.pessoa_id = al.pessoa_id and
  17. pe.pessoa_naturalidade = ci.cidade_id and
  18. ci.estado_id = es.estado_id and
  19. pe.sexo_id = sx.sexo_id and
  20. pe.pessoa_instrucao_id = it.instrucao_id and
  21. pe.EstadoCivil_id = ec.EstadoCivil_id and
  22. pe.cidade_id = ci2.cidade_id and
  23. ci2.estado_id = es2.estado_id and
  24. pe.sexo_id='M' "
May 6 '07 #1
1 2028
534 Expert 512MB
Please read the Posting Guidelines at the top of the forum

First, you need to look at the CREATE FUNCTION manual.

For a simple SELECT you don't need to use a procedural language, so review the man page on SQL Functions and make sure to read the section "SQL Functions Returning Sets"
May 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by domeceo | last post: by
5 posts views Thread by phil_gg04 | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by sushil | last post: by
8 posts views Thread by Olov Johansson | last post: by
3 posts views Thread by Beta What | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.