-
Apr 12th, 2021, 12:55 PM
#1
Thread Starter
New Member
Vb6 problem with odbc for postgresql and columns calculated in query
Good afternoon
I have problems when in a select to postgresql there are calculated columns.
In this example if I execute the select directly in the pgAdmin there are no errors, but since vb6 using ado column 4 is incorrect.
If I insert a round (.. in the select it is corrected but the problem is that there is a lot of pre-existing code that I cannot touch.
If someone can give me a light I would appreciate it very much
The text is translated, sorry for the grammar.
Greetings from Costa Rica
DATA
CREATE TABLE public.testdec
(
ccosto numeric(18,4),
cdescuento01 numeric(9,2),
cdescuento02 numeric(9,2)
)
TABLESPACE pg_default;
insert into testdec values(18.87,0,0)
select ccosto,cdescuento01,cdescuento02,
(ccosto * (1-cdescuento01/100) * (1-cdescuento02/100)) as ccostoneto
from testdec
In vb return:
18.87 OK
0 OK
0 OK
0.00000204170829370340983232 Error, = 0
-
Apr 12th, 2021, 01:04 PM
#2
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Originally Posted by dsginfo
select ...(ccosto * (1-cdescuento01/100) * (1-cdescuento02/100))...
Have you tried:
Code:
select ...(ccosto * (1.0-cdescuento01/100.0) * (1.0-cdescuento02/100.0))...
Olaf
-
Apr 12th, 2021, 01:24 PM
#3
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Or perhaps (alternatively) try it with proper casting of the result-field
since Numeric(18,4) is apparently transported correctly over ODBC...
..., Cast( ccosto * (1 - cdescuento01 / 100) * (1 - cdescuento02 / 100) As Numeric(18,4) ) As ccostoneto
Olaf
-
Apr 13th, 2021, 10:21 AM
#4
Thread Starter
New Member
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Thank you very much Olaf.
The problem is that I needed a solution without touching the querys.
I already made it, I share it in case it helps someone
In the odbc configuration, in datasource, page 2, numeric without precision change default to double
I also found that I can set it from the connection string adding to it: "; D6 = 8"
Thank you very much and greetings from Costa Rica
-
Apr 13th, 2021, 10:25 AM
#5
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Originally Posted by dsginfo
In the odbc configuration, in datasource, page 2, numeric without precision change default to double
I also found that I can set it from the connection string adding to it: "; D6 = 8"
Wow, dilletante will turn out is right everything outside MS walled-garden is black terminals and under-documented "POS code" :-))
cheers,
</wqw>
-
Apr 13th, 2021, 10:36 AM
#6
Thread Starter
New Member
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Originally Posted by wqweto
Wow, dilletante will turn out is right everything outside MS walled-garden is black terminals and under-documented "POS code" :-))
cheers,
</wqw>
Thank you very much, there was the information only that the language blocked me a little
https://odbc.postgresql.org/docs/config.html
https://odbc.postgresql.org/docs/config-opt.html
Thank you
-
Apr 13th, 2021, 10:48 AM
#7
Re: Vb6 problem with odbc for postgresql and columns calculated in query
Originally Posted by wqweto
Wow, dilletante will turn out is right everything outside MS walled-garden is black terminals and under-documented "POS code" :-))
Yep, as it stands there (D6=8) - it looks quite funny...
Cannot test it - but according to this docu-page here:
https://odbc.postgresql.org/docs/config-opt.html
...instead of the abbreviations, it should probably work as well with the "full Keywords":
NumericAS=SQL_DOUBLE
Olaf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|