Compound key

Question:
I want to use a unique compound key, with a string columns and a numeric column, in my table. Since Blaze does not support compound keys, I will have to check for uniqueness in my application. What’s the best way to accomplish this?

Answer:
Although Blaze is being replaced by Oracle Lite in version 2.0, you may still have situations when you want to execute procedural code based on the value of more than one field in your application. You can use the technique described in this tip for any of these type of situations.

One of the issues you will have to wrestle with in a client/server environment is when to implement logic. In the case you describe, I will assume that you need a unique compound key for the row. Power Objects gives you a method that can be used to implement logic whenever the user tries to either commit a new or changed row or move from a new or changed row to a different row. This method is called ValidateRow(). The ValidateRow() method returns either True or False. If the method returns False, the action that triggered the method is not executed and OPO pops a message box with the message that is specified in the ValidateRowMsg property of the container.

Assuming that your table name was ORDERS, the two columns are called CUSTOMER and ORDER_ID and the data field objects that are bound to the columns are fldCUSTOMER and fldORDER_ID, the code for the ValidateRow() method would look like:

DIM nCount AS IntegerEXEC SQL SELECT COUNT(*) FROM ORDERS INTO :nCount  WHERE &         CUSTOMER = :fldCUSTOMER AND ORDER_ID = :fldORDER_IDIF nCount = 0 THENValidateRow = TRUEELSE        ValidateRow = FALSEEND IF

You return the appropriate boolean value based on the value of the nCount variable. If the method returns False, the string specified in the ValidateRowMsg property is shown in a message box and the user action is not executed.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may