[SQL] cast type bytea to double precision

2012-02-17 Thread Amila Jayasooriya
HI All, I have a database column which type is bytea. It contains floats converted as byte array (4 bytes per one float) and encoding is Escape. I would be able to get corresponding bytea string using substring function. My question is how can I convert bytea string to float inside a SQL function

Re: [SQL] cast record type to array?

2010-05-28 Thread Gerardo Herzig
Jasen Betts wrote: > On 2010-05-26, Gerardo Herzig wrote: >> Hi all. Im not being able to cast a record variable into an array. >> >> Im writing a trigger, and i would like to store NEW (and OLD) as text[]. >> There is a way to do it in plpgsql? (w/o any contrib modules) > > why not store them as

Re: [SQL] cast record type to array?

2010-05-28 Thread Jasen Betts
On 2010-05-26, Gerardo Herzig wrote: > Hi all. Im not being able to cast a record variable into an array. > > Im writing a trigger, and i would like to store NEW (and OLD) as text[]. > There is a way to do it in plpgsql? (w/o any contrib modules) why not store them as text instead? new::text

[SQL] cast record type to array?

2010-05-26 Thread Gerardo Herzig
Hi all. Im not being able to cast a record variable into an array. Im writing a trigger, and i would like to store NEW (and OLD) as text[]. There is a way to do it in plpgsql? (w/o any contrib modules) thanks! Gerardo -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes

Re: [SQL] cast bool/int

2009-03-24 Thread Jasen Betts
On 2009-03-23, Zdravko Balorda wrote: > > Hi, > I need a casting operator from boolean to integer, you can use any expression > tu put in ALTER TABLE statment after USING. > > Any ideas? Thanks. CASE WHEN columname THEN 1 WHEN NOT columname THEN 0 ELSE NULL END -- Sent via pgsql-sql m

Re: [SQL] cast bool/int

2009-03-23 Thread Zdravko Balorda
CASE WHEN column='t' THEN 1 ELSE 0 END Or just CASE WHEN column THEN 1 ELSE 0 END. In the mean time I've got an elegant solution: alter ... ... column TYPE smallint USING column::boolean::int::smallint; It works, you wouldn't beleive it. ;) Zdravko -- Sent via pgsql-sql mailing list (pgsq

Re: [SQL] cast bool/int

2009-03-23 Thread Marcin Krawczyk
This: SELECT true::integer, false::integer also works on 8.1 -- regards mk 2009/3/23 Achilleas Mantzios > Στις Monday 23 March 2009 09:59:12 ο/η Zdravko Balorda έγραψε: > > > > Hi, > > I need a casting operator from boolean to integer, > > tu put in ALTER TABLE statment after USING. > > > > S

Re: [SQL] cast bool/int

2009-03-23 Thread Joshua Tolley
On Mon, Mar 23, 2009 at 10:18:31AM +0200, Achilleas Mantzios wrote: > Στις Monday 23 March 2009 09:59:12 ο/η Zdravko Balorda έγραψε: > > > > Hi, > > I need a casting operator from boolean to integer, > > tu put in ALTER TABLE statment after USING. > > > > Sorry in the above email i meant smth li

Re: [SQL] cast bool/int

2009-03-23 Thread Achilleas Mantzios
Στις Monday 23 March 2009 09:59:12 ο/η Zdravko Balorda έγραψε: > > Hi, > I need a casting operator from boolean to integer, > tu put in ALTER TABLE statment after USING. > Sorry in the above email i meant smth like CASE WHEN column='t' THEN 1 ELSE 0 END however SELECT 't'::boolean::int; int4 -

Re: [SQL] cast bool/int

2009-03-23 Thread Achilleas Mantzios
Στις Monday 23 March 2009 09:59:12 ο/η Zdravko Balorda έγραψε: > > Hi, > I need a casting operator from boolean to integer, > tu put in ALTER TABLE statment after USING. > How about CASE WHEN 't' THEN 1 ELSE 0 END > Any ideas? Thanks. > > Zdravko > > -- Achilleas Mantzios -- Sent via p

[SQL] cast bool/int

2009-03-23 Thread Zdravko Balorda
Hi, I need a casting operator from boolean to integer, tu put in ALTER TABLE statment after USING. Any ideas? Thanks. Zdravko -- 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] Cast in PG 8.3

2008-02-05 Thread Volkan YAZICI
Franklin Haut <[EMAIL PROTECTED]> writes: > I Tries create a cast but the function text doesn't exist more in PG 8.3 sql-createcast.html tells that "It is normally not necessary to create casts between user-defined types and the standard string types (text, varchar, and char(n)). PostgreSQ

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Tom Lane
Franklin Haut <[EMAIL PROTECTED]> writes: > Create Table temp (id int4); > insert into temp values (1215); > insert into temp values (1216); > insert into temp values (1217); > insert into temp values (1218); > insert into temp values (1219); > insert into temp values (1220); > insert into temp val

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Markus Bertheau
2008/2/6, Jaime Casanova <[EMAIL PROTECTED]>: > did you read the release notes? Obviously he did: > I Know that changing the SQL command to : > SELECT * FROM TEMP WHERE CAST(id AS TEXT) ilike ('%122%'); > work´s but for now isn't possible... :( > > > I Tries create a cast but the function text

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Li, Jingfa
@postgresql.org Subject: Re: [SQL] Cast in PG 8.3 On Feb 5, 2008 2:39 PM, Li, Jingfa <[EMAIL PROTECTED]> wrote: > check the typo -- "ilike" > that's not a typo, it's "case insensitive LIKE" -- regards, Jaime Casanova "Programming today is a race

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Jaime Casanova
On Feb 5, 2008 2:39 PM, Li, Jingfa <[EMAIL PROTECTED]> wrote: > check the typo -- "ilike" > that's not a typo, it's "case insensitive LIKE" -- regards, Jaime Casanova "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the univers

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Li, Jingfa
check the typo -- "ilike" -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jaime Casanova Sent: Tuesday, February 05, 2008 11:19 AM To: Franklin Haut Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Cast in PG 8.3 On Feb 5, 2008 2:22 PM, Fra

Re: [SQL] Cast in PG 8.3

2008-02-05 Thread Jaime Casanova
On Feb 5, 2008 2:22 PM, Franklin Haut <[EMAIL PROTECTED]> wrote: > > > Hi all, > > I´m testing the new version of PostgreSQL in windows plataform but i have a > problem. > > > In PG 8.2 > > Create Table temp (id int4); > insert into temp values (1215); > insert into temp values (1216); > insert int

[SQL] Cast in PG 8.3

2008-02-05 Thread Franklin Haut
Hi all, I´m testing the new version of PostgreSQL in windows plataform but i have a problem. In PG 8.2 Create Table temp (id int4); insert into temp values (1215); insert into temp values (1216); insert into temp values (1217); insert into temp values (1218); insert into temp values (1

Re: [SQL] Cast on character columns in views

2007-09-04 Thread Tom Lane
Richard Broersma Jr <[EMAIL PROTECTED]> writes: > --- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: >> But when I open a query tool window and do: >> SELECT * FROM view1; >> Now, again type1 column returns as bpchar. > This might be a good question to ask on the PGAdmin mailing list or even try

Re: [SQL] Cast on character columns in views

2007-09-04 Thread Richard Broersma Jr
--- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: > Ugh, I'm totally crazy with this views > I'm using pgadmin with postgres, when I clink on "view the data of > selected object" button all works fine. > But when I open a query tool window and do: > > SELECT * FROM view1; > Now, again type1 co

Re: [SQL] Cast on character columns in views

2007-09-04 Thread Richard Broersma Jr
--- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: > When I drop the view first , and then create again the view (in a > separated transaction), now the command works! (this is a bug?) Well according to the manual, it is working as it is intended to work: http://www.postgresql.org/docs/8.2/intera

Re: [SQL] Cast on character columns in views

2007-09-04 Thread Luiz K. Matsumura
Luiz K. Matsumura wrote: Richard Broersma Jr wrote: --- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: CREATE VIEW view1( id, col1, type1, type2) AS SELECT table1.id, table1.col1, CAST( table2.type1 AS CHARACTER( 3 )), NULL FROM table1 JOIN table2 ON table2.fk_tabl

Re: [SQL] Cast on character columns in views

2007-09-03 Thread Luiz K. Matsumura
Richard Broersma Jr wrote: --- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: CREATE VIEW view1( id, col1, type1, type2) AS SELECT table1.id, table1.col1, CAST( table2.type1 AS CHARACTER( 3 )), NULL FROM table1 JOIN table2 ON table2.fk_table1 = table1.id UNION ALL SE

Re: [SQL] Cast on character columns in views

2007-09-03 Thread Richard Broersma Jr
--- "Luiz K. Matsumura" <[EMAIL PROTECTED]> wrote: > CREATE VIEW view1( id, col1, type1, type2) AS > SELECT table1.id, >table1.col1, >CAST( table2.type1 AS CHARACTER( 3 )), >NULL > FROM table1 > JOIN table2 ON table2.fk_table1 = table1.id > UNION ALL > SELECT table1.id,

[SQL] Cast on character columns in views

2007-09-03 Thread Luiz K. Matsumura
Hello, I have a scenario like this: CREATE TABLE table1 ( id serial NOT NULL, col1 character varying(30), CONSTRAINT pk_table1 PRIMARY KEY (id) ); CREATE TABLE table2 ( fk_table1 integer, type1 character(3), id serial NOT NULL, CONSTRAINT pk_table2 PRIMARY KEY (id) ); CREATE TABLE table

Re: [SQL] cast

2005-10-18 Thread Dan Feiveson
I believe int8(n.udf4) will do the trick for you. - Original Message - From: "Judith Altamirano Figueroa" <[EMAIL PROTECTED]> To: Sent: Friday, October 14, 2005 12:08 PM Subject: [SQL] cast > Hello I have a query that ran in 7.0.2, but in 8.0.1 does not, the

Re: [SQL] cast

2005-10-14 Thread Andrew Sullivan
On Fri, Oct 14, 2005 at 01:08:43PM -0500, Judith Altamirano Figueroa wrote: > Hello I have a query that ran in 7.0.2, but in 8.0.1 does not, the query > is the next: It'd help if we could see the table schema and the error message. A -- Andrew Sullivan | [EMAIL PROTECTED] When my information c

[SQL] cast

2005-10-14 Thread Judith Altamirano Figueroa
Hello I have a query that ran in 7.0.2, but in 8.0.1 does not, the query is the next: select n.factura, n.venta_neta, c.nombre_cli || ' ' || c.apellido_pat_cli || ' ' || coalesce (c.apellido_mat_cli,''), date(n.fecha_hora_factura),

Re: [SQL] Cast NULL into Timestamp?

2004-12-11 Thread Frank Bax
At 12:11 AM 12/11/04, Josh Berkus wrote: Wei, > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_relevant_table; I don't think you're reporting the error exactly as it happened. Try cutting and pasting your actual PSQL session into your e-mail. Perhaps

Re: [SQL] Cast NULL into Timestamp?

2004-12-10 Thread Steve Crawford
On Friday 10 December 2004 11:24 am, Wei Weng wrote: > I have a table > > create table temp > ( > tempdatetimestamp, > tempnamevarchar(10) > ); > > And I tried to insert the following: > > insert into table temp (tempname, tempdate) > select distinct 'tempname', null fro

Re: [SQL] Cast NULL into Timestamp?

2004-12-10 Thread Stephan Szabo
On Fri, 10 Dec 2004, Wei Weng wrote: > I have a table > > create table temp > ( > tempdatetimestamp, > tempnamevarchar(10) > ); > > And I tried to insert the following: > > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_re

Re: [SQL] Cast NULL into Timestamp?

2004-12-10 Thread Josh Berkus
Wei, > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_relevant_table; I don't think you're reporting the error exactly as it happened. Try cutting and pasting your actual PSQL session into your e-mail. Perhaps you are mixing up the column order?

[SQL] Cast NULL into Timestamp?

2004-12-10 Thread Wei Weng
I have a table create table temp ( tempdatetimestamp, tempnamevarchar(10) ); And I tried to insert the following: insert into table temp (tempname, tempdate) select distinct 'tempname', null from some_other_relevant_table; And I got an error that says "column "tempda

Re: [SQL] cast varchar to numeric/money

2003-11-21 Thread Tomasz Myrta
Dnia 2003-11-21 19:26, Użytkownik Yudie napisał: I don't have to_numeric function in my 7.2.2 postgre. then it can resolve it with: cast(substr(varcharcolumn,0) as float4) Read once again. The function is not "to_numeric", but "to_number". You can read about this function in manual: 6.7. Data Typ

Re: [SQL] cast varchar to numeric/money

2003-11-21 Thread Yudie
TECTED]> Sent: Friday, November 21, 2003 11:55 AM Subject: Re: [SQL] cast varchar to numeric/money On Fri, Nov 21, 2003 at 11:47:42 -0600, Yudie <[EMAIL PROTECTED]> wrote: > Hi guys, > > I know it's impossible to just cast varchar to any numeric datatype, > but is

Re: [SQL] cast varchar to numeric/money

2003-11-21 Thread Bruno Wolff III
On Fri, Nov 21, 2003 at 11:47:42 -0600, Yudie <[EMAIL PROTECTED]> wrote: > Hi guys, > > I know it's impossible to just cast varchar to any numeric datatype, > but is there another function/ custom function or any way to force to do > that convertion. You can use to_number to go from text to num

[SQL] cast varchar to numeric/money

2003-11-21 Thread Yudie
Hi guys, I know it's impossible to just cast varchar to any numeric datatype, but is there another function/ custom function or any way to force to do that convertion. please help Thanks.. Yudie ---(end of broadcast)--- TIP 9: the planner will i

Re: [SQL] cast of integer to bool doesn't work (anymore?)

2003-03-21 Thread Achilleus Mantzios
On Fri, 21 Mar 2003, Eric Veldhuyzen wrote: > On Fri, Mar 21, 2003 at 04:46:17PM -0200, Achilleus Mantzios wrote: > > > > Currently (7.3) all input can be handled if fed as text. > > So what you can do is simply: > > > > my $sth = $dbh->prepare( > > "INSERT INTO object_def (name, meant_as_

Re: [SQL] cast of integer to bool doesn't work (anymore?)

2003-03-21 Thread Eric Veldhuyzen
On Fri, Mar 21, 2003 at 04:46:17PM -0200, Achilleus Mantzios wrote: > > Currently (7.3) all input can be handled if fed as text. > So what you can do is simply: > > my $sth = $dbh->prepare( > "INSERT INTO object_def (name, meant_as_subobject) VALUES (?,?)"); > $sth->execute('test', '0');

Re: [SQL] CAST from VARCHAR to INT

2003-01-27 Thread Luke Pascoe
EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, January 24, 2003 6:58 PM Subject: Re: [SQL] CAST from VARCHAR to INT > > > (Postgres 7.2.1) > > > > I screwed up when I was designing a table a while back and made a column a > > VARCHAR that referenced (a

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread Tom Lane
daq <[EMAIL PROTECTED]> writes: > Make your life easier! :) You must write a function like > this: > create function "int4"(character varying) returns int4 as ' >DECLARE > input alias for $1; >BEGIN > return (input::text::int4); >END; > ' language

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread daq
Hello! Like others said you can't cast varchar to int directly. Make your life easier! :) You must write a function like this: create function "int4"(character varying) returns int4 as ' DECLARE input alias for $1; BEGIN return (input::text::int4); E

Re: [SQL] CAST from VARCHAR to INT

2003-01-23 Thread Tom Lane
"Luke Pascoe" <[EMAIL PROTECTED]> writes: > Now I'm trying to correct my mistake, I've created a new table and I'm > trying to INSERT INTO...SELECT the data into it, but it's complaining that > it can't stick a VARCHAR into an INT. All the values in the column are valid > integers (the foreign key

Re: [SQL] CAST from VARCHAR to INT

2003-01-23 Thread Bhuvan A
> (Postgres 7.2.1) > > I screwed up when I was designing a table a while back and made a column a > VARCHAR that referenced (and should have been) an INT. > > Now I'm trying to correct my mistake, I've created a new table and I'm > trying to INSERT INTO...SELECT the data into it, but it's compla

[SQL] CAST from VARCHAR to INT

2003-01-23 Thread Luke Pascoe
(Postgres 7.2.1) I screwed up when I was designing a table a while back and made a column a VARCHAR that referenced (and should have been) an INT. Now I'm trying to correct my mistake, I've created a new table and I'm trying to INSERT INTO...SELECT the data into it, but it's complaining that it c

Re: [SQL] cast lo to oid

2002-11-08 Thread Nekta Katz
L PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [SQL] cast lo to oid Date: Thu, 07 Nov 2002 10:16:21 -0500 "Nekta Katz" <[EMAIL PROTECTED]> writes: > I have the following table > create table scan_docs ( > docid serial, > shipno numeric(10), > sc

Re: [SQL] cast lo to oid

2002-11-07 Thread Nekta Katz
L PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [SQL] cast lo to oid Date: Thu, 07 Nov 2002 10:16:21 -0500 "Nekta Katz" <[EMAIL PROTECTED]> writes: > I have the following table > create table scan_docs ( > docid serial, > shipno numeric(10), > scanlo,

Re: [SQL] cast lo to oid

2002-11-07 Thread Tom Lane
"Nekta Katz" <[EMAIL PROTECTED]> writes: > I have the following table > create table scan_docs ( > docid serial, > shipno numeric(10), > scanlo, > type text > ); > when I try to create the following rule > create rule "delete_scan_docs_lo" as > on delete to "scan_docs" > do

[SQL] cast lo to oid

2002-11-07 Thread Nekta Katz
Hi, I have the following table create table scan_docs ( docid serial, shipno numeric(10), scanlo, type text ); when I try to create the following rule create rule "delete_scan_docs_lo" as on delete to "scan_docs" do select lo_unlink (old.scan); I get the error message "psql:

Re: [SQL] cast

2001-10-22 Thread Stephan Szabo
On Mon, 22 Oct 2001, Esteban Gutierrez Abarzua wrote: > > hi. > > I wanna to make a query on this table(postgres system catalog): > > Attribute | Type| Modifier > --+---+-- > relname | name | > reltype | oid | > relowner | in

[SQL] cast

2001-10-22 Thread Esteban Gutierrez Abarzua
hi. I wanna to make a query on this table(postgres system catalog): Attribute | Type| Modifier --+---+-- relname | name | reltype | oid | relowner | integer | relam| oid | relpages | integer | reltup

Re: [SQL] CAST(ipaddress as text) -- HOW?

2001-07-20 Thread Bhuvan A
1, omid omoomi wrote: > Sorry friend, you are right. I could not do that too. :o > I'll look for it. > omid > > >From: Bhuvan A <[EMAIL PROTECTED]> > >To: omid omoomi <[EMAIL PROTECTED]> > >CC: [EMAIL PROTECTED] > >Subject: Re: [SQL] CAST(ipad

Re: [SQL] Cast '' (blank) to null date

2001-07-20 Thread Tom Lane
"Mattis Jiderhamn" <[EMAIL PROTECTED]> writes: > I'm trying to create a trigger so that, if I try to insert blank, that is > '', into a date field it will be converted to null so that I don't get > ERROR: Bad date external representation '' I don't think it's possible to do that with a trigger

[SQL] Cast '' (blank) to null date

2001-07-20 Thread Mattis Jiderhamn
Hi there everyone. I'm trying to create a trigger so that, if I try to insert blank, that is '', into a date field it will be converted to null so that I don't get ERROR: Bad date external representation '' I believe my ploblem is that I don't know the type of blank (''), and therefore do not

Re: [SQL] CAST(ipaddress as text) -- HOW?

2001-07-18 Thread Bhuvan A
hi, ipaddress::text is resulting in ERROR: Cannot cast type 'cidr' to 'text' how else we can??? Thankx. On Tue, 17 Jul 2001, omid omoomi wrote: > ie, > ipaddrss::text > > >From: Bhuvan A <[EMAIL PROTECTED]> > >To: [EMAIL PROTECTED] >

[SQL] CAST(ipaddress as text) -- HOW?

2001-07-17 Thread Bhuvan A
hi all, how can we cast an ipaddress(type cidr) to any other type? thankx in advance.. Regards, Bhuvaneswar. ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROT

[SQL] CAST Problem: Difference between insert a tuple in a table by function and by datasheet

2001-06-22 Thread DI Hasenöhrl
Now,I found the problem, but I don't know how to solve. It depends on type float8. I changed all type float to float8   In my function I make the following calculation: . update KalkPreislisten_float8 SET  kp_ep = rkontingent.k_ep::float8    -- this works correct   but I hav