Problem s vypoctem v pgsql
Karel Zak
zakkr na zf.jcu.cz
Čtvrtek Leden 13 18:48:14 CET 2005
On Thu, 2005-01-13 at 15:07 +0100, Ondrej Kolonicny wrote:
> Karel Zak wrote:
>
> >On Thu, 2005-01-13 at 13:12 +0100, Ondrej Kolonicny wrote:
> >
> >
> >>Ahoj vsem,
> >>
> >>mam tenhle dotaz:
> >>select to_number(to_char(current_timestamp,
> >>'YYYY'),'9999')-(to_number(substring('79999', 1, 2),'99')+1900) ;
> >>(takhle je funkcni)
> >>kdyz dam misto retezce '79999' nejakou polozku typu varchar z tabulky
> >>tak to prestane fungovat. Poradite nekdo jak to udelat ??
> >>
> >>
> >
> > A co je ta polozka typu varchar zac? Lze udelat
> >
> >select to_number(substring(polozka, 1, 2),'99') from tab;
> >
> >
> to prave nejde vrati to invalid input syntax for type numeric: " "
to_number() je definovano jako to_number(text, text) takze musite
zajistit aby ten substring() vracel nejaky string s alespon dvema cisly.
Karel
--
Karel Zak <zakkr na zf.jcu.cz>
Další informace o konferenci Test