[SQL] uuid on windows

2008-11-14 Thread Sabin Coanda
Hi there,

I installed Postgres "PostgreSQL 8.3.5, compiled by Visual C++ build 1400" 
on Windows OS, and I tried to check some uuid functions, for instance:
SELECT uuid_generate_v1();

But I found the following error message:
ERROR:  function uuid_generate_v1() does not exist
LINE 1: SELECT uuid_generate_v1()
   ^
HINT:  No function matches the given name and argument types. You might 
need to add explicit type casts.

Why ? What I should install more to have uuid functions ?

TIA,
Sabin



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] uuid on windows

2008-11-14 Thread Richard Huxton
Sabin Coanda wrote:
> Hi there,
> 
> I installed Postgres "PostgreSQL 8.3.5, compiled by Visual C++ build 1400" 
> on Windows OS, and I tried to check some uuid functions, for instance:
> SELECT uuid_generate_v1();
> 
> But I found the following error message:
> ERROR:  function uuid_generate_v1() does not exist

You'll want the uuid-ossp module:

http://www.postgresql.org/docs/8.3/static/datatype-uuid.html
http://www.postgresql.org/docs/8.3/static/uuid-ossp.html

I *think* it's one of the optional modules with recent installers, but I
don't run Windows routinely, so you'll have to check.

-- 
  Richard Huxton
  Archonet Ltd

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] uuid on windows

2008-11-14 Thread Sabin Coanda
I run the following script and now it works:

CREATE OR REPLACE FUNCTION uuid_generate_v1()
RETURNS uuid
AS '$libdir/uuid-ossp', 'uuid_generate_v1'
VOLATILE STRICT LANGUAGE C;

Similar for all the other defined uuid functions.

Unfortunatelly I experienced the same problem on linux version 8.3.5. after 
I installed the package. But there the same script doesn't work, and logs 
that the file is not found.

Sabin 



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] uuid on windows

2008-11-14 Thread Richard Huxton
Sabin Coanda wrote:
> I run the following script and now it works:
> 
> CREATE OR REPLACE FUNCTION uuid_generate_v1()
> RETURNS uuid
> AS '$libdir/uuid-ossp', 'uuid_generate_v1'
> VOLATILE STRICT LANGUAGE C;
> 
> Similar for all the other defined uuid functions.

There should be a uuid-ossp.sql file with all those definitions in. Also
an "uninstall" version of the file too.

> Unfortunatelly I experienced the same problem on linux version 8.3.5. after 
> I installed the package. But there the same script doesn't work, and logs 
> that the file is not found.

The uuid-ossp.so file? Is it in the right directory? Is it readable by
the postgres user?

-- 
  Richard Huxton
  Archonet Ltd

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] trapping a NULL querystring error

2008-11-14 Thread Gerardo Herzig
Hi all. Inside a plpgsql function, i have a EXECUTE statement, which
sometimes seems to be receiving a null querystring.

Can i check that condition in a BEGIN..EXCEPTION block? Under which
condition?

Or should just check if that string is null?

Thanks!

Gerardo

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] trapping a NULL querystring error

2008-11-14 Thread A. Kretschmer
am  Fri, dem 14.11.2008, um  7:29:32 -0300 mailte Gerardo Herzig folgendes:
> Hi all. Inside a plpgsql function, i have a EXECUTE statement, which
> sometimes seems to be receiving a null querystring.
> 
> Can i check that condition in a BEGIN..EXCEPTION block? Under which
> condition?
> 
> Or should just check if that string is null?

I think, you should prevent NULL-strings. To ensure that you can use
coalesce. For instance:

sql:='SELECT FROM foo WHERE col = ' || coalesce(var, default-value)

Other way: you check if your sql-string is NULL or not


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] uuid on windows

2008-11-14 Thread Sabin Coanda
>
> I *think* it's one of the optional modules with recent installers, but I
> don't run Windows routinely, so you'll have to check.
>

I installed with full optional modules on Windows, but uuid is still 
missing. However, I found C:\Program 
Files\PostgreSQL\8.3\share\contrib\uuid-ossp.sql, I run it and it's ok now.

