progolf069
Programmer
Greetings Techies:
I am seeking some assistance in PSQL - Typecasting.
I have a product catalog created, and I am wanting to implement a price search feature. I want to allow the customer the oppurnunity to input a range of prices (high/low) that they are willing to pay for a product. Then I will query the database, and return anything that matches their search. The problem that I am running into, is that I have the money field in the database setup as type: money. I need to be able to typecast it to a double, or some floating point value for numeric comparison, as money is a "string" datatype (for apperance on the website).
Here is what I have for results up to now:
Any support you maybe able to provide will be greatly appreciated. Have a great day!
Ian Wickline
Webmaster, catalog.ksmerchandise.com
I am seeking some assistance in PSQL - Typecasting.
I have a product catalog created, and I am wanting to implement a price search feature. I want to allow the customer the oppurnunity to input a range of prices (high/low) that they are willing to pay for a product. Then I will query the database, and return anything that matches their search. The problem that I am running into, is that I have the money field in the database setup as type: money. I need to be able to typecast it to a double, or some floating point value for numeric comparison, as money is a "string" datatype (for apperance on the website).
Here is what I have for results up to now:
Code:
ksonline=# select sku, yourcost from catitem where yourcost < 100.00;
ERROR: Unable to identify an operator '<' for types 'money' and 'float8'
You will have to retype this query using an explicit cast
ksonline=#
ksonline=# select sku, yourcost from catitem where yourcost::real < 100.00;
ERROR: Cannot cast type 'money' to 'float4'
ksonline=#
ksonline=# select sku, yourcost from catitem where yourcost::double precision < 100.00;
ERROR: Cannot cast type 'money' to 'float8'
ksonline=#
Any support you maybe able to provide will be greatly appreciated. Have a great day!
Ian Wickline
Webmaster, catalog.ksmerchandise.com