Hi Bruce,

I think it is a 'ain't broke' situation.  For the next 4 months, we need to use numbers with 3 digits after the decimal.  After that, we go back to only 2 digits.  Razzak's solution worked and we can live with the odd rounding for a few months.

But, if I ever got inspired to write this project again, that is one of the first issues I would address!

Lin

On 2023-11-09 8:59 a.m., Bruce Chitiea wrote:
Lin: Thank you, and I fully understand your need. I look at my early code and just ... wonder how I got home New Year's morning.

It appears that R:azzak addressed the Report formatting issue. After 20+ years of successful use, are you experiencing key-related issues now? If not, maybe the if-it-ain't-broke rule applies.

Very best, Bruce

Bruce A. Chitiea
SafeSectors, Inc.
1142 S Diamond Bar Blvd # 442
Diamond Bar CA 91765-2203

[email protected]
(909) 238-9012 m

------ Original Message ------
From "Lin MacDonald" <[email protected]>
To [email protected]
Date 11/9/2023 8:27:14 AM
Subject Re: [RBASE-L] - On the Question of Primary Keys | Two Cents

Wow!  I seem to have opened Pandora's box!

I agree totally in retrospect.  However, this is 20+ year old code that is in use constantly.  I don't have the luxury of pulling it out of service to rewrite it completely at this time.  I'm trying to find a bandaid

Lin

On 2023-11-09 8:19 a.m., Bruce Chitiea wrote:
My blustery 0.02061 cents.

Just about anything can serve as a PK, so long as ALL values are unique. The code used to generate keys MUST repeat MUST eliminate all opportunities for variance in key structure. When one departs from plain vanilla INTEGERs into the realm of text or decimal strings, guaranteed uniqueness is held hostage to the arbitrary criteria chosen to assemble said string. The more one has to think about the composition of a key value, the greater the likelihood of confusion and corruption down the line.

In the "real world" of dollars and cents, I can get away with "two cents" being "$0.02" or "$0.02003 depending on how the parties to the transaction understand the MEANING of the value, and the context (say, purchase order or invoice) within which the value appears. Those two values coexist just fine for the manufacture and sale of 250,000 carbon steel flat washers. As PK values, sugar in the relational gas tank.

All of which is to say a Primary Key should have no meaning other than that of being a UNIQUE SERIAL NUMBER for a row of data within a given table. The datatype should refuse structural reformatting. There is no sequencing except (n+1), no categorization, no sub-structures vulnerable to manipulation by formatting. That means no items with real-world meaning, such as invoice numbers, product serial numbers, etc.; certainly no value deserving of its own column wherein an unexpected duplication doesn't leave you with a smoked, carmelized engine on the shoulder of the Jersey Turnpike on a sleeting New Year's Eve around midnight. Good luck with the tow.

So, INTEGER it is. No criteria beyond:

SET VAR vprimaryKey INTEGER = ( (MAX(vprimaryKey)) + 1 )

Ok, so that was more like $0.04.

Best, Bruce

Bruce A. Chitiea
SafeSectors, Inc.
1142 S Diamond Bar Blvd # 442
Diamond Bar CA 91765-2203

[email protected]
(909) 238-9012 m



------ Original Message ------
From "Ronald C Peterson" <[email protected]>
To "[email protected]" < [email protected]>
Date 11/9/2023 7:11:15 AM
Subject Re: [RBASE-L] - Where do I set my Vars?

What about using a numeric data type with fixed decimal location as a primary key?

------------------------------------------------------------------------
*From:* [email protected] <[email protected]> on behalf of [email protected] <[email protected]>
*Sent:* Wednesday, November 8, 2023 6:07 PM
*To:* [email protected] <[email protected]>
*Subject:* RE: [RBASE-L] - Where do I set my Vars?

If I understand correctly, by Universal Key you mean a Primary Key with Foreign keys linked. I personally would not use a real or double type as Primary key, precisely because of the problems you are encountering. You can have the same value generated at different time and depending on how is computed can default to a different valuer, or two different values that default to the same value. All my primary keys, and by extension foreign keys, have the type INTEGER or TEXT.

Now, if you want to change the type, you need to go to all the linked tables, disable the primary/foreign link to the primary table an rename them to a temporary name. Then, you can go to the primary table and change the type to what ever you need it to be, and the n go back to the secondary tables and change the name back to the original at which time they will adopt the new type and then re-ink them to the primary table, makes sense? There is a rename command, but if I recall correctly, will not work with linked columns. If you are going to do this, I would suggest converting your REAL values to INTEGER and use them as the primary key.

At one time, I had the need to change the text length of several primary columns and their corresponding foreign columns in numerous tables as the needs changed. I wrote a program where you would select the name of the primary table, primary key and the new length and the application would do the entire process described above automatically. If you need to do this once, you can do it manually; however, if you have multiple occurrences, writing a program to do it would be the best way.

Javier,

Javier Valencia, PE

14315 S Twilight Ln

Olathe, KS 66062

913-915-3137

*From:* [email protected] <[email protected]> *On Behalf Of *Lin MacDonald
*Sent:* Wednesday, November 8, 2023 3:02 PM
*To:* [email protected]
*Subject:* Re: [RBASE-L] - Where do I set my Vars?

Sadly, that's about when I wrote this!  It is a Universal Key attached to several other tables so I can't really change it to a double, I guess

Lin

