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

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 (10000000000.300) (11.3), without casting as double precision, I get an error, cannot work with strings.

 

Thanks again 😊

 

 

Von: firebird-support@yahoogroups.com <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