AW: AW: [firebird-support] Converting with parameters stored in variables?
Helle Karol, thank you, now it works and it is more easier. I have modified this: SELECT lpad(cast(TRUNC(x.a) as integer), :i_anz, '0') || '.' || lpad((X.A-TRUNC(X.A))*X.B, 3, '0') FROM (SELECT cast(:z_str as double precision) AS A, POWER(10,:i_anz2) AS B FROM RDB$DATABASE) X Without cast as integer I get the 100 to the left (100.300) (11.3), without casting as double precision, I get an error, cannot work with strings. Thanks again Von: firebird-support@yahoogroups.com Gesendet: Samstag, 31. August 2019 09:20 An: firebird-support@yahoogroups.com Betreff: ODP: AW: [firebird-support] Converting with parameters stored in variables? >>Trunc instead of pow? I only mean that you do not need to operate on strings to separate number. A = 123.45 – numeric not a double A1 = TRUNC(A) A2 = (A-A1)*POWER(10,3) Then A1 = 123 A2 = 450 SELECT LPAD(TRUNC(X.A), 10, '0') || '.' || LPAD((X.A-TRUNC(X.A))*X.B, 3, '0'), FROM (SELECT 100.12 AS A, POWER(10,3) AS B FROM RDB$DATABASE) X Regards, Karol Bieniaszewski
ODP: AW: [firebird-support] Converting with parameters stored in variables?
>>Trunc instead of pow? I only mean that you do not need to operate on strings to separate number. A = 123.45 – numeric not a double A1 = TRUNC(A) A2 = (A-A1)*POWER(10,3) Then A1 = 123 A2 = 450 SELECT LPAD(TRUNC(X.A), 10, '0') || '.' || LPAD((X.A-TRUNC(X.A))*X.B, 3, '0'), FROM (SELECT 100.12 AS A, POWER(10,3) AS B FROM RDB$DATABASE) X Regards, Karol Bieniaszewski
AW: AW: [firebird-support] Converting with parameters stored in variables?
Hallo Karol, we have a rfc interface with a high bay storage an the telegram defines the different datatypes. If I would create a new material, I must set different parameters #name#weight…#111.111# and so on. Trunc instead of pow? Regards Olaf Von: firebird-support@yahoogroups.com Gesendet: Freitag, 30. August 2019 10:04 An: firebird-support@yahoogroups.com Betreff: Re: AW: [firebird-support] Converting with parameters stored in variables? Hi, You can do this simpler by using trunc. But i ask why do you need this format in resultset? Formatting numbers is a client side task, same as for DATE. Regards, Karol Bieniaszewski
Re: AW: [firebird-support] Converting with parameters stored in variables?
Hi,You can do this simpler by using trunc.But i ask why do you need this format in resultset? Formatting numbers is a client side task, same as for DATE.Regards,Karol Bieniaszewski null
AW: [firebird-support] Converting with parameters stored in variables?
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 002.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 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
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
Re: [firebird-support] Converting with parameters stored in variables?
select right('0'||(10.3+0.000),10) from rdb$database Hello, I get from a application the following 100 R10.3 Or 22.22 R10.3 Now I should take it into: 000100.000 And 22.220 I think, I cannot simply (cast :input as :vartype) (vartype = ‘decimal(10.3)’ Also it will fortunately not work: cast(input as decimal(:v1,:v2) (v1 = 10 v2 = 3). How can I realize it without dismantle the 10.3 and the 22.22? Thank you.
[firebird-support] Converting with parameters stored in variables?
Hello, I get from a application the following 100 R10.3 Or 22.22 R10.3 Now I should take it into: 000100.000 And 22.220 I think, I cannot simply (cast :input as :vartype) (vartype = 'decimal(10.3)' Also it will fortunately not work: cast(input as decimal(:v1,:v2) (v1 = 10 v2 = 3). How can I realize it without dismantle the 10.3 and the 22.22? Thank you.