Search Postgresql Archives

a math function with error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I am new in this group and I've been working a lot in this function but it didnt work good enought until now. Here is the thing: I use some sql strings that calcultes a coll with another and I get the results. For exemple I have two tables that has many float, texts or numeric colls.

Like Tab01 with V01 as varchar(10), V02 as numeric, V03 as float; and Tab02 with F01 as varchar(20), F02 as float, F03 as float, F04 as numeric. In the colls of varchar there will be times that there is a number and others not.

There will be times that I will need to do a sum or division or any other math. Just like this:
SELECT Tab01.V01 + Tab02.F03 FROM Tab01, Tab02
SELECT Tab01.V02 / Tab02.F01 FROM Tab01, Tab02

Well here is the thing, I get some errors by doing this because we can have any results. So I need a function that tests this like:
evalthis(Tab01.V02 / Tab02.F01);

If I send something like 25 / '5' I get the result, 5
but if I send 25 / '0' I get null (division_by_zero)
or when I send 25 / 'textcrap' I get null too....

Is there any chance to get something like this?
sorry for my bad English

regards,
Arthur

		
_______________________________________________________ Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora! http://br.mobile.yahoo.com/mailalertas/



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux