Thread: Help!!

Help!!

From
Edson Vilhena de Carvalho
Date:
Hi,

I hould like to know how cant I disable autocommit
using the windows version. I've tried "set autocommit
to off" in SQL but the message was : "ERROR:  SET
AUTOCOMMIT TO OFF is no longer supported". I've tried
"\set autocommit off" in the command-line, I have no
error but the autocommit its still ON.

My other problem is about triying to do functions
using plsql. It seems the diference is big but I don't
have any example. If any one has examples about out to
do it... It can also be examples about how to do them
in C, I'll trie to do the connection.


Thank you very much
Edson Carvalho






Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/

Time and date functions give me headaches!!

From
"Costin Manda"
Date:
  Hello,

I have a table with columns defines as varchar that have values in format
'YYYY-MM-DD HH:MM:SS'.

Now, if I do a
select timestamp '2005-10-10 10:10:10';
I get the value just fine. I can use abstime()::integer on the result to
find the unix timestamp. (This is the simplest way I could find, are there
any others?)

However, when I try doing the same with the values in the table I can't
get it to work.

select timestamp setuptime from billing; - error
select timestamp(setuptime) from billing; - error
select setuptime::timestamp from billing; - error (cannot cast type
character varying to timestamp without timezone!?)

So, how can I convert this string into a timestamp, pleeease! :(




-------------------------
E-Mail powered by MadNet.
http://www.madnet.ro/


Re: Time and date functions give me headaches!!

From
Csaba Nagy
Date:
Costin,

You could probably use one of the functions listed here:
file:///usr/share/doc/postgresql-7.4.2/html/functions-formatting.html
If you want the varchar -> date conversion to happen automatically, you
should study this chapter:
file:///usr/share/doc/postgresql-7.4.2/html/typeconv.html

HTH,
Csaba.

On Mon, 2005-04-11 at 11:40, Costin Manda wrote:
>   Hello,
>
> I have a table with columns defines as varchar that have values in format
> 'YYYY-MM-DD HH:MM:SS'.
>
> Now, if I do a
> select timestamp '2005-10-10 10:10:10';
> I get the value just fine. I can use abstime()::integer on the result to
> find the unix timestamp. (This is the simplest way I could find, are there
> any others?)
>
> However, when I try doing the same with the values in the table I can't
> get it to work.
>
> select timestamp setuptime from billing; - error
> select timestamp(setuptime) from billing; - error
> select setuptime::timestamp from billing; - error (cannot cast type
> character varying to timestamp without timezone!?)
>
> So, how can I convert this string into a timestamp, pleeease! :(
>
>
>
>
> -------------------------
> E-Mail powered by MadNet.
> http://www.madnet.ro/
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings


Re: Time and date functions give me headaches!!

From
Tom Lane
Date:
"Costin Manda" <siderite@madnet.ro> writes:
> select setuptime::timestamp from billing; - error (cannot cast type
> character varying to timestamp without timezone!?)

It works for me in 8.0.  In some releases you need to cast to text
first, for example in 7.4:

regression=# select '2005-10-10 10:10:10'::varchar::timestamp;
ERROR:  cannot cast type character varying to timestamp without time zone
regression=# select '2005-10-10 10:10:10'::varchar::text::timestamp;
      timestamp
---------------------
 2005-10-10 10:10:10
(1 row)


            regards, tom lane

Re: Time and date functions give me headaches!!

From
Scott Marlowe
Date:
On Mon, 2005-04-11 at 04:40, Costin Manda wrote:
>   Hello,
>
> I have a table with columns defines as varchar that have values in format
> 'YYYY-MM-DD HH:MM:SS'.
>
> Now, if I do a
> select timestamp '2005-10-10 10:10:10';
> I get the value just fine. I can use abstime()::integer on the result to
> find the unix timestamp. (This is the simplest way I could find, are there
> any others?)
>
> However, when I try doing the same with the values in the table I can't
> get it to work.
>
> select timestamp setuptime from billing; - error
> select timestamp(setuptime) from billing; - error
> select setuptime::timestamp from billing; - error (cannot cast type
> character varying to timestamp without timezone!?)
>
> So, how can I convert this string into a timestamp, pleeease! :(

More importantly, why are you storing your timestamps as strings?
Sotring them as timestamps is the proper way to do things.  It provides
bounds checking, and allows date maths to be done rather simply.