Re: [pgbr-geral] Substituição de variável no psq l

2009-03-19 Por tôpico dmanci...@gmail.com
Agradeço a todos pelas dicas! Valeu!

Um Abraço!

2009/3/18 Rudinei Dias rudinei.d...@gmail.com

 E aíd Diego, beleza?

 Aí vai um exemplo.
 Abraço,

 Rudinei

 The \set command sets a variable, and \unset removes a variable. To
 access a variable you precede its name with a colon. The \set command
 used alone lists all defined variables.

 Figure  shows the use of psql variables.

 test= \set num_var 4
 test= SELECT :num_var;
  ?column?
 --
 4
 (1 row)

 test= \set operation SELECT
 test= :operation :num_var;
  ?column?
 --
 4
 (1 row)

 test= \set str_var '\'My long string\''
 test= \echo :str_var
 'My long string'
 test= SELECT :str_var;
 ?column?
 
  My long string
 (1 row)

 links:
 http://www.postgresql.org/files/documentation/books/aw_pgsql/node143.html
 http://www.faqs.org/docs/ppbook/x19832.htm

 2009/3/18 Dickson S. Guedes lis...@guedesoft.net
 
  Em Qua, 2009-03-18 às 09:04 -0300, dmanci...@gmail.com escreveu:
   Pessoal
  
   No Oracle(sqlplus) é possível o seguinte:
  
   select campo1, campo2
   from tabela
   where campo1 = variavel;
  
   Sendo que ao encontrar variavel, será aberto um prompt solicitando o
   valor... existe algo parecido no psql?
 
 
 http://guedesoft.net/blog/2008/04/07/exemplo-de-um-script-sql-interativo-no-postgresql/
 
  --
  Dickson S. Guedes
  mail/xmpp: gue...@guedesoft.net - skype: guediz
  http://guedesoft.net - http://planeta.postgresql.org.br
 
  ___
  pgbr-geral mailing list
  pgbr-geral@listas.postgresql.org.br
  https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
 
 ___
 pgbr-geral mailing list
 pgbr-geral@listas.postgresql.org.br
 https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral




-- 
Diego Mancilha
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Substituição de variável no psq l

2009-03-18 Por tôpico Rafael Garbin
Tem sim cara!
Olha esse link: http://planeta.postgresql.org.br/
Tem um post aqui que fala sobre isso!

2009/3/18 dmanci...@gmail.com dmanci...@gmail.com

 Pessoal

 No Oracle(sqlplus) é possível o seguinte:

 select campo1, campo2
 from tabela
 where campo1 = variavel;

 Sendo que ao encontrar variavel, será aberto um prompt solicitando o
 valor... existe algo parecido no psql?

 --
 Diego Mancilha

 ___
 pgbr-geral mailing list
 pgbr-geral@listas.postgresql.org.br
 https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Substituição de variável no psq l

2009-03-18 Por tôpico Dickson S. Guedes
Em Qua, 2009-03-18 às 09:04 -0300, dmanci...@gmail.com escreveu:
 Pessoal
 
 No Oracle(sqlplus) é possível o seguinte:
 
 select campo1, campo2 
 from tabela
 where campo1 = variavel;
 
 Sendo que ao encontrar variavel, será aberto um prompt solicitando o
 valor... existe algo parecido no psql?

http://guedesoft.net/blog/2008/04/07/exemplo-de-um-script-sql-interativo-no-postgresql/

-- 
Dickson S. Guedes 
mail/xmpp: gue...@guedesoft.net - skype: guediz
http://guedesoft.net - http://planeta.postgresql.org.br


signature.asc
Description: Esta é uma parte de mensagem	assinada digitalmente
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Substituição de variável no psq l

2009-03-18 Por tôpico Rudinei Dias
E aíd Diego, beleza?

Aí vai um exemplo.
Abraço,

Rudinei

The \set command sets a variable, and \unset removes a variable. To
access a variable you precede its name with a colon. The \set command
used alone lists all defined variables.

Figure  shows the use of psql variables.

test= \set num_var 4
test= SELECT :num_var;
 ?column?
--
4
(1 row)

test= \set operation SELECT
test= :operation :num_var;
 ?column?
--
4
(1 row)

test= \set str_var '\'My long string\''
test= \echo :str_var
'My long string'
test= SELECT :str_var;
?column?

 My long string
(1 row)

links:
http://www.postgresql.org/files/documentation/books/aw_pgsql/node143.html
http://www.faqs.org/docs/ppbook/x19832.htm

2009/3/18 Dickson S. Guedes lis...@guedesoft.net

 Em Qua, 2009-03-18 às 09:04 -0300, dmanci...@gmail.com escreveu:
  Pessoal
 
  No Oracle(sqlplus) é possível o seguinte:
 
  select campo1, campo2
  from tabela
  where campo1 = variavel;
 
  Sendo que ao encontrar variavel, será aberto um prompt solicitando o
  valor... existe algo parecido no psql?

 http://guedesoft.net/blog/2008/04/07/exemplo-de-um-script-sql-interativo-no-postgresql/

 --
 Dickson S. Guedes
 mail/xmpp: gue...@guedesoft.net - skype: guediz
 http://guedesoft.net - http://planeta.postgresql.org.br

 ___
 pgbr-geral mailing list
 pgbr-geral@listas.postgresql.org.br
 https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral