Skip site navigation (1) Skip section navigation (2)

help with conversion functions

From: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: help with conversion functions
Date: 2004-07-26 06:46:25
Message-ID: 77ED2BF75D59D1439F90412CC5B109740F5543F8@ie10-sahara.hiso.honeywell.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,

I have written a function to update values in a table. The table structure
is as follows: 
CREATE TABLE PointAttributes(AttributeId BIGINT NOT NULL,
				PointId BIGINT NOT NULL,
				StrValue VARCHAR(255),
				NumValue FLOAT);

Based on the attribute datatype, i have to fill up either StrValue(if
datatype is character) or NumValue(if the datatype is numeric).

My function just updates the above table by providing values. The function
is as follows: 

CREATE OR REPLACE FUNCTION PP_UpdatePointParameter(varchar,varchar,text);

the first 2 parameters specify the attributename and pointname. I am passing
the value as text in the 3rd parameter. 
Now if the datatype is character, i have to set the StrValue field of the
table with text value else if the datatype of the attribute is numeric then
i have to convert the text to the suitable numeric type and assign it to the
NumValue.

I have problems in doing that.....i have used TO_NUMERIC(text) as specified
in the POSTGRESQL DOCUMENTATION. When i execute the function, it says 
function to_numeric("unknown") does not exist. You may need to add explicit
type casts.

And also i am not sure what the return type of my function should. I have to
just update the table. 
I need help on this.





> With Best Regards 
> Pradeep Kumar P J 
> 
> 

Responses

pgsql-novice by date

Next:From: Devrim GUNDUZDate: 2004-07-26 07:26:55
Subject: Re: Load Balancing / Failover cluster
Previous:From: Devrim GUNDUZDate: 2004-07-26 05:23:30
Subject: Re: Request for information about 3rd party support for

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group