On Wed, Nov 8, 2023, at 12:43 PM, 'Karen Tellef' via RBASE-L wrote:

    Welcome to the not-so-wonderful world of the "REAL" datatype. 
    Long ago in DOS days that was the only datatype (other than
    currency) that allowed decimals. Unfortunately it isn't real
    accurate IMO (pun intended).  Most of us switched all those
    Real numbers to the DOUBLE datatype.  With Double, a 104.31 is
    always stored and displayed exactly as 104.31. With Real,
    internally that number may be stored as something like
    104.309187983. So depending on your display formatting, you
    could get different representations to the screen.

    Looks like the 000.## type of formatting might be truncating. 
    In my example, it would display as 104.30 or 104.309 even tho
    the number is actually 104.31.  Someone else suggested using
    the ROUND function if you know how many decimal places you want
    displayed.

    Karen

    On Wednesday, November 8, 2023 at 01:47:25 PM CST,
    [email protected] <[email protected]> wrote:

    Hello Razzak,

    Thank you - that is what I was looking for.  I knew there was a
    simple solution.

    I am getting a strange output though:  the real number stored
    is 104.31

      000.## prints as 104.30

      000.### prints as 104.309

    This is an unusual situation where the number stored could
    possibly be 4 numbers to the left of the decimal and 3 to the
    right (we have never had more than 2 to the right)

    thanks for the help!

    Lin

    On Tuesday, November 7, 2023 at 7:57:30 PM UTC-8 Razzak Memon
    wrote:

        Lin,

        Here's how ...

        Please take a look at the attached illustration.

          * Open the report in Report Designer
          * Right-click on the Variable Object and select Display
            Format
          * Under the Display Format option change the Display
            Format to *0.000*
          * Click on the [OK] button to save the Display Format
          * Click on the [Preview] Tab to preview while still in
            Report Designer
          * Save the report and close the Report Designer

        That's all there is to it!

        I hope it helps!

        Very Best Regards,

        Razzak

            On 11/07/2023 8:53 PM EST Lin MacDonald <
            [email protected]> wrote:

            This will sound silly, but I am working on a system
            that I wrote several years ago, but can't remember most
            of what I wrote!

            I have a report that prints a Var (type: Real)  It is
            now printing it with 7 places after the decimal point. 
            I need it to print a max of 3 places.  Where do I set
            the number of places?  I honestly can't rmemeber!

            Lin

            --

            For group guidelines, visit
            http://www.rbase.com/support/usersgroup_guidelines.php

            ---

            You received this message because you are subscribed to
            the Google Groups "RBASE-L" group.

            To unsubscribe from this group and stop receiving
            emails from it, send an email to
            [email protected].

            To view this discussion on the web visit
            
https://groups.google.com/d/msgid/rbase-l/1c446867-f6d4-49b8-adc4-3252ed914b4b%40app.fastmail.com
            
<https://groups.google.com/d/msgid/rbase-l/1c446867-f6d4-49b8-adc4-3252ed914b4b%40app.fastmail.com?utm_medium=email&utm_source=footer>.

--
    For group guidelines, visit
    http://www.rbase.com/support/usersgroup_guidelines.php

    ---

    You received this message because you are subscribed to the
    Google Groups "RBASE-L" group.

    To unsubscribe from this group and stop receiving emails from
    it, send an email to [email protected].

    To view this discussion on the web visit

    
https://groups.google.com/d/msgid/rbase-l/c065ed53-23d4-4581-baa4-11a2e5034242n%40googlegroups.com
    
<https://groups.google.com/d/msgid/rbase-l/c065ed53-23d4-4581-baa4-11a2e5034242n%40googlegroups.com?utm_medium=email&utm_source=footer>

    .

--
    For group guidelines, visit
    http://www.rbase.com/support/usersgroup_guidelines.php

    ---

    You received this message because you are subscribed to the
    Google Groups "RBASE-L" group.

    To unsubscribe from this group and stop receiving emails from
    it, send an email to [email protected].

    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/rbase-l/1942164164.930636.1699476193291%40mail.yahoo.com
    
<https://groups.google.com/d/msgid/rbase-l/1942164164.930636.1699476193291%40mail.yahoo.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/c022b428-2852-45c0-bb15-d0acaa5c2fee%40app.fastmail.com <https://groups.google.com/d/msgid/rbase-l/c022b428-2852-45c0-bb15-d0acaa5c2fee%40app.fastmail.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/0fb501da1298%24668608c0%2433921a40%24%40vtgonline.com <https://groups.google.com/d/msgid/rbase-l/0fb501da1298%24668608c0%2433921a40%24%40vtgonline.com?utm_medium=email&utm_source=footer>.
--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/DM4PR10MB5918D74A426E497A133C72A6C8AFA%40DM4PR10MB5918.namprd10.prod.outlook.com <https://groups.google.com/d/msgid/rbase-l/DM4PR10MB5918D74A426E497A133C72A6C8AFA%40DM4PR10MB5918.namprd10.prod.outlook.com?utm_medium=email&utm_source=footer>.
--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to a topic in the Google Groups "RBASE-L" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/rbase-l/w0ExqyokoME/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/em16207e4d-4045-448a-8216-f9b98db406e6%40ffc94789.com <https://groups.google.com/d/msgid/rbase-l/em16207e4d-4045-448a-8216-f9b98db406e6%40ffc94789.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/e04a67d5-0bb6-4ec1-a5d9-3bba7fb70c0d%40gmail.com <https://groups.google.com/d/msgid/rbase-l/e04a67d5-0bb6-4ec1-a5d9-3bba7fb70c0d%40gmail.com?utm_medium=email&utm_source=footer>.
--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to a topic in the Google Groups "RBASE-L" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/rbase-l/w0ExqyokoME/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/em8c589e1f-45a6-447e-8692-1698ce235c97%40ffc94789.com <https://groups.google.com/d/msgid/rbase-l/em8c589e1f-45a6-447e-8692-1698ce235c97%40ffc94789.com?utm_medium=email&utm_source=footer>.

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/795f8263-1d72-4ed4-a9a1-5f18e84df5b7%40gmail.com.

Reply via email to