Re: [SQL] backup and document views and user functions

2010-08-30 Thread Hélder M . Vieira
Hi. I am looking for an easy way to backup views and functions. I want to store them in our version control system. Well... As far as I can see, for functions you should go to the 'pg_catalog' schema, table 'pg_proc'. In column 'prosrc' you will find the original text, but other attributes a

Re: [SQL] Problemas com Procedure no PostgreSQL

2009-04-17 Thread Hélder M . Vieira
ias nos select e update, uma vez que não há join envolvidos Cumprimentos, Hélder M. Vieira create or replace function trava_inadimplentes ( pdias_vencido integer, pund_local varchar(3), pcnpj varchar(18) ) returns boolean as $$ declare spermite_bloqueio varchar(1); inro_re

Re: [SQL] Problemas com Procedure no PostgreSQL

2009-04-17 Thread Hélder M . Vieira
Bom dia. ... acusado o seguinte erro "sintax error at or near "SELECT" at character 487", e infelizmente não conseguimos achar o que esta errado, dai peço ajuda aos colegas. Segue abaixo a procedure: ... IF ( pCNPJ = '' ) THEN BEGIN ... END IF ... Numa leitura sumária, parece-me qu

Re: [SQL] Having the sum of two queries

2007-07-16 Thread Hélder M . Vieira
... SELECT tot.status, COUNT(total) FROM( QUERY A UNION QUERY B ) AS tot GROUP BY tot.status But it doesn't works. It doesn't add the total columns with the same status... ... I guess you have two problems, if I understand what you're trying to do. - As Roberto Spier noted, 'sum' would be be

Re: [SQL] Removing duplicate rows

2007-02-06 Thread Hélder M . Vieira
eate temporary table mytesttable (like mymaintable excluding constraints excluding defaults); Regards, Hélder M. Vieira ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

Re: [SQL] Looping recordset

2007-01-25 Thread Hélder M . Vieira
selected rows or, perhaps, use the SELECT in the FOR..LOOP and subsequently perform the DELETE. Hélder M. Vieira ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command

Re: [SQL] distinct with sum

2006-07-09 Thread Hélder M . Vieira
sum there. The query: select distinct on (id_prod) id_prod, id_unit, sum(quantity) as result from products where determinant = false group by id_prod, id_unit select id_prod, id_unit, sum(quantity) as result from products where determinant = false group by id_prod, id_unit Hélder M. Vieira

[SQL] Re: [SQL] Problema com função UPPER

2006-06-20 Thread Hélder M . Vieira
Eduardo, creio que o problema decorre do jogo de caracteres usado... No meu caso, uma vez que vivo em Portugal, uso o jogo LATIN9 quando crio uma nova base de dados. Simplificando: CREATE DATABASE xpto WITH OWNER = postgres ENCODING = 'LATIN9' TABLESPACE = pg_default;

[SQL] Locale and pattern matching

2005-12-07 Thread Hélder M . Vieira
users: Until now, I've been selecting LATIN1 encoding, but after a few tests, I came to think that LATIN9 is a better option (the euro sign...). For those who regularly use LATIN9, what is your opinion ? Is it indeed a better option ? Thank you. Hélder M. Vieira LATIN CAPITA

Re: [SQL] max() unexpected type conversion

2005-11-21 Thread Hélder M . Vieira
This is true of just about everything, not only max() -- there are *no* functions yielding varchar in recent PG releases Thanks for the information. I added an explicit cast to the max() output and it works fine. Anyway, for those using VB, this is potentially hazardous. Knowing that the underl

[SQL] max() unexpected type conversion

2005-11-21 Thread Hélder M . Vieira
x27;); insert into test (testcol) values ('B'); insert into test (testcol) values ('B'); insert into test (testcol) values ('C'); insert into test (testcol) values ('C'); select max(testcol) from test; Thank you Hélder M. Vieira

Re: [SQL] how to do a find and replace

2005-11-17 Thread Hélder M . Vieira
-matching.html), it isn't mentioned in section '9.4. String Functions and Operators' (http://www.postgresql.org/docs/8.1/interactive/functions-string.html). Hélder M. Vieira ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] table listing queries

2005-08-25 Thread Hélder M . Vieira
Namely, in MySQL I can say: "SHOW TABLES FROM 'dbname'" to list tables in a database I'm not currently connected to. In MySQL, table definitions are replicated outside the database files, and might therefore be available without connecting to a specifc database. This probably happens because of

Re: [SQL] Fwd: How to encrypt a column

2005-08-11 Thread Hélder M . Vieira
I'm interested in encrypting an column in table. Are there any example using "C" to create the encrypted column, inserting and retreiving data to/from it? the table is: CREATE TABLE mytable ( id SERIAL PRIMARY KEY, crypted_content BYTEA ); I'm getting (null) in the field with the follow

Re: [SQL] 'select where' using multiple columns.

2005-08-05 Thread Hélder M. Vieira
Is there a way to do something like a 'select * where forename_1,forename_2,surname like '%String%' ?? You could try the following, but it won't get a medal for performance... SELECT * FROM xpto WHERE forename_1 LIKE '%String%' OR forename_2 LIKE '%String%' OR surname LIKE '%String%'