CREATE OR REPLACE FUNCTION food600.tvor_cislo(
	text)
    RETURNS integer
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE ret BOOLEAN DEFAULT TRUE;
cc TEXT;
ccc TEXT;
i INTEGER DEFAULT 1;
BEGIN
cc:=TRIM(BOTH FROM $1);
IF length(cc)>0 THEN
	ccc:=REPLACE(cc,'1','');
	ccc:=REPLACE(ccc,'2','');
	ccc:=REPLACE(ccc,'3','');
	ccc:=REPLACE(ccc,'4','');
	ccc:=REPLACE(ccc,'5','');
	ccc:=REPLACE(ccc,'6','');
	ccc:=REPLACE(ccc,'7','');
	ccc:=REPLACE(ccc,'8','');
	ccc:=REPLACE(ccc,'9','');
	ccc:=REPLACE(ccc,'0','');
	ccc:=REPLACE(ccc,'-','');
	IF length(ccc)>0 THEN
		RETURN CAST('0' AS INTEGER);
	ELSE
		RETURN CAST(cc AS INTEGER);
	END IF;
ELSE
	RETURN CAST('0' AS INTEGER);
END IF;
END
$BODY$;
