Subject AW: [firebird-support] Converting with parameters stored in variables?
Author Check_Mail

Hello Karol,

 

yes, I know padding. In my case I would like to set the numeric parameters with two variables first.

 

  • Take the R11.3 into two variables f1 and f2 (f1 = 11, f2 = 3)
  • Set the numeric(:f1,:f2) without execute statements

 

Now I have it realized as following:

 

  c_anz = substring(t_str from 2 for (position( '.' in t_str)-2)); -- precision (t_str is ’11.3’ a string)

  select value_int from p_u_isnumeric(:c_anz) into :i_anz; -- check for integer and convert into an int

  c_anz2 = substring(t_str from (position('.' in t_str)+1) for 5); -- scale

  select value_int from p_u_isnumeric(:c_anz2) into :i_anz2;

  tmp_int = cast(z_str as double precision) * power(10,i_anz2); -- set the value, round it –z_str = double precision, the value to convert into a string (2.4 into 00000000002.400)

  tmp_str =  lpad(cast(tmp_int as varchar(15)),i_anz + i_anz2,'0');

  n_str = o_str || left(tmp_str,i_anz) || '.' || right(tmp_str,i_anz2) || '#'; -- set the decimalpoint

  suspend;

 

 

 

Von: firebird-support@yahoogroups.com <firebird-support@yahoogroups.com>
Gesendet: Donnerstag, 29. August 2019 16:55
An: firebird-support@yahoogroups.com
Betreff: ODP: [firebird-support] Converting with parameters stored in variables?

 

 

Hi

 

This is called padding.

Simple example (but not what you want you must padd also decimal point)

SELECT LPAD(CAST(100 AS NUMERIC(10,3)), 14, '0') FROM RDB$DATABASE

 

But you must tell us what is your real problem, as you need padding for what?

 

Pozdrawiam,

Karol Bieniaszewski