Results 1 to 7 of 7

Thread: Vb6 problem with odbc for postgresql and columns calculated in query

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    4

    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

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,415

    Re: Vb6 problem with odbc for postgresql and columns calculated in query

    Quote Originally Posted by dsginfo View Post
    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

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,415

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    4

    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

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,967

    Re: Vb6 problem with odbc for postgresql and columns calculated in query

    Quote Originally Posted by dsginfo View Post
    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>

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    4

    Re: Vb6 problem with odbc for postgresql and columns calculated in query

    Quote Originally Posted by wqweto View Post
    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

  7. #7
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,415

    Re: Vb6 problem with odbc for postgresql and columns calculated in query

    Quote Originally Posted by wqweto View Post
    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
  •  



Click Here to Expand Forum to Full Width