Tom Lane wrote:
But postgres 7 rejects this with "ERROR: cannot cast type character
varying to integer".
As a general rule, you need to be more specific than that about which
version you are working with ;-)
You may find that username::text::integer will work, depending
Bryce Nesbitt (mailing list account) wrote:
Tom Lane wrote:
As a general rule, you need to be more specific than that about which
version you are working with ;-)
Oooh, I'd be so happy to. But I don't know. Yes, I don't know.
I know which version of psql is installed on my local
Cool, thanks.
PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
20030502 (Red Hat Linux 3.2.3-20)
Richard Huxton wrote:
SELECT version();
---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster
How can I force a character field to sort as a numeric field?
I've got something like this:
Postgres= SELECT username,last_name
FROM eg_member ORDER BY username;
--+---
0120 | Foley
1| Sullivan
10 | Guest
11 | User
(5 rows)
(I can't
Check out the function to_number()
In particular here's an example...
If a field named section is text containing numbers:
ORDER BY to_number(t.section, text())
If the field can also contain non-numerals such as 3a, 3b, and you want
3a to show first then do this:
ORDER BY
Bryce W Nesbitt [EMAIL PROTECTED] writes:
SELECT username,last_name
FROM eg_member ORDER BY username::integer;
But postgres 7 rejects this with ERROR: cannot cast type character
varying to integer.
As a general rule, you need to be more specific than that about which
version you are
On Wednesday 01 September 2004 09:24, Stephan Szabo wrote:
On Wed, 1 Sep 2004, sad wrote:
On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote:
On Aug 31, 2004, at 8:24 PM, sad wrote:
and i am still desire to know _WHY_ there are no predefined cast for
BOOL ?
and at the same
On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote:
On Sep 1, 2004, at 2:41 PM, sad wrote:
On Wednesday 01 September 2004 09:24, Stephan Szabo wrote:
There's a fairly accepted convention for integer representations.
There's no such convention for boolean representations.
On Sep 1, 2004, at 2:55 PM, sad wrote:
On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote:
On Sep 1, 2004, at 2:41 PM, sad wrote:
On Wednesday 01 September 2004 09:24, Stephan Szabo wrote:
There's a fairly accepted convention for integer representations.
There's no such convention for
There's a difference between an output function and a cast to text.
One gives you an external representation of the data for end use. The
other gives you an internal representation for manipulation.
And at the same time
't'::TEXT can be casted to BOOL
't'::BOOL
but reverse.
On Wed, 1 Sep 2004, sad wrote:
There's a difference between an output function and a cast to text.
One gives you an external representation of the data for end use. The
other gives you an internal representation for manipulation.
And at the same time
't'::TEXT can be casted to BOOL
sad wrote:
On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote:
On Sep 1, 2004, at 2:41 PM, sad wrote:
On Wednesday 01 September 2004 09:24, Stephan Szabo wrote:
There's a fairly accepted convention for integer representations.
There's no such convention for boolean representations.
Peter Eisentraut [EMAIL PROTECTED] writes:
The cast to text, however, is part of the data model, and it has to be
both natural and universal. I think you agree that there is no
universal, obvious correspondence between character strings and boolean
values, at least not nearly as universal
On Wed, 1 Sep 2004, Tom Lane wrote:
Peter Eisentraut [EMAIL PROTECTED] writes:
The cast to text, however, is part of the data model, and it has to be
both natural and universal. I think you agree that there is no
universal, obvious correspondence between character strings and boolean
hello
why BOOL can not be casted to TEXT
...nevertheless BOOL has a textual (output) representation 't' and 'f' letters
why not to use this fact to define cast to TEXT ?
---(end of broadcast)---
TIP 8: explain analyze is your friend
On Aug 31, 2004, at 6:06 PM, sad wrote:
why BOOL can not be casted to TEXT
nevertheless BOOL has a textual (output) representation 't' and
'f' letters
why not to use this fact to define cast to TEXT ?
I'm not sure of the reason why there isn't a built-in cast from boolean
to text, though I'm
you wrote:
you can use CREATE CAST to make your own cast from boolean to text.
thnx it helps.
and i am still desire to know _WHY_ there are no predefined cast for BOOL ?
and at the same time there are predefined casts for INT and FLOAT..
---(end of
sad wrote:
you wrote:
you can use CREATE CAST to make your own cast from boolean to text.
thnx it helps.
and i am still desire to know _WHY_ there are no predefined cast for BOOL ?
and at the same time there are predefined casts for INT and FLOAT..
I'd like to understand in what context you
On Aug 31, 2004, at 8:24 PM, sad wrote:
and i am still desire to know _WHY_ there are no predefined cast for
BOOL ?
and at the same time there are predefined casts for INT and FLOAT..
I think the main reason is what is the proper textual representation of
BOOLEAN? True, PostgreSQL returns
On Tuesday 31 August 2004 16:22, Geoffrey wrote:
sad wrote:
you wrote:
you can use CREATE CAST to make your own cast from boolean to text.
thnx it helps.
and i am still desire to know _WHY_ there are no predefined cast for BOOL
? and at the same time there are predefined casts for
On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote:
On Aug 31, 2004, at 8:24 PM, sad wrote:
and i am still desire to know _WHY_ there are no predefined cast for
BOOL ?
and at the same time there are predefined casts for INT and FLOAT..
I think the main reason is what is the
PLEASE NOTE :
select 1::int8::bit(64);
0001
select 1::int4::bit(64);
0001
select 1::int2::bit(64);
ERROR: Cannot cast type smallint to bit
the last is a great surprise for
Joe Conway [EMAIL PROTECTED] writes:
Not possible in current releases, but it will be in 7.4 (about to start beta).
It looks like this:
Well there is the int_array_aggregate function in the contrib/intagg
directory. It has to be compiled separately, and it has a few quirks (like the
arrays
I have a rather odd table structure that I would like to simplify to be a view
(for some definition of simplify). The current idea I have is to shovel
values from multiple rows in one table into an array in the view. The tables
look something like this:
create table person (
id serial,
Mike Rylander wrote:
I have a rather odd table structure that I would like to simplify to be a view
(for some definition of simplify). The current idea I have is to shovel
values from multiple rows in one table into an array in the view. The tables
look something like this:
snip
Is anything
Thank you! This is great news. Is there a projected release date for 7.4?
Also, is there a published roadmap, or should I just get on the developers
list?
Thanks again.
---
Mike Rylander
On Friday 18 July 2003 05:34 pm, Joe Conway wrote:
Mike Rylander wrote:
I have a rather odd table
Mike Rylander wrote:
Thank you! This is great news. Is there a projected release date for 7.4?
Not exactly an officially projected date, but in the past IIRC beta/RC
has lasted 2 to 3 months, so I'd start looking for a 7.4 release in October.
Also, is there a published roadmap, or should I
Hi
psql -V
psql (PostgreSQL) 7.3
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
12:00:00
(1 row)
psql -V
psql (PostgreSQL) 7.3.2
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
00:00:00
(1 row)
Did I miss something? I looked into 'history'
Tomasz Myrta [EMAIL PROTECTED] writes:
psql (PostgreSQL) 7.3.2
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
00:00:00
(1 row)
I get 12:00:00 here, using 7.3.3 ... platform-specific problem maybe?
regards, tom lane
Dnia 2003-06-16 16:53, Uytkownik Tom Lane napisa:
Tomasz Myrta [EMAIL PROTECTED] writes:
psql (PostgreSQL) 7.3.2
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
00:00:00
(1 row)
I get 12:00:00 here, using 7.3.3 ... platform-specific problem maybe?
Default Debian
Tomasz Myrta [EMAIL PROTECTED] writes:
Dnia 2003-06-16 16:53, U¿ytkownik Tom Lane napisa³:
Tomasz Myrta [EMAIL PROTECTED] writes:
psql (PostgreSQL) 7.3.2
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
00:00:00
(1 row)
I get 12:00:00 here, using 7.3.3 ...
On Mon, 16 Jun 2003, Tom Lane wrote:
Tomasz Myrta [EMAIL PROTECTED] writes:
Dnia 2003-06-16 16:53, U¿ytkownik Tom Lane napisa³:
Tomasz Myrta [EMAIL PROTECTED] writes:
psql (PostgreSQL) 7.3.2
SELECT cast(cast('1 day 12 hours' as interval) as time);
time
--
Dnia 2003-06-16 17:17, Uytkownik Tom Lane napisa:
What do you get from pg_config --configure? What's the hardware
platform --- i386, or something else? Can anyone else reproduce this,
on any platform?
The platform is i386.
There was no pg_config file in binary package. After copying this file
Antti Haapala [EMAIL PROTECTED] writes:
'--enable-integer-datetimes' (could be this?)
Bingo. I can reproduce it with that configure choice.
Should have the answer soon ...
regards, tom lane
---(end of broadcast)---
TIP
Antti Haapala [EMAIL PROTECTED] writes:
It's also Debian (3.0).
On investigation the interval_time() function was completely broken for
the --enable-integer-datetimes case --- it was reducing the interval
value modulo one second, rather than modulo one day as intended.
I also noticed that
Hi all.
Recently I face some problem with casting character type variable and
varchar variable.
The situation was like: I had 2 table, on table A, the user_name is
defined
as character(32), and table B uses varchar(32). I have 1 function and
a
trigger to manipulate with these data.
Here's
Hi all.
Recently I face some problem with casting character type variable and
varchar variable.
The situation was like: I had 2 table, on table A, the user_name is defined
as character(32), and table B uses varchar(32). I have 1 function and a
trigger to manipulate with these data.
Here's the
Hi,
I am using postgresql 7.2.1.
How do i cast an integer value to boolean? I did try the below sequence of
SQLs and was little bit confused, by the way it behaves. It casts the
integer value to boolean in one case but not ever again.
bhuvan= SELECT count(*)::int::boolean from my_table;
ERROR:
On Fri, 16 Aug 2002, Bhuvan A wrote:
How do i cast an integer value to boolean?
You can always do something like this:
select not count(*) = 0 from my_table;
Basically, for any integer i, convert to boolean with: not i = 0
--
Tod McQuillin
---(end of
select not count(*) = 0 from my_table;
Basically, for any integer i, convert to boolean with: not i = 0
Or i != 0 of course...
Chris
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send
Cedar Cox writes:
When would one want to use cast()? What is the difference between cast
and :: ? After a quick look in the documentation I couldn't find
anything..
cast() is SQL, :: is traditional Postgres. :: may go away in the distant
future to make room for the SQL feature that is
On Mon, Apr 09, 2001 at 05:57:45PM +0200, Peter Eisentraut wrote:
Cedar Cox writes:
When would one want to use cast()? What is the difference between cast
and :: ? After a quick look in the documentation I couldn't find
anything..
cast() is SQL, :: is traditional Postgres. :: may
Ross J. Reedstrom writes:
FYI, I can't find an occurance of '::' that's not part of '::=' in either
SQL1992.txt or the ansi-iso-[sql]-1999.txt files I've got.
SQL 1999 6.12
static method invocation ::=
user-defined type double colon method name [ SQL argument list ]
That syntax even
On Mon, Apr 09, 2001 at 06:53:13PM +0200, Peter Eisentraut wrote:
Ross J. Reedstrom writes:
FYI, I can't find an occurance of '::' that's not part of '::=' in either
SQL1992.txt or the ansi-iso-[sql]-1999.txt files I've got.
SQL 1999 6.12
static method invocation ::=
Hans-Jrgen Schnig writes:
Is there any possibility to cast numeric to text in Postgres 7.0.3?
shop=# select cast(price as text) from products;
ERROR: Cannot cast type 'numeric' to 'text'
Use the to_char() function.
--
Peter Eisentraut [EMAIL PROTECTED] http://yi.org/peter-e/
Is there any possibility to cast numeric to text in Postgres 7.0.3?
shop=# select cast(price as text) from products;
ERROR: Cannot cast type 'numeric' to 'text'
Hans
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
Thomas SMETS writes:
I'm removing charaters from a String which should be numbers.
I then want to make calculations on these numbers (calculate the ISBN
number).
(You might want to look into contrib/isbn_issn for an isbn type.)
Do I have to cast the char into int's before I can do the
Hi,
In pgsql
I'm removing charaters from a String which should be numbers.
I then want to make calculations on these numbers (calculate the ISBN
number).
Do I have to cast the char into int's before I can do the calulations.
Also I looked in the User manual but could not find the
48 matches
Mail list logo