Thanx,
Sabin 



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Enc: Help to replace caracter

2008-11-14 Thread paulo matadr





I Need to replace string (" ) in the situation below :
 
select  clie_nmclientefrom cadastro.cliente where clie_nmcliente like 
'%"%'; 
 
result:
JOANA D"ARCALMEIDA"
EMLURB "P M R."
CECILIA D"CAGNO"
HELENA FERREIRA D"FREITAS"
JOSE M. "BARRACA DO BOLA"
FORTE" DUNAS BAR"
JOANA D"ARC R. DE SOUZA
ASSEMBLEIA DE DEUS"
USINA SALGADO"SUPRIMENTO 
JOSE MOURA  'BIGODE"
BEATRIZ MEDEIROS D"EMERY

Any help me to create pgPL/sql or funcion  to replace ( " )  to null value, I 
have many table with this.
Thanks for help



  Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

[SQL] raise doesn't add end of line

2008-11-14 Thread Sabin Coanda
Hi there,

I upgrade "PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by GCC gcc.exe 
(GCC) 3.4.2 (mingw-special)" to "PostgreSQL 8.3.5, compiled by Visual C++ 
build 1400", and I found that many RAISE statements in a function no more 
adds end of line (CR/LF) on every message. Just when the funcion ends a 
CR/LF is added in the log.

Is it the same behavior on linux os ?
Do you know a trick to get my old end of lines ?

TIA,
Sabin 



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Query to match location transitions

2008-11-14 Thread sub3

Hi,

I was hoping someone could help me build a better query.  I have a table of
time/locations.  Occasionally, we have multiple timestamps for the same
location.  I would like to remove those extra timestamps and only show the
transition from one location to another. So...

create table time_locations (
  id integer,
  timestamp double precision,
  location integer
)

Data:
1,1197605841,1
2,1197608001,2
3,1197609802,2
4,1197611951,2
5,1199145360,2
6,1199145480,3
7,1199147280,3
8,1199149140,3
9,1199151300,1
10,1199152000,3

I would like to return a table like:
1197605841,1,1197608001,2
1199145360,2,1199145480,3
1199149140,3,1199151300,1
1199151300,1,1199152000,3

The only way I can think of to do this would be a procedure which would do a
large loop over the
table (sorted by time) returning a row when last.location <> this.location. 
However, when I try this on a
large table, it seems like the 'select into' doesn't order & ruins the whole
solution.
Is there a query approach?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Query-to-match-location-transitions-tp20506709p20506709.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Enc: Help to replace caracter

2008-11-14 Thread Raj Mathur
On Friday 14 Nov 2008, paulo matadr wrote:
> I Need to replace string (" ) in the situation below :
>
> select  clie_nmclientefrom cadastro.cliente where clie_nmcliente
> like '%"%';
>
> result:
> JOANA D"ARCALMEIDA"
> EMLURB "P M R."
> CECILIA D"CAGNO"
> HELENA FERREIRA D"FREITAS"
> JOSE M. "BARRACA DO BOLA"
> FORTE" DUNAS BAR"
> JOANA D"ARC R. DE SOUZA
> ASSEMBLEIA DE DEUS"
> USINA SALGADO"SUPRIMENTO
> JOSE MOURA  'BIGODE"
> BEATRIZ MEDEIROS D"EMERY
>
> Any help me to create pgPL/sql or funcion  to replace ( " )  to null
> value, I have many table with this. Thanks for help

For a single field, you can use something like this to achieve your 
objective (this will delete all " characters in the field):

update cadastro.cliente
  set clie_nmcliente = regexp_replace(clie_nmcliente, '"', '', 'g')
  where clie_nmcliente like '%"%';  -- delete all ": not tested!

You could replace the '' with some other string to replace all " with 
that string.

It may be quicker to edit an ASCII dump of the database and reload it if 
you want to do the same replacement in multiple fields in multiple 
tables.

Regards,

-- Raju
-- 
Raj Mathur[EMAIL PROTECTED]  http://kandalaya.org/
   GPG: 78D4 FC67 367F 40E2 0DD5  0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/   ||   It is the mind that moves

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql