text
stringlengths 11
3.5k
| source
stringclasses 1
value |
---|---|
Changing a charts z-axis Most three dimensional (3-D) chart types, (except pie charts) have a third axis, called the z-axis. The z-axis is along the third dimension of the chart. Depending on the specific chart type, the labels for the z-axes can either benext to the chart or displayed in the legend under the chart. To change the z-axis font properties Right-click the z-axis on a 3-D chart to change the Font used in its label. Changing a charts title T o compliment your form or report, you can affect the position andappearance of the charts title. To change a charts title With a form or report open in the Design window, right-click the title areaof the chart and click Title to specify the text, font, typeface, size, color,and script of the title. Removing fields from a chart You can remove fields from a charts x-Axis, y-Value, and Grouped By boxesin the Define Chart dialog box. To remove fields from a chart 1Open a form or report in the Design window, select the chart. 2Right-click the upper-left corner of the chart and click Define Chart. 3In the Define Chart dialog box, select the field you want to remove in thex-Axis, y-Value, or Grouped By boxes. 4Click the Remove Field button. Changing the appearance of a chart You can change the way each part of a chart looks; in other words, you canchange the titles font, color and background pattern the data series color and pattern the backgrounds color and pattern the frames style and color 296 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
the axis titles color and font the ticks color, font and frequency There are also properties that can be changed which are specific to particular chart types. See the Object property reference for more information onspecific area properties. Changing a charts fonts Use the Font palette to specify a charts typeface, size, and style. To change a charts fonts 1Open a form or report in the Design window, right-click a portion of thechart that has text (like the title or an axis) and click Title, Font. 2Change the typeface, size, style, color, and script of the font. Changing a charts background The charts background is the area not being filled with data, for exampleabove and between the columns in a tabular chart. You can change thebackgrounds color, pattern, and pattern color. To change a charts background color 1Open a form or report in the Design window, select the chart. 2Right-click the background area, click Color, and then click a color fromthe palette. To change a charts background pattern 1Open a form or report in the Design window, select the chart. 2Right-click one of the following: The background area, click Pattern, and then click a color from the palette to change the patterns color. The background area, click Pattern, and then click a style from thepalette to change the background pattern. T o make the chart transparent, select the chart rather than thebackground; right-click the chart and click Properties. Enable the Transparent check box on the General page of the Properties dialog box. Charts and crosstabs 297 | 292806769-Paradox-9-Eng.pdf |
Changing a charts color and transparency Use the Color palette on the charts General page of the Properties box to specify a charts color and transparency and to create custom colors for thechart. To change a charts color and transparency 1Open a form or report in the Design window, right-click the upper-leftcorner of the chart and click Properties. 2On the General page of the Properties dialog box, click a color on thecolor palette. 3Enable the Transparent check box to make the chart transparent. To change the color of an area of a chart 1Right-click the area, click Color 2Click a color on the palette. Creating custom colors for a chart Paradox saves custom colors in the Registry, not with the particulardocument you are working on when you create the color. Therefore, you cancreate a custom color in one design document and use the color in any otherdesign document. To create custom colors for a chart 1Open a form or report in the Design window, right-click the upper-leftcorner of the chart and click Properties. 2On the General page of the Properties dialog box, click one of the blankspaces on the color palette. 3Click the Add Custom Color button. 4In the Custom Color dialog box, choose a color scheme (RGB, HSV, or CMY). 5Drag the sliders to mix a color. 6Click OK to add the custom color to the color palette. The custom color appears on the color palette and is available for use whenever you change a color. 298 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
Working with crosstabs A crosstab is a data analysis tool that summarizes (cross-tabulates) information according to one or more categories. A crosstab is a design object, and the categories are fields. The summarized data for a crosstab are created by a query. Because crosstabs automaticallycreate and run queries, it is not necessary to define a query to create acrosstab. It is, however, a way to understand the type of information acrosstab can contain. A crosstabclassifies data by one or more categories summarizes the data within those categories sorts the summarized information displays the data in a spreadsheet-like format The following crosstab was created on the sample Orders table. T erms was selected as the column field, Ship Via as the category, and T otal Invoice asthe summary field. The crosstab summary region shows the sum of T otal Invoice by shipment and terms. As another example, you may know that in your organization, last years sales totaled $100 million nationwide. But what if you wanted to know whereyou should concentrate your advertising dollars? Breaking the informationdown by region would provide better information on which to base such adecision. Region Sales North $25,000,000 South $30,000,000 Charts and crosstabs 299 | 292806769-Paradox-9-Eng.pdf |
East $15,000,000 West $30,000,000 You could break this table down even further to show, for example, how much each product contributed to its regions sales. SALES Region Product #1 Product #2 North $12,000,000 $13,000,000South $10,000,000 $20,000,000East $10,000,000 $5,000,000West $15,000,000 $15,000,000You can quickly get an in-depth look at your data by using crosstabs. Crosstab basics Crosstabs may be one dimensional or two dimensional, and may be based on one or more tables. One-dimensional crosstabs When you create a one-dimensional crosstab, you can analyze one type ofdata in relation to another. The Orders table has a Payment Method field. The crosstab counts the number of orders placed using each of the seven possible payment methods. In this case, Payment Method is the category of information, and thecalculation Count(ORDER. Order No) provides the data for each category. You can arrange the display of information horizontally or vertically. Paradox can usually calculate and generate a vertical one-dimensional crosstab fasterthan a horizontal one. 300 Paradox 9: Chapter 6 An example of acrosstab used tobreak down orderamounts by paymentmethod. | 292806769-Paradox-9-Eng.pdf |
Two-dimensional crosstabs A two-dimensional crosstab summarizes information by more than one category. T o create a two-dimensional crosstab, indicate two category fields (the Column and Categories boxes in the Define Crosstab dialog box), and a fieldwhose data you want to summarize (entered in the Summaries box of the Define Crosstab dialog box). In this case, using the Orders table, you couldshow the count of orders (the summary appearing in the cells of the crosstabobject) placed for each payment method and each month (the categoriesappearing across the top and down the left side of the crosstab object). Thedata are two-dimensional because they reflect both the month in which theorders were placed and the method used to pay for the orders. The summary information (count of Order No) appears in the crosstab cells sorted in rows by Month and in columns by Payment Method. T o find thenumber of orders in a given month, you would find the intersection of theappropriate row and column. For example, the number 4 in the first columnof cells indicates that four orders were placed in the month of December bycustomers who used an American Express charge card to pay for the orders. This is a convenient way to analyze the buying habits of customers overtime. Multi-table crosstabs T o analyze (cross-tabulate) data contained in two or more tables, the tablesmust be linked. A crosstab can draw information from any number of tables that are linked in a single-value (one one or many one) relationship. Before you create a multi-table crosstab of a linked one-to-one relationship,you must define the relationship with a data model. For example, to view the number of items in stock by equipment class and the vendor that supplies them, you can link the Stock and Vendors tables. Youre then free to define the rows, columns, and summary fields using anyfield from either table. Charts and crosstabs 301 An example of atwo-dimensionalcrosstab. | 292806769-Paradox-9-Eng.pdf |
The following figure shows a multi-table crosstab that uses the Vendors Name field from the Vendors table and the Equipment Class field from the Stock table: This figure displays: Summary values show how many pieces of each type of stock came from each vendor. Row titles show values from the Vendor Name field of the Vendors table. Column headings show values from the Equipment Class field of the Stocktable. You can combine fields from linked tables in the same crosstab only if the linkis single-valued. You cannot cross-tabulate information from combined fields of tables linked in multi-value (one many) relationships. You cancross-tabulate information from the detail table only in a one many relationship. Crosstabs of detail tables Suppose you have a linked multi-valued (one-to-many) relationship and youwant a summary crosstab of only those records in the detail table that applyto a specific record in the master table. For example, you might want to define a crosstab in the detail table Orders that sums the T otal Invoice field by Payment Method and by Month for eachcustomer in the Customer table. 302 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
In the relationship between the Customer and Orders tables, each customer can have many orders. You can link the two tables and create a crosstab inthe detail table, Orders. You can then place the Customer No or Name field(or both) from the master table, Customer, on the form. Paradox knows fromthe data model that the information in the crosstab applies only to thecurrent record of the master table. In this example, the Name field at the topcomes from the Customer table. As you scroll through Customer, thecrosstab updates to show each customers order information. Creating a crosstab on a form or report When you create a crosstab in a form or report, the crosstab uses the datamodel of that form or report. If you want to see the data from your tables placed in the crosstab you have created, you will have to run the crosstab. To create a crosstab in a form or report 1Open a form or report in the Design window, click the Crosstab tool. 2Click the form or report to create a crosstab at its default size, or click anddrag to size the crosstab. An empty crosstab object appears with undefined fields in the row header, column header, and first summary area. To run a crosstab Open a form or report in the Design window, do one of the following: Click View, Run Form or View, Run Report. Press (F8). Charts and crosstabs 303 | 292806769-Paradox-9-Eng.pdf |
Paradox runs a query to calculate a crosstabs summary information. The process might fail if the resulting Answer table contains too many fields orif you have inadequate disk space for the query. When the crosstab fails,an empty grid appears in its place. Saving a crosstab to a table Once you have created a crosstab on a form, you run the form, then save thecrosstab to a table. To save a crosstab to a table 1Create a crosstab and save the form containing the crosstab. 2Click Edit, Save Crosstab (this menu command is available only whenrunning a form that contains a crosstab. ) 3T ype the name you want to give to the new table, or select one from thelist. Defining a crosstab Crosstabs may be based on one or on many tables, and may compare two ormore categories of data. The only requirements for crosstabs are that thetables being examined must be in the data model, and that the categoriesbeing compared are either linked in the data model or are linked viareferential integrity. You define crosstabs using fields from the tables in yourdata model. Defining a crosstab Define the crosstab using fields from the table(s) of the data model of theform or report. To define a crosstab 1Open a form or report in the Design window, right-click the upper leftcorner of the crosstab object and click Define Crosstab. 2In the Define Crosstab dialog box, enable the Column button and choosethe fields from the table list box that you want to use as column headingsacross the top of the crosstab. 304 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
3Enable the Categories button and choose the field from the table list box that you want to use as row headings down the left column of thecrosstab. 4Enable the Summaries button and choose the field from the table list boxon which you want to perform a summary operation. This provides thedata for the crosstab. You can choose more than one field at a time from the tables in the datamodel. You can also revise the documents Data Model and choosesummary operations. The total number of category fields plus the number of columns createdfor a crosstab cannot exceed 254. Defining the fields of a crosstab When you place a new crosstab object in a form or report, the first columnfield, first row field, and first summary field are undefined. You can define orremove the fields used for column headings, row categories, and summariesat any time. To define the fields for a crosstab 1Open a form or report in the Design window, right-click a crosstab fieldand click Define Field. 2In the Define Field Object dialog box, choose the field that you want touse in that field from the table list box. To remove a field from a crosstab 1Open a form or report in the Design window, right-click the upper-leftcorner of the crosstab object and click Define Crosstab. 2Select a field in the Column, Categories, or Summaries panels. 3Click the Remove Field button. Specifying column headings and row headings (categories) for a crosstab When Paradox generates a crosstab with multiple fields specified for categories, it sorts the information by the top category first, then by thenext, and so on. For one-dimensional crosstabs you can choose only one fieldto supply column-heading values. For two-dimensional crosstabs, as long asyou have at least one field specified for column headings, you can choose as Charts and crosstabs 305 | 292806769-Paradox-9-Eng.pdf |
many fields as are available and that are valid in the tables of the data model for the row categories. Each field you add to the Categories list furtherrefines the grouping of information. To specify column headings for a crosstab 1Open a form or report in the Design window, right-click a crosstab fieldand click Define Field. 2In the Define Crosstab dialog box, enable the Column button and choosethe field from the table list box that you want to use as column headingsacross the top of the crosstab. To specify row headings (categories) for a crosstab 1Open a form or report in the Design window, right-click a crosstab fieldand choose Define Field. 2In the Define Crosstab dialog box, enable the Categories button andchoose the field from a table list box that you want to use as row headingsdown the left column of the crosstab. You cannot use the same field for column headings and row categories. Ifyou have already chosen a field from this table to supply the columnheading values, that field will be dimmed. If you are creating a horizontal one-dimensional crosstab, do not choose afield for row categories. If you are creating a vertical one-dimensional crosstab, do not choose afield for column-heading values. Specifying summary fields for a crosstab Unlike fields you choose for column-heading values and row-category values,fields you summarize can be chosen more than once. The number ofsummary fields times the number of column values cannot exceed 254. Afteryou specify the field(s) to summarize in a crosstab, you can specify whichsummary operation to perform (sum, count, min, max, or average). Bydefault, Paradox performs the following operations: Sums number, money, short integer, long integer, autoincrement, and Binary Coded Decimal (BCD) field data Counts alpha, date, time, timestamp, or logical field data 306 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
To specify summary fields for a crosstab 1Open a form or report in the Design window, right-click a crosstab field and click Define Field. 2In the Define Crosstab dialog box, enable the Summaries button andchoose the field from table list box on which you want to perform asummary operation. This provides the data for the crosstab. To change a summary operation 1Open a form or report in the Design window, right-click a crosstab fieldand click Define Field. 2In the Define Crosstab dialog box, enable the Summaries button andchoose a summary operation from the Summary list box. You cannot choose the same field to summarize as you have chosen forcolumn headings or for row categories. If you have already chosen fieldsfrom the table to supply column heading and row category values, thosefields will be dimmed. You can choose as many fields as are available and that are valid from thetables of the data model. The order in which you choose them determinesthe order in which the summarized data appears in the crosstab. Modifying a crosstab You can modify both the properties of each section of the crosstab, and theorder in which the data appears within the crosstab. For more information onthe properties available to crosstabs, see the Object property reference. Changing the appearance of a crosstab You can change the way each part of a crosstab looks; in other words, you canchange the properties of the fields, columns, rows, and summary areas of thecrosstab by using the Properties dialog box. You can change the size of the entire crosstab, the column area, or the row area. To change the appearance of a crosstab 1Open a form or report in the Design window, select the crosstab. Selectionhandles appear around the crosstab. Charts and crosstabs307 | 292806769-Paradox-9-Eng.pdf |
2Right-click the appropriate area of the crosstab and click Properties. 3Select the properties you wish to be associated with the crosstab. To change the size of the entire crosstab With the crosstab selected in the Design window, drag the crosstabs borders to the appropriate size. To change the size of the column area Drag the grid lines surrounding the selected crosstab. To change the size of the row area Drag the borders of the row area of the selected crosstab. Rearranging category and summary fields on a crosstab When you choose more than one field to define the row categories and morethan one field to summarize, you can change the order in which the fieldsappear in the Categories and Summaries panels. To rearrange category and summary fields in a crosstab 1With the form or report open in the Design window, right-click theupper-left corner of the crosstab object and click Define Crosstab. 2Use the Change Order arrows at the bottom of the Field Used In area. These arrows become active when you select either Categories or Summaries and when you have more than one field in their panels. You can rearrange the categories or summaries in the Form Design and Report Design windows by dragging them to a different location. 308 Paradox 9: Chapter 6 | 292806769-Paradox-9-Eng.pdf |
Querying your database 309QUERYING YOUR DATABASE 7 A query is a way to retrieve information from your database. Queries are usually in the form of a question. For example, you can find out whichcustomers placed orders in a given month, the total amount billed for allorders, and which orders havent been paid. In a query, you can specifytables to ask questions about fields you want to see in the Answer table records you want to select calculations you want to perform new fields you want to create through calculations on table data. You can query one table or several tables to get the information you need. Paradox finds the records that meet the conditions you specify and presentsthe results to you in an Answer table. If a query does not obtain the resultsyou want, you can refine the query and run it again. You can also save a querydefinition to use it again. Many of the procedures and examples in this chapter use files from the Paradox Samples directory (default location is C:\Program Files\Corel\Shared\Samples). If you did not install the sample files, youcan do so by performing a custom installation. | 292806769-Paradox-9-Eng.pdf |
Uses of queries By constructing queries that build on each other, you can ask what if? with your data. For example, you can find out: How much would total sales increase if sales to Oregon residents increased by 8%? How much would our travel costs increase if airline prices went up 10%? You can also use a query to insert, delete, change, or perform calculations onyour records. Query properties and preferences You can set properties for individual queries, such as the type and name ofthe results table, and whether the results are sorted. You can also set defaultpreferences for all queries. Live query views Normally, when you perform a query, Paradox generates an Answer table thatis read-only. In other words, you cannot change the information in therecords. However, you can generate a live query instead of an Answer tableby changing a query-property setting and then updating the information inthe selected records. Query building methods Paradox provides four different methods to create queries for your database: Query By Example (QBE) is a popular query building method from earlier versions of Paradox. T o perform a QBE query, you give Paradox anexample of the result you want. You use selection conditions and exampleelements to define the query. The Visual Query Builder (VQB) provides a method to generate SQLqueries quickly and easily without typing any SQL code. You create yourquery by choosing tables, fields, and other options through a graphicalinterface while the SQL code is generated in the background. You can seethe SQL code being generated in the SQL editor as you choose options inthe VQB window. For information about the VQB, see Using the Visual Query Builder to create SQL queries in the online Help. 310 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Direct coding in the SQL Editor is an advanced method for experienced database developers who have expertise in SQL. You can also use the SQLEditor to modify queries that were previously created through the Visual Query Builder or the Query Expert. For more information on SQL, see Using the SQL Editor and Using Local SQLink the online Help. The Query Expert is the easiest method and will appeal to new databaseusers. It takes you though a step-by-step process to createcommonly-used query models. T o launch the Query Expert, click T ools,Experts, and then double-click the Query icon. Creating a QBE query The types of queries you can create with Paradox and QBE are almostlimitless. You can use query operators and calculation statements to extractjust the information you need. No matter what kind of query youre creating,the technique you use to create the query has very little variation. Creating a QBE query from a table You can create a QBE query image directly from one or more existing tables. To create a query based on a table 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In listbox. 3Choose one or more tables from the list of tables, and click Open. To choose more than one table, hold down CTRL and click each table you want to open. 4Enable the check box beside each field you want to display in the Answertable. 5Click Query, Run Query. If your query contains more than one table, you must link the tables withexample elements before you run the query. See Linking tables in a QBEquery on page 319. Creating a QBE query based on a data model, form, or report You can create a query based on an existing data model, form, or report. When you create a query based on a form or report, Paradox places in the Querying your database311 | 292806769-Paradox-9-Eng.pdf |
Query window an image of each table used in the data model of the chosen form or report. It also places example elements (and inclusion operators, ifnecessary) to join the tables according to the data model. Multiple tables in aquery must be joined in this way. To create a query based on a data model, form, or report 1Click File, New, Query. 2Choose Data Models, Forms, or Reports from the Files Of T ype list box. 3Choose the folder in which your data model, form, or report is locatedfrom the Look In list box. 4Double-click a data model, form, or report from the list of files. 5Enable the check box beside each field you want to display in the Answertable. 6Click Query, Run Query. Creating a QBE query based on another query If you want to create similar queries, you can modify an existing query andsave it under a new name. When you create a query based on another query,Paradox places a copy of the query in the Query window. Any existingselection conditions, example elements, (and inclusion operators, ifnecessary) are included in the query images. To create a query based on another query 1Click File, New, Query. 2Choose the folder in which the existing query is located from the Look Inlist box. 3Choose Queries in the Files Of T ype list box. 4Double-click a query in the list of files. 5Make changes to the query image as appropriate. 6Click File, Save, and type a name in the File Name box. Opening and running a QBE query As the information in your database increases or changes, you may haveoccasion to run the same query on it several times. After you have createdand saved one or more queries, you can open and run them to obtain updatedinformation. After Paradox runs a query, it either displays an Answer table or 312 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
changes data in a table, depending on the kind of query. See Viewing query results on page 324 for more information. To open a query 1Click File, Open, Query. 2Choose the folder in which your query is stored from the Look In list box. 3Click the query in the list of files. 4Click the Open button. To run a query Click Query, Run Query. Example of creating a simple QBE query T o create a simple query that results in a list of customer names and phonenumbers, follow these steps. This example uses the CUSTOMER. DB tablelocated in your Samples directory. 1Choose Sample from the list box in the Project Viewer. 2Click File, New, Query. 3Double-click the CUSTOMER. DB table. 4Enable the check box beside the Name field. 5Enable the check box beside the Phone field. 6Click Query, Run Query. Paradox displays the data in an Answer table. QBE Query operators There are eight types of Paradox query operators: Reserved symbols Operator Meaning Check Display unique field values in an Answer table Check Plus Display field values including duplicates in an Answer table Check Descending Display field with values sorted in descending order Group By check Specify a group for set operators Querying your database 313 | 292806769-Paradox-9-Eng.pdf |
Reserved words Operator Meaning CALC Calculate a new field INSERT Insert records with specified values DELETE Remove records with specified values CHANGETO Change specified values in fields SET Define specific records as a set for comparisons Arithmetic operators Operator Meaning + Addition or alphanumeric string concatenation-Subtraction * Multiplication / Division () Group arithmetic operations Comparison operators Operator Meaning = Equal to (optional) > Greater than < Less than >= Greater than or equal to <= Less than or equal to Wildcard operators Operator Meaning.. Any series of characters @ Any single character 314 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Special operators Operator Meaning LIKE Similar to NOT Does not match BLANK No value TODAY Todays date OR Specify OR conditions in a field,(comma) Specify AND conditions in a field AS Specify the name of a field in an Answer table ! (exclamation mark) Display all values in a field, regardless of matches Summary operators Operator Meaning AVERAGE Average the values in a group COUNT Count the number of values in a group MAX Find the maximum value of a group MIN Find the minimum value of a group SUM Total the values in a group ALL Calculate summary based on all values in a group, including duplicates UNIQUE Calculate summary based on unique values in a group Set comparison operators Operator Meaning ONLY Display records that match only members of the defined set NO Display records that match no members of the defined set EVERY Display records that match every member of the defined set EXACTLY Display records that match all members of the defined set and no others Operator precedence in QBE queries Paradox evaluates operators in queries in a specific order. In expressions that contain more than one operator, the operators are evaluated in the order of precedence shown in the following table: Querying your database 315 | 292806769-Paradox-9-Eng.pdf |
Precedence Operator 1( ) 2* / 3+-4 =< ><< =>> = 5 NOT 6O R 7,(comma) Any expression contained in parentheses is evaluated first, and inner levels of parentheses are evaluated before outer levels. When two or moreoperators of equal precedence are in a single expression, they are evaluatedfrom left to right. Rules for entering numbers in QBE queries When you type a number into a number field (Paradox number, short integer,long integer, or money field and d BASE number or floating number fields) ofa query image, do not type: dollar signs parentheses to signify a negative value thousand separators (neither a comma nor a period) when you specify a pattern match with the..or @ wildcard operators. For more information see Using wildcards to match a pattern on page 338. On the other hand, do type: decimal separators (a period in United States convention and a comma in international convention) the minus symbol to signify a negative value thousand separators when specifying an exact match numeric-selectioncondition Paradox determines when a comma or a period is a whole-number or adecimal separator, first based on whether you have a United States orinternational number convention set, and second, based on the symbolsposition and context. Ambiguity arises when a comma could be Paradoxs AND operator, which is a comma, and when a period could be part of Paradoxs..wildcard operator, which is two periods in a row. If the meaning of a comma or period is not clear, you must help Paradox understand the symbols meaning by using double quotation marks or spaces. 316 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
The meaning of a comma or period meaning will not be recognized as a thousand separator if you are specifying a pattern match with the..or @ wildcard operators; therefore, do not type thousand separators when youspecify a numeric pattern with..or @. If you are using the United States number format Paradox interprets a single period in a number field as a decimal separator. Paradox interprets the first two periods in a row as the..wildcard operator. In a number field, if Paradox encounters three periods in a row, it interprets them as the..wildcard operator followed by the decimal separator. T o make Paradox interpret the first period as the decimal separator, enclose it in double quotation marks. Paradox interprets a comma in a number field as a thousand separator if you are specifying an exact match and if the comma is in the proper position to bea thousand separator. T o make Paradox interpret a comma as the ANDoperator where this meaning might not be clear, type a space or any othernon-numeric character (except @ or a period) after the AND comma. Forexample, you could type a comparison operator. If you are using the international number format Paradox interprets the first comma in a number field within a number as thedecimal separator. Paradox interprets a comma followed by a space or any other non-numeric character (except @ or a period) as the AND operator in a number field. Paradox interprets a single period in a number field as a thousand separator if you are specifying an exact match and if the period is in the proper positionwithin a numeric selection condition. Using reserved words or symbols in selection conditions In a QBE query image, to specify an alphanumeric value that contains aperiod or comma or a Paradox reserved word, the value must be enclosed indouble quotation marks. Paradox then recognizes the quoted characters as avalue and does not act on their special meaning. If the value itself contains a double quotation mark, precede the quotation mark with a backslash (\): Thomas E. \"Ned\" Lawrence If the value contains a backslash, precede that backslash with another backslash (\\). Querying your database 317 | 292806769-Paradox-9-Eng.pdf |
You do not need quotation marks to enclose blank spaces in a value. You do need them, however, for all other symbols and operators that have specialmeanings in Paradox, such as commas, periods, and asterisks. Choosing tables for a QBE query You can create a simple query based on only one table, or a complex querybased on up to 24 tables. If you are querying more than one table, you mustlink the tables under common fields. Multi-table queries T wo or more tables usually contain different information about the sameperson, place, or thing. T o combine this information, you can query morethan one table at the same time. Multi-table queries are similar to single-table queries, except thatyou must fill out a separate query image for each table you must use example elements to identify common fields among the tables. In other words, you must link the tables based on their commonfields for the query to work. Linking tables in a multi-table query Sometimes, three or more tables you are querying have the same field incommon. In that case, you use the same example element to link all thetables. The more usual case occurs when three or more tables have different fields in common. For example, Table 1 and Table 2 have one field in common,Table 2 and Table 3 have a different field in common, and Table 1 and Table 3have no fields in common. You must use a unique example element for eachlink. In this case, you could use the example element abc to link Tables 1 and2 and use xyz to link Tables 2 and 3. Using a multi-table design to link tables Paradox lets you automatically link tables in a query by using a linkedmulti-table design document you have already created. If you have alreadyset up table relationships for the purpose of a multi-table design document,you can use that object as the basis of your query. Paradox adds the tablesused in the document to the Query window and places example elements tojoin the tables according to the documents data model. For more information,see Creating a QBE query based on a data model form or report on page311. 318 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Adding query tables You can open a query with one or more tables and add tables to the query. To add tables to a query 1Open the query to which you want to add tables. 2Click Edit, Insert Table. 3Select the table(s) you want to add to the query. To select multiple tables, hold down CTRL and click the name of each table. 4Click Open. Whenever you create a query using more than one table, you must linkthem. For more information, see Linking tables in a QBE query on page319. Removing query tables You can open a query with one or more tables and remove tables from thequery. To remove tables from a query 1Open the query from which you want to remove tables. 2Click Edit, Remove Table. 3Select the table(s) you want to remove in the Table T o Remove list. T o select multiple tables, hold down CTRL and click the name of each table. Linking tables in a QBE query When you query more than one table, you must use example elements tolink the tables under a common field. These linking fields are fields in eachtable that contain the same kind of information. For example, Customer and Orders both have a field that contains customer identification numbers called Customer No. Because the information in both fields is compatible, you canlink these two tables on that field. Querying your database 319 | 292806769-Paradox-9-Eng.pdf |
Linking fields do not need to have the same field name, but they must meet the following requirements: They must be of compatible types. You cannot, for example, link a number field in one table to an alpha field in another. They cannot be memo, formatted memo, graphic, OLE, or binary fields. The example elements you use to join your tables can be any uniquecombination of letters and numbers. If you use the Join command to link yourtables, Paradox assigns an example element automatically, in the form ofjoin1, join2, etc. When you use an example element to link tables, youmust enable the check box beside one of the fields in one of the tables todisplay that field in the Answer table. To link tables using example elements 1Click the first field you want to link. 2Press F5, and type your example characters in the field. The example characters should appear in red. 3Click the next field you want to link. 4Press F5, and type the same example element as you typed in step 2. 5If you need to link additional fields, repeat steps 3 and 4 using the same example element, as necessary. To link tables using the Join command 1Click the Join T ables button. 2Click the appropriate field of each query image. You can only link two tables at a time using the Join command. Examples of a multi-table QBE query Example 1 Suppose you want to use the sample tables to see which dive shops haveplaced orders. The sample Orders table, however, only shows the Customer ID number and not the dive shop names. The sample Customer tablecontains the dive shop names. Therefore, you want to use example elementsto link Customer and Orders on their common Customer No fields toretrieve 320 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
orders information from Orders the names of the dive shops that have placed orders from Customer The following figure shows the use of an example element to link two tables: Example 2 Suppose you want to know which dive shops outside of California have placed orders for items from $500 to $1,500 in selling price and have hadthese items shipped via Federal Express or Emery. The following figure shows the use of two example elements to link three tables: Querying your database321 | 292806769-Paradox-9-Eng.pdf |
Selecting fields to display in a QBE query After you select the tables you want to query, you need to specify what fields you want to see in the Answer table. Each field of a query image has a checkbox. The column on the far left under the table name also has a check box. Enable a fields check box to include that field in the Answer table for thequery. When you right-click a fields check box, you see the different types ofchecks you can use. Check type Properties Check Displays all unique values for the selected field in ascending order (A to Zor 0 to 9). When used with a summary operator, a check mark specifiesthat the records should be divided into groups based on the values in thechecked field. Check Plus Displays all values in a field, including duplicates, without sorting. Thevalues sort in the Answer table in the same order they appear in thequeried table. Check Descending Displays unique values sorted in descending order (Z to A or 9 to 0). Group By Specifies a group of records to use in a set query. A field with the Group By checkmark does not appear in the Answer table. When you use Check Plus in any field of the query image, it overrides any Checks or Check Descendings you have placed in any other field. This isbecause Paradox cannot both sort and exclude duplicates which is whatthe Check and Check Descending tell it to do and not sort and includeduplicates which the Check Plus tells it to do. Although you can place Checks and Check Descendings in BLOB fields,Paradox treats them as Check Pluses in these fields. Paradox cannot sortor distinguish unique from duplicate values in these field types. 322 Paradox 9: Chapter 7 Selecting fields usingthe Check symbol. | 292806769-Paradox-9-Eng.pdf |
Selecting QBE query fields T o display a field in the Answer table, you must place a check mark of one type or another in the check box next to that field. To place the default check mark Enable the fields check box. To place a Check Plus, Check Descending, or Group By check mark Right-click the fields check box, and choose the type of check mark youwant from the menu. To select all fields in a table Enable the check box in the left-most column of the query image (underthe table name). Working with QBE query images After you select the table(s) you want to query, Paradox opens the querywindow that contains query images of each table you have selected to query. The query image has the same fields, in the same order, as the table itrepresents, but no data. If you have changed the tables properties (forexample, changed the field order or the way heading text is displayed), thequery image does not reflect them. You type data into and navigate through the fields of a query image the same way you would in a table in Edit mode. For example: To... Do this... Add a row Press the INSERT key (works only if you have changed the current row). Delete a row Press CTRL + DELETE. Enter Field View Press F2. To cascade or tile query images Paradox provides two ways for you to display multiple query images in a Query window: Click View, Cascade Tables to view multiple query images cascaded in the Query window. Click View, Tile Tables to view multiple query images tiled vertically inthe Query window. Querying your database 323 | 292806769-Paradox-9-Eng.pdf |
Moving fields in a QBE query image You can move a field to a new position in the query image, or to the end of the query image. The position of the fields in the query image does not affectthe sort order of the Answer table. To move a field in a query image Drag a column heading to a new location in the query image. To move a field to the end Select the column you want to move and press CTRL + R. Viewing query results When run, most queries display an Answer table, which is placed in yourprivate directory. However, if your query uses the INSERT, DELETE, or CHANGETO reserved words, Paradox does not display an Answer table. Instead, it changes the data in one of the tables represented in the query andcreates an Inserted, Deleted, or Changed table. If you have enabled the Fast Queries option on the QBE page of the Preferences dialog box, Paradox willnot create INSERTED, DELETED, and CHANGED tables. Live query views You can edit the Answer table, but any changes you make are not reflected inthe original table or tables that you queried. If you want to create an Answertable that does update the original table when you change it, you must createa live-query view instead of an Answer table. For more information, seeLive query views on page 328. The Answer table A Paradox query that retrieves data or performs calculations gives you an Answer table. The Answer table is a temporary table that Paradox stores inyour private directory and replaces each time you perform a query. Paradoxdeletes the Answer table when you exit Paradox. If you want to save the Answer table, you must rename it, or save it to a different directory. Modifying and renaming the Answer table You can change the properties of the Answer table before you run the query,and you can rename an Answer table after you run a query. By default,Paradox names the result of a query ANSWER. DB and places it in yourprivate directory. If you rename this table, Paradox does not treat it as a 324 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
temporary table, and does not delete it when you change working directories or exit the program. The structure of the Answer table closely reflects the structure of the query example: the left-most field checked in the first image becomes the left-mostfield of the Answer table, and so on. You can change the field order to bettersuit your needs. To change Answer table properties 1Click Query, Properties. 2Click the Answer tab. 3Choose any of the following options: Enable the Live Query view button to create a Live Query View instead of an Answer table. Enable the d BASE button to generate an Answer table as a d BASEtable. T ype a new name and location for your Answer table in the Table Namebox. For a complete description of available query properties, see Setting QBE query properties on page 352. To rename the Answer table 1Run your query. 2Click Format, Rename Table. 3T ype a new name for the table. You can type the full path if you want to save the table to a different folder (other than your private folder). To change the Answer table field order 1Click Query, Properties. 2Click the Structure tab. 3Click the name of a field you want to move in the Answer Fields list. 4Click the UP ARROW or DOWN ARROW buttons to move the field. Querying your database 325 | 292806769-Paradox-9-Eng.pdf |
Settings made with the Query Properties command are saved with the query. Renaming Answer table fields When you enable the check box beside a field in a query image, Paradoxdisplays that field in the Answer table with the same name it had in theoriginal table. If the Answer table contains fields with duplicate field namesfrom two or more tables, Paradox names the first field by its exact field nameand numbers the duplicates, calling them Name_1, Name_2, etc. You can usethe AS operator to change the field name in the Answer table. The ASoperator changes field names only in the Answer table. It doesnt changefield names in the table(s) you query. When you use the CALC operator, Paradox creates a new field in the Answer table that contains the results of a calculation. Paradox automatically placesthe new calculated field at the end of the Answer table and gives it the nameof the calculation. You can specify a new name using the AS operator. To specify a different name 1Click the field in the query image to which you want to assign a differentname. 2T ype AS, followed by a space. 3T ype the name you want the field to be called in the Answer table. To specify a different name when using a selection condition T ype the selection condition followed by a comma(,),a n dthen type AS, followed by a space, followed by the new field name. Sorting the Answer table You can change the sort order of the Answer table before you run your query. By default, Paradox sorts first under the left-most field in the Answer table,followed by the next-to-left-most field, and so on. You can set your Answertable to sort first under any of the fields, without changing the order in whichthey appear. To sort the Answer table 1With the query open, click Query, Properties. 2Click the Sort tab. 326 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
3Use the RIGHT ARROW button to move the fields from the Answer Fields list to the Sort Order list. Add the fields in the order you want the Answer table sorted. 4T o remove a field from the Sort Order list, click its name, and click the LEFT ARROW button. 5T o change the order of the fields in the Sort Order list, select a field anduse the UP ARROW and DOWN ARROW buttons to move the field up ordown in the list. Because Sort is a query property, sort information is saved with the queryand applies only to that query. Sorting Answer-table values in descending order By default, Paradox sorts records in the Answer table in ascending orderbased on the values in the fields you enable, from left to right. That is, itsorts on the left-most field, then the next field, and so on. Here is how sort order applies to the different Paradox field types: Field type Examples of sorted values (low to high) Number 0 to 10 Alpha A, a to Z, z Date 1/1/97 to 12/31/97 Money $1. 99 to $99. 99 Memo (not sorted) Graphic (not applicable) Time 00:00:01 to 23:59:59 Logical False to True Ft o T No to Yes0t o1 Paradox sorts numbers and other nonalphabetic characters according to thesort order you installed. Alphanumeric 10" sorts before 2" although it isnumerically larger. Querying your database 327 | 292806769-Paradox-9-Eng.pdf |
To specify that values be sorted in descending order Right-click the check box beside the appropriate field, and choose Check Descending. In BLOB fields and in d BASE memo fields, Paradox treats Check and Check Descending as if they were Check Plus. You cannot use Group By in BLOB fields or d BASE memo fields. Live query views When you create a Paradox query that generates an Answer, the Answertable generated by the query does not maintain a relationship with theoriginal table you queried. Edits you make to ANSWER. DB are not reflectedin the original table. If you want changes you make to be reflected in theoriginal table, you can create a live query view. When you create a live query view, Paradox generates an answer set that is a limited, direct view into the table you queried. The view is limited by theselection conditions you specify in the query. When you edit the live-queryview, you are really editing the table you queried and using this limited directview to see only the data you want from that table. Multi-table QBE queries cant return live-query views. Structured Query Language (SQL) queries on up to three tables can return live-query views. Although you request a live-query view on the Answer page of the Query Properties dialog box, Paradox might not actually produce a live-queryview. Paradox will not produce a live-query view if you did not use Check Plus; Check and Check Descending caused sorting instead. Paradoxwill also not produce a live-query view if you performed an INSERT,DELETE, CHANGETO, or CALC query. If a query view cant be live, Paradox still generates a query view, not an Answer table; however, all the fields are read-only. Youll still see updatesother users make to the table, provided it is a Paradox table and the Refresh Rate is not 0. You will get better performance on single-table queries if you use alive-query view. You can set your query options to default to createlive-query views. See Modifying and renaming the Answer table onpage 324. 328 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Rules for live-query views Not all queries can return live-query views. A live-query view must meet the following conditions. You can create a live-query view only on single-table queries. You must use the Check Plus operator. The live-query view cannot be sorted; therefore, Check, Check Descending, and Group By checks are notallowed. You cannot use the Sort Answer Table button or the Sort settings on alive-query view. You cannot use calculated fields in a live-query view. Multiline OR queries are not allowed. The selection conditions you specify in the query must be capable of beingexpressed as a filter. This means the following query structures are notallowed: References to one field in the selection condition of another field. References to aggregates in the selection condition. Use of the @ wildcard operator. Use of the .. wildcard operator before selection conditions. Use of the.. wildcard operator after a selection condition is allowed, as inthe example Canada.., and produces a case-insensitive answer set. Creating a live-query view You can create a live-query view on any single-table QBE query that meetsthe requirements outlined in Rules for live-query views on page 329. To create a live-query view 1Open the query for which you want to generate a live view. 2Click Query, Properties. 3Click the Answer tab. 4Enable the Live Query View button, and click OK. Remember that all selected fields in the query image must be selectedusing the Check Plus option. T o change to Check Plus, right-click thecheck box, and choose Check Plus from the list. Querying your database 329 | 292806769-Paradox-9-Eng.pdf |
Editing a live-query view You can edit the data in a live-query view in the same manner as you would edit any other table in Paradox. When Paradox creates a live-query view,youll see the words Query View and the name of the. QBE file thatgenerated the live-query view (if the. QBE file has been saved) in the Title Bar of the live-query view. All changes to data in the live view immediatelyappear in the original table. To edit the live-query view 1Click View, Edit Data. 2Edit the data in the live view as needed. You can use CTRL + DELETE to delete a record from the live-queryview; this command also deletes the record from the table you queried. Deletions from Paradox tables cannot be undone. For more information on editing table data, see Editing data on page144. Saving a live-query You can save a live query view in the same manner as you would save aquery that generates an Answer table. Each time you open and run the query,Paradox generates a new live-query view of the tables data. The live-query view is a temporary view of the table you queried. You can save this query view as a new table. Edits you make after saving a live-queryview are no longer reflected in the table you queried. To save a live query 1Click File, Save As. 2Choose the folder in which you want to save the live-query from the Save In list box. 3T ype a name for the live-query in the File Name box. 330 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
To save a live-query view as an Answer table 1Run the live-query. 2Click File, Save. The live-query view is converted to a standard Answer table and placed in your private directory. To save a live-query view as a Paradox table 1Run the live-query. 2Click File, Save As. 3Choose the folder in which you want to save the live-query view from the Save In list box. 4T ype a name for the live-query view in the File Name box. Specifying query selection conditions In most queries, you want to see only records that meet certain conditions. You use the query operators to define selection conditions. You can define selection conditions that test for the following types of matches: exact matches matching a range of values: comparison operators inexact matches: the LIKE operator non-matches: the NOT operator blank values: the BLANK operator todays date: the TODAY operator character patterns: wildcard operators You can also use AND and OR to indicate whether a record must match all the defined selection conditions or just one of them. Understanding selection conditions Selection conditions are used to narrow the scope of the information youretrieve with a query. You use combinations of operators, reserved words,and symbols to define the type of information you are looking for. You mustfollow certain rules when you enter selection conditions and calculationstatements in query images. Querying your database 331 | 292806769-Paradox-9-Eng.pdf |
You can type a selection condition in a field without enabling the check box for that field. Enabling the check box tells Paradox to display that field in the Answer table. You do not have to include a field in the Answer table to use itsvalues to select records. Specifying two selection conditions for a field You can enter two or more selection conditions in the same field of a QBEquery image by separating the conditions with commas. The comma acts asan AND operator and tells Paradox that both (or all) of the selectionconditions must be met for a match to occur. You can also combine AND and OR conditions in a single query. T o match a value that includes a comma (like Acme, Inc. ) you must enclose the value in quotation marks or Paradox will interpret the comma as an ANDoperator. For example, you would type Acme, Inc. Sometimes you use the OR query when you are asking an and question. For example, if you want all records in CA and HI, you must query for CA ORHI because no single record has both values. Using Arithmetic operators in QBE queries You can use arithmetic expressions in number, date, time, and money fieldsof a query image. Operator Meaning + Addition or string concatenation-Subtraction * Multiplication / Division () Used to group expressions Use parentheses () to combine and group operations and to indicate whichcalculations should be performed first. In expressions without parentheses,multiplication and division are performed before addition and subtraction. Operations with equal precedence are calculated from left to right. For moreinformation on operator precedence, see Operator precedence in QBEqueries on page 315. Arithmetic operators are especially useful with the TODAY operator, the CALC operator, and with example elements. 332 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
You can use arithmetic expressions with date values and the TODAY operator to add a number of days to a date subtract a number of days from a date subtract one date from another date to produce a range of days Use arithmetic operators to create arithmetic expressions with field values. You can use any of the arithmetic operators in the number fields Paradoxnumber, short integer, long integer, BCD, money, d BASE number, andd BASE floating number fields. Not all Paradox field types will support arithmetic operators. For a list ofcompatible field types, see Paradox field types allowing arithmeticoperators in the Reference section of the online Help. Specifying matches in selection conditions Paradox allows you to create selection conditions that match one or morespecific values in the queried table(s). You can also match types of values, orcharacter patterns. You can specify the following types of matches:exact matches inexact matches (the LIKE operator) ranges of values (comparison operators) non-matches (the NOT operator) blank values (the BLANK operator) todays date (the TODAY operator) patterns of non-specific characters (wildcard operators) Specifying exact matches You can define a selection condition that retrieves only records that have a specific value in a field. Paradox includes in the Answer table only recordswith that value in that field. Exact matches are case-sensitive. You canspecify exact matches for as many different fields as you want. T ype all of thevalues you want to see exactly as they appear in the table in theappropriate fields of the query image. Querying your database 333 | 292806769-Paradox-9-Eng.pdf |
To create an exact match selection condition T ype the value you are looking for in the appropriate field of the query image. Field type restrictions You cannot specify exact matches for BLOB fields. You must use the..wildcard operator to specify selection conditions in memo and formattedmemo fields. See Using wildcards to match a pattern on page 338. Exact matches of logical fields include uppercase or lowercase T and F and any combination of uppercase and lowercase letters of the entire words Trueand False. Specifying inexact matches: the LIKE operator You can use the LIKE operator in a QBE query image to match inexactalphanumeric values. This is particularly useful for finding values that containtypographical errors or alternate spellings. If the Answer table to a query does not include some records you expected to see, try using LIKE with one or more alpha fields; the records you arelooking for might contain typographical errors, misspellings, or alternatespellings. There are two general rules for obtaining a match with the LIKE operator:The first character of the pattern you specify with the LIKE operator must match exactly (though case does not matter). LIKE Californiadoes not match Kalifornia. A pattern matches if at least one-half to two-thirds of the charactersmatch. To use the LIKE operator T ype LIKE in front of the value you think will match the records youwant. Field type restrictions You cannot use LIKE on BLOB fields or d BASE memo fields. Although you can use LIKE in number and date fields, you will get better results by using the wildcard operators..and @ to specify a number or date pattern. 334 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Matching a range of values: comparison operators If you want a QBE query to retrieve records that match a range of values, use comparison operators, also known as range operators. Comparison operatorslet you specify a range of values in a single field. You can combinecomparison operators to construct a limited range of values. To use a comparison operator T ype it in front of the value you are using to define the range. To combine comparison operators Separate all the comparison conditions with a comma. Equal to* (=) Examples Match = 3/17/97 Only March 17,1997 = Ralph Only Ralph = False Only False Greater than (>) Examples Match > 3/17/97 Dates later than March 17, 1997 > Ralph Rat, Rudolph, etc. > False True, T, Yes, 1 Less than (<) Examples Match < 3/17/97 Dates before March 17, 1997 < Ralph Charles, etc. < True False (by convention, False < True) Greater than or equal to (>=) Examples Match >= 3/17/97 March 17,1997 and later dates >= Ralph Ralph, Raphael, Randolph, etc. Querying your database 335 | 292806769-Paradox-9-Eng.pdf |
Less than or equal to (<=) Examples Match <= 3/17/97 March 17, 1997 and earlier dates <= Ralph Ralph, Manny, Charles, etc. *The =operator is optional in these cases because it is assumed when no other comparison operator is used. Example The following query retrieves all stock that costs more than $1000: Field type restrictions You can use comparison operators with alphanumeric values and all number, date, and logical values. You cannot use them with BLOB or d BASE memovalues; you can only use the equal to (=) operator with these types. Specifying non-matches: the NOT operator The NOT operator finds records that do not have a specified value in aparticular field. NOT can precede exact values, ranges, wildcard patterns, orother selection conditions. In fact, you can precede any valid Paradoxselection condition with NOT. If the selection condition you specify after NOT is an exact match condition, you must type the condition with exactly the same capitalization and spellingas the matching value appears in the table. Values in logical fields are anexception to this rule. The case of the NOT operator does not matter. 336 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
To use the NOT operator T ype NOT before the example of the value you do not want to see. Finding blank values The BLANK operator finds records with no value in a specified field. In some cases, the absence of a value is in itself a useful piece of information. Youmight also want to find records with a blank field so you can fill in informationthat was unavailable when the record was entered. You can combine NOTwith BLANK to find all records that have any value in the specified field. Searching for blank field values is entirely different from leaving a field blank in a query image. Using the BLANK operator tells Paradox you want to seeonly those records that have no value in the specified field. However, whenyou leave the field of a query image blank, Paradox does not consider thefield at all when selecting records. To use the BLANK operator T ype BLANK in the appropriate field of the query image. When you use comparison operators or sort by a field that has blankvalues, blank fields are considered to have a lower value than anynonblank value. Finding the current date In date fields of a QBE query image, the TODAY operator always stands fortodays date. Make sure your computers calendar is set properly. TODAY isespecially useful for aging payables and receivables when you use Paradoxsarithmetic operators. To use the TODAY operator T ype TODAY in the appropriate field of the query image, in combinationwith the appropriate operators or values. For example: Expression Meaning < TODAY Finds dates earlier than todays date < TODAY-90 Finds dates earlier than 90 days ago TODAY + 30 Finds dates 30 days ahead of todays date Querying your database 337 | 292806769-Paradox-9-Eng.pdf |
Example The following query retrieves orders that were placed on the day that the query is run: Using wildcards to match a pattern Paradox provides two wildcard operators to match patterns of characters in QBE queries. Although the LIKE operator is useful for finding inexactmatches in alpha fields, wildcard operators give you more flexibility. You can type any combination of uppercase and lowercase letters and your query will produce the same results. The.. wildcard operator The..wildcard operator matches any series of any number of characters, including blank spaces. The.. wildcard operator is case-insensitive. Pattern Matches G.. Giant, gigantic, Georgia g..t Giant, gross weight..D Grand, Elm Road..e..s Phillip Edward Wilson, roses 7..5 7485, 70,005 6/../96 6/01/96, 6/25/96 The @ wildcard operator The @ wildcard operator matches any single character (letter or number). You can use any number of @ characters to specify a pattern. The @wildcard operator is case-insensitive. When you know how many characters are in the pattern youre looking for, you can use that number of @ wildcard operators instead of using the..wildcard operator. 338 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Pattern Matches m@@e Mike, more, made wom@n Woman, women s@@@@ Smith, Smyth, scent 19@2 1922, 1972, 1992 Field type restrictions You can use these operators in any field except in binary, graphic, OLE, or logical fields. T o retrieve values from a memo or formatted memo field, you must use the.. wildcard operator to specify a pattern-selection condition. T yping an exactmatch in these field types means typing the entire memo value; to preventthis unnecessary effort, Paradox does not allow it. You can also use the @wildcard operator to specify a pattern match in these field types, but youmust use it in combination with the.. wildcard operator. Using wildcards with numbers If the meaning of a comma or period is not clear, you must help Paradoxunderstand the symbols meaning with double quotation marks or spaces. The meaning of a comma or period will not be clear as a thousand separator if you are specifying a pattern match with the..or @ wildcard operators; therefore, do not type thousand separators when you specify a numericpattern with..or @. If there is a chance that a decimal or thousand separator will be confusedwith the..or @ wildcard operator, use quotation marks. For details, see Rules for entering numbers in QBE queries on page 316. Paradox considers only significant digits in Paradox number fields when you use wildcard operators. For example, @@@. @ matches 400. 70, because thelast 0 isnt significant. By contrast, @@@. @@ doesnt match 400. 70 for thesame reason. Example The following query finds all stock having a list price of $18 and any numberof cents. Querying your database339 | 292806769-Paradox-9-Eng.pdf |
d BASE numbers A d BASE number field has trailing zeros to the right of the decimal place. Therefore, you must add the..operator to the end of a numeric pattern, even if you are trying to match the last digits. For example,... 95.. will match all numeric values ending in. 95, but... 95 will not match. Using wildcards with dates When you enter date values for exact matches in a query image, you can use any date format that Paradox supports, including custom formats. However, when you use a wildcard to find a date, the pattern you define with the wildcard operator must reflect the date format you have set in both the Borland Database Engine (BDE) Configuration Utility and the Regional Settings in the Windows Control Panel. The BDE and Control Panel datesettings must match. Example If the date format set in both BDE and Control Panel is mm/dd/yy, you canfind orders placed in May of 1995 like this: If you have another date format set, use that format in the wildcard query. Using AND in selection conditions When you enter selection conditions in separate fields on the same line of a QBE query image, all conditions on that line must be met by a record in thetable for the query to retrieve that record. This type of operation is called alogical AND, and means that all conditions must be met. You can also express a logical AND in a single field that is, enter more than one condition in a field and require that they all be met by separatingthe conditions with commas. The comma acts as an AND operator and tells Paradox that both (or all) conditions must be met for a match to occur. 340 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
If you want to enter a comma in a query without Paradox interpreting it as the AND operator, enclose the comma in quotation marks. You can use the AND operator in all field types including BLOBs. Whenever you query a memo or formatted memo field, you must use the.. wildcard operator in addition to any other selection conditions oroperators you use. Specifying AND conditions in the same field The comma(,)acts as an AND operator, and tells Paradox that both (or all)conditions must be met for a match to occur. Because a value in a single fieldcannot be two or more values at the same time, the AND conditions youspecify in a single field can be any kind except exact match conditions forexample, two or more types of patterns, or two range conditions. You can specify AND selection conditions across linked tables in the same way as you would specify AND conditions for a single table. To specify an AND selection condition in a single field Use a comma(,)t oseparate AND conditions in a single field of a QBEquery image. T ype the entire AND expression on the same line of thefield. Example The following query asks to see list prices in the Stock table that are lessthan or equal to $50. 00 and that end with the number 5. Querying your database341 | 292806769-Paradox-9-Eng.pdf |
If you have the United States number format set, spaces are not necessary between the conditions and the AND(,)operator. If you havethe international number format set, a space is necessary on one side ofthe comma. Specifying AND conditions in different fields You can specify exact matches on more than one field in a single query that is, all conditions must be met for a match to occur. You can specify ANDselection conditions across linked tables in the same way as you wouldspecify AND conditions for a single table. To specify AND conditions in different fields T ype the conditions on the same line of the QBE query image, and placeeach condition in its respective field. You must type all of the values you want to see exactly as they appear in the table in the appropriate fields of the query image. Example The following query specifies AND conditions on more than one field: Using OR in selection conditions You can set logical OR operations in a QBE query. That is, you can retrieverecords that meet either of two (or any of several) conditions. You can createa query that specifies OR conditions in two or more tables. You can alsocombine AND and OR conditions in a single QBE query. 342 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Field type limitations You can use the OR operator in all field types, including BLOBs. Whenever you query a memo or formatted memo field, you must use the..wildcard operator in addition to any other selection conditions or operators you use. Specifying OR conditions in the same field Specify conditions in a single field on the same line of a QBE query image to tell Paradox you want records that meet any of two or more conditions in thatfield. To specify an OR selection condition in a single field T ype the conditions in the field, separated by the OR operator. Example The following query retrieves a list of all dive shops from the sample Customer table that are in either California or Hawaii. Specifying OR conditions in different fields You can specify OR conditions for different fields of the table you arequerying. You perform this kind of OR operation by typing selectionconditions on different rows of the QBE query image. T o display fields in the Answer table with this kind of query, you must check the check boxes in the same field in each row. For example, if you check the Name field in the first row, you must also check the Name field in all otherrows of the query. Otherwise, Paradox displays error messages that statethat the query appears to ask two unrelated questions or that one or morequery rows do not contribute to the Answer. Querying your database 343 | 292806769-Paradox-9-Eng.pdf |
If you are working with multiple tables, all query images of linked tables must have the same number of rows and be linked with different exampleelements for each line of the common field. To specify an OR selection condition between different fields T ype the conditions on separate rows of the query image. T o add additional rows to the query, follow the editing instructions in Working with QBE query images on page 323. Example The following query finds the names of the contacts for customers locatedeither in the city of Nassau or in the country of Jamaica. The same exampleelements are used on corresponding rows of the query images (join1 on thetop rows and join2 on the bottom rows). You cant use the OR operator on example elements. The condition Qty or Price, where Qty and Price are example elements, returns an errormessage. This is because an example element stands for all the values inthe field. You cant tell Paradox that either Qty or Price can represent allthe values in the field. Using example elements in QBE queries An example element represents values in the field in which it is placed. Example elements are used in two ways in Paradox: 344 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
In single-table queries, you can use example elements with query operators to perform calculations with the values in a particular field. Anexample element represents each value in turn from that field in theselection condition. In multi-table queries, you can use example elements to link tables bycommon fields. The example elements tell Paradox that two fields containcommon data although their field names differ. Each example element actsas a place marker and means If a record selected from Table A has a valuein this field, link it with all the records from Table B that have the samevalue in the corresponding field. You can use example elements in all fields except BLOB fields. Creating example elements You can type your own example elements directly in the query image, or youcan let Paradox do it for you by clicking the Join Tables button. When youcreate your own example elements, you make up names that are meaningfulto you. The Join command creates a special example element, specificallydesigned for the purpose of linking tables in a multi-table query. For moreinformation on linking tables, see Linking tables in a QBE query on page319. When you use example elements to link tables, you can add as many selection conditions as you want. You can place conditions in any QBE queryimage. The only requirement of a multi-table query is that all tables in the Query window be linked to each other. Example elements can contain any alphabetic characters (A-Z, a-z), digits (0-9), or both. They must not contain spaces, or any of the followingcharacters: *()-+/. Paradox assumes you have completed the example element when you do any of the following: Move to another field, line, or query image. Press SPACEBAR. T ype one of the characters that cant be part of an example element. Subsequent characters you type appear in normal text. To create an example element 1Click the field in the query image for which you want to create an example element. Querying your database 345 | 292806769-Paradox-9-Eng.pdf |
2Press F5 and type the word you want to use as an example element. The text for an example element should appear in red. Using an example element to represent a value You can use an example element in a selection condition when the value you want to use is stored in a table. The example element stands for whatevervalue Paradox retrieves. Example Suppose you want to know what dive shops in the sample Customer table arelocated in the same city as the VIP Divers Club. Rather than ask what citythat is and then ask what cities match it (a two-query process), you can findthe value and all matching values in one query: 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Double-click the Customer table. 4In the Name field of the query image, type VIP Divers Club. 5In the City field, press F5 and type city as the example element torepresent the city where VIP Divers Club is located. 6Press the DOWN ARROW to create a second line in the query image. 7On the second line of the query image, enable the check boxes beside the Customer No, Name, and City fields. 8In the City field on the second line, press F5 and type city again toretrieve all records whose City values are the same as the City value for VIP Divers Club. 9Click Query, Run Query. Using an example element in a range You can use example elements in queries to retrieve records that match arange of values. Example The following query lists all the stock items whose cost is greater than thecost of item number 1320. 346 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
The first line of this query retrieves the record that contains Stock No 1320 from the sample Stock table. The cost of item 1320 is represented by theexample element cost. The same example element is used in the second lineto retrieve all records with a cost greater than the cost of item 1320. The costof 1320 is $171. 00. Using an example element in a date condition You can use an example element in a date expression. Example The following query lists all orders that were shipped less than 30 days afterorder number 1010 (this includes orders that were shipped before ordernumber 1010). Order 1010 shipped on 5/14/91. This query uses an example element to represent the shipping date of order number 1010 an arithmetic expression to calculate the date 30 days after the shipping date the < (less than) operator to select the records that have shipping datesearlier than the date 30 days after the shipping date of Order No 1010 Querying your database 347 | 292806769-Paradox-9-Eng.pdf |
Using LIKE or NOT with an example element You can use example elements with the LIKE and NOT operators. Example The following query finds contacts who have been entered more than once in the sample Contacts table with slightly different last name spellings. Youcould use LIKE to look for alternative-spelling duplicates of each name, oneat a time, or you could use LIKE and NOT with example elements to find allalternative-spelling duplicates at once. The statement like name, not name specifies last names that are like one another and at the same time not exactly one another just names thathave in common at least one-half to two-thirds of the same letters. The spaceafter the comma is not necessary but makes the expression easier to read. Performing calculations with QBE queries The CALC operator performs calculations on the information in your tables. Use CALC to construct and evaluate mathematical expressions combine values from two or more fields combine field values with constants create a new field with a constant value CALC capabilities Using the CALC operator, you can 348 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
specify selection conditions to define the records on which to perform calculations type the CALC expression itself in any field of the query image use CALC with alphanumeric values and with summary operators use values from several tables in a calculation use example elements in the CALC expression to refer both to values inthe same table and to values in other tables Rules for using the CALC operator When you use CALC in a query, the Answer table generated by that querycontains an additional field for the calculated result. This means that when you create tables, there is no need to include fields for any data that can be calculated from the values in other fields the field of the query image in which you choose to type the CALCexpression does not matter you dont need to check the field in which you enter the CALC expressionbecause the CALC operator always causes Paradox to create a new field in the Answer table. If you do check the field in which you enter the CALC operator, the grouping is changed and the results are altered. Paradox gives the new field a name based on the calculation. You can use the AS operator to give the calculated field another name. Using CALC with arithmetic operators You can use CALC in any field of a QBE query image. After you type the CALC reserved word, you type the expression for the calculation you want toperform. Expressions can containconstants such as 154 or 12/24/91 example elements such as QTY arithmetic operators such as +-*/() summary operators such as SUM or MAX comparison operators such as =<>< => = Querying your database 349 | 292806769-Paradox-9-Eng.pdf |
Example Suppose you want to multiply the values of the Quantity (Qty) field in the STOCK. DB table by the values in the List Price field to obtain total costs ofthe stock you have on hand. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Double-click the STOCK. DB table. 4Enable the Stock No, Part No, Description, Qty, and List Price checkboxes in the query image. 5T ype an example element in the Qty field (press F5 and type somethinglike Qty). 6T ype an example element in the List Price field (press F5 and typesomething like Lp). After youve defined the field values you want to work with by placing example elements in the List Price and Qty fields, you can type the CALCexpression using these example elements in any field of the query image. 7In any field, type CALC and follow this with the example elementyoure using for the Qty field; then type * followed by the exampleelement youre using for the List Price field. Your query statement shouldlook something like this: CALC Qty * Lp. (You can choose whether ornot to type spaces; Paradox disregards them. ) 8Click Query, Run Query. Using CALC with alphanumeric values You can combine (concatenate) alphanumeric values and constants by using CALC and the +operator. For example you can add Ms. in front of a list of last names when the value in the Sex field is F you can use CALC to combine values from the City, State/Prov, and ZIP/Postal Code fields into a single Address field Creating a new answer field with a constant value You can create a new Answer table field that contains a constant value(number, date, or alphanumeric) rather than the result of a calculation. Paradox names the new field in the Answer table the same name as theconstant value. T o name the new field something else, use the AS operator, 350 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
as described in Renaming Answer table fields on page 326. If the new field is alpha, it has as many character spaces as necessary to hold the constantvalue. You can also create a new blank field. In this case, you must type the CALC expression in the same type of field as you want the resulting Answer field number, short integer, long integer, money, date, or alpha. To create a field with a number or date constant 1Click in any field of the query image. 2T ype the reserved word CALC, a space, and the constant number ordate value. To create a field with an alphanumeric constant 1Click in any field of the query image. 2T ype CALC, a space, double quotation marks, the alphanumericconstant (with respect for case), and end with double quotation marks. To create a blank field 1Click in any field of the query image that is of the same type as the fieldyou want to create. 2T ype CALC blank. Calculating with numeric values from different tables You can link tables and perform calculations that call on values from differenttables in a single QBE query. Suppose you want to calculate the total dollar value of all currently on-order items based on List Price (in STOCK. DB) rather than on Selling Price (in LINEITEM. DB). T o calculate this information, you must multiply the list price of all items by the quantity of that item ordered. Querying your database 351 | 292806769-Paradox-9-Eng.pdf |
The following figure shows the results: Create the following example elements by pressing F5 and then typing qty in the Qty field of the Lineitem query image price in the List Price field of the Stock query image a comma, then the expression CALC qty * price (entering Qty and Price as example elements) Use the Join Tables button to place example elements in the Stock No fieldsof both query images. Setting QBE query properties After you choose the table(s) you want to query, and Paradox displays thequery image for the table(s), you can use the Query Properties command tospecify how you want Paradox to run your queries and display the results. Answer table properties You can specify whether the results appear as an Answer table or live-queryview, whether the table type is Paradox or d BASE, and the name anddirectory of the Answer table. You can also specify the display order of fieldsin the Answer table. For more information, see Modifying and renaming the Answer table on page 324. You can specify which Answer table fields are tobe included in a sort and in what order the sort is to be done. For moreinformation, see Sorting the Answer table on page 326. QBE properties You can specify where queries are to be run (locally, remotely, or either) andwhether Paradox creates auxiliary tables for queries that change data(INSERT, DELETE, and CHANGETO queries). 352 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Query defaults or preferences You can set global defaults for some of these properties and for preferences such as the Default QBE Check T ype. These defaults are called preferencesand are set with the Preferences command (T ools, Settings menu) on the Query Page of the Preferences dialog box. All preference types can beaccessed through Setting system preferences. Query properties are saved with the query. Handling table updates Table Update Handling settings appear on the Query page of the Preferencesdialog box. However, if you want to change these settings temporarily for asingle work session, choose commands on the Query menu instead ofclicking Query, Properties. When using Paradox on a network, multiple users can make changes concurrently to a shared table in a shared data directory. You can choosewhether you want your Answer table to reflect changes made to the sourcetable(s) of your query while the query is running. To change table update handling for the current work session 1Click T ools, Settings, Preferences. 2Click the Query tab. 3Enable one of the following table update handling options: Choose Restart On Changes makes Paradox restart the query when it detects a change to the source table(s). Lock Tables locks all tables in your query and prevents any changesto the tables while Paradox runs the query. Paradox releases the lockswhen it finishes running the query. If someone else is already using thetable(s) you want to lock and query, Paradox cant place your locks. Youll see a message informing you that a table is locked. Ignore Changes allows other users to make changes to the sourcetable(s) while Paradox runs your query and prevents Paradox fromrestarting the query if they make changes. This is the default selection. Setting auxiliary table properties The INSERT, DELETE, and CHANGETO queries generate more than an Answer table. For example, CHANGETO queries create a Changed table and Querying your database353 | 292806769-Paradox-9-Eng.pdf |
INSERT queries create an Inserted table. It takes time to create these extra tables, and you may not want to create them. The auxiliary table preferences and properties let you specify whether to create these tables for queries that change data. To change the default auxiliary table options 1Click T ools, Settings, Preferences. 2Click the Query tab. 3Enable one of the following auxiliary table options: Fast Queries stops Paradox from generating auxiliary tables when yourun queries that change data. When you generate only Answer tables,your queries run more quickly. Generate Auxiliary Tables produces auxiliary tables when you runqueries that change data. To change auxiliary-table options for the current query 1With the query open, click Query, Properties. 2Click the QBE page. 3Enable one of the following auxiliary table options: Fast Queries Generate Auxiliary Tables Settings made with the Query Properties command are saved with the query. Setting remote query properties When you create a query that uses data from a remote database server, youcan choose whether you want Paradox to process the query locally (on yourhard drive) or remotely (on the server). Or, you can let Paradox decide howthe query can be run most efficiently. Whether you create a query on local (Paradox or d BASE) or remote (SQL) data, Paradox can translate your QBE statement into valid SQL syntax. Thisis done automatically when you query remote data. You can view this SQLsyntax. 354 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
To view SQL syntax With the appropriate query open, click View, Show SQL. If you prefer to write SQL syntax rather then to create QBE statements, you can use the SQL Editor to write SQL statements to be run againstlocal (Paradox or d BASE) or remote (SQL) tables. The only restriction isthat QBE must be able to interpret the SQL syntax correctly. To change the default remote query settings 1Click T ools, Settings, Preferences. 2Click the Query tab. 3Enable one of the following remote query options: Query May Be Local Or Remote makes Paradox attempt to run the query remotely (on the server). If this fails, Paradox runs the querylocally (on your computer). Run Query Remotely makes Paradox request that the server runthe query and send back only the answer data. Run Query Locally makes Paradox run the query locally. Paradoxrequests all data in queried tables from the server and runs the queryon your desktop system. To change remote query settings for the current query 1With the query open, click Query, Properties. 2Click the QBE page. 3Enable one of the following remote query options: Query May Be Local Or Remote Run Query Remotely Run Query Locally Settings made when you click Query, Properties are saved with the query. Advanced QBE queries: groups, sets, and inclusive links Paradox can perform a variety of advanced queries on groups and sets of records: Work with groups of records using summary operators and other analysis tools. Querying your database 355 | 292806769-Paradox-9-Eng.pdf |
Define and compare sets of records to show records that are and arent part of a set. Create and use inclusive links to retrieve all the records in a table,whether or not they match a selection condition. You can also use Paradox to answer questions about groups of records: Select records based on characteristics of a group, such as items that appear in two or more orders. Calculate statistics on groups of records, such as the average invoice totalof orders placed in each state or province. Compare characteristics of a group with other records, such as which ofthe customers have placed more orders than any customer in Hawaii. These questions all consider more than one record at a time. No individualrecord can answer them you have to look at the group of records. You can use the summary operators to answer these and other questions about groups of records. Querying groups of records using summary operators A summary operator performs an operation on a group of records that youdefine by checking a field or fields. You specify which records to group byusing selection conditions. Paradox has five summary operators: AVERAGE Averages the values in a group COUNT Counts the number of values in a group MAX Finds the maximum value in a group MIN Finds the minimum value in a group SUM Totals the values in a group As with Paradoxs other reserved word operators, summary operators and summary-operator modifiers are case-insensitive. You can type them inuppercase or lowercase. Field type limitations You cannot use summary operators in Paradox BLOB fields or d BASE memofields. In addition, AVERAGE and SUM cannot be used in alpha, date, time,or timestamp fields. For a complete description of field type limitations whenusing summary operators, see Paradox field types allowing QBE summaryoperators in the Reference section of the online Help. 356 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Summary operator modifiers All of the summary operators except COUNT perform their operations by default on all of the values in a group. COUNT counts only unique values in agroup by default. T o change the default behavior, apply one of thesummary-operator modifiers: ALL Considers all values in a group, including duplicates. You must use ALLwith COUNT, in the format COUNT ALL, to make COUNT count all valuesin a group, including duplicates. UNIQUE Considers only unique values in a group. You must use UNIQUE with allsummary operators except COUNT to make them perform their operationon unique values in a group instead of on all values. Defining groups You can use summary operators in combination with the type of check markyou place in the check box beside a field to define groups of data. Checkmarks (Check, Check Plus, and Check Descending) that appear on the sameline as a summary operator serve two functions: They divide the records into groups based on the values in the enabled field. They include the enabled field in the Answer table (their usual function). Example of using COUNT: selecting records based on a group count Use the COUNT summary operator to count unique values in each group. For example, suppose you want to know which countries have three or more dive-shop customers. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Double-click the CUSTOMER. DB table. 4In the Query window, enable the check box beside the Country field togroup the records by country and include the Country field in the Answertable. 5T ype COUNT >=3" in the Customer No field to have Paradox count allthe different customer numbers for each group (country) and selectgroups for which the count is three or more. Querying your database 357 | 292806769-Paradox-9-Eng.pdf |
6Click Query, Run Query. Because the Customer No field is the tables keyed field, you know that all customer numbers are unique. The COUNT operator counts unique valuesby default. If you want to count all values, including duplicates, use COUNTALL. Example of using SUM: selecting records based on a group sum Use the SUM summary operator to sum values within each group in a query. For example, suppose you want to know which customers have placed orders for which they owe $5,000 or more. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Hold down CTRL and click the CUSTOMER. DB and ORDERS. DB tables. 4Click the Open button. 5Click the Join T ables button, and click the Customer No field of each query image. 6Enable the check boxes beside the Customer No and Name fields of the CUSTOMER. DB query image. 7T ype SUM >5000" in the Balance Due field of the ORDERS. DB queryimage. The expression SUM >5000 sums the balance due for each group (customer) and selects those with balances greater than $5,000. 8Click Query, Run Query. 358 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
If you enable the check box in the Customer No field, Paradox groups the records by customer and includes this field in the Answer table. When youalso enable the check box in the Name field, Paradox also groups recordsby customer name and includes this field in the Answer table. Paradoxdoes not form a different group because there is a one-to-onecorrespondence between Customer No and Name; both form the samegroup. Example of using AVERAGE: selecting records based on a group average Use the AVERAGE summary operator to average the values in each group in a query. For example, suppose you want to know the states/provinces in which the average invoice total is less than $50,000. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Hold down CTRL and click the CUSTOMER. DB and ORDERS. DB tables. 4Click the Open button. 5Click the Join T ables button, and click the Customer No field of each query image. 6Enable the check box in the State/Prov field of the CUSTOMER. DB queryimage to group the tables records by State/Prov values and include thisfield in the Answer table. 7T ype AVERAGE <50000" in the T otal Invoice field of the ORDERS. DBquery image to average the invoices for each group (state/province) andselect those groups with less than $50,000. 8Click Query, Run Query. Querying your database 359 | 292806769-Paradox-9-Eng.pdf |
Your query result would look like this: Example of using MAX and MIN: selecting records based on a group maximum or minimum Use the MAX summary operator to find the maximum value in a group. Use the MIN summary operator to find the minimum value in a group. Thefollowing example shows a query using the MAX summary operator. Youcould do the same query with the MIN summary operator to retrieve theminimum value from the same group. Suppose you want to know the countries in which the highest total invoice is $200,000 or less. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Hold down CTRL and click the CUSTOMER. DB and ORDERS. DB tables. 4Click the Open button. 5Click the Join T ables button, and click the Customer No. field of each query image. 6Enable the check box beside the Country field of the CUSTOMER. DBquery image to group the tables records by Country values and includethis field in the Answer table. 7T ype MAX <=200000" in the T otal Invoice field of the ORDERS. DBquery image to find the total invoice for each group (country) and selectthose which total $200,000 or less. 8Click Query, Run Query. 360 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Your query result would look like this: Using the CALC operator with summary operators In a query, you can calculate new fields for each record, as well as calculate statistics (like total and average) for groups of records. For example, you canask how many of each stock item have been ordered? what is the total amount of sales for each customer? how many customers live in each country or state/province? what are the highest and lowest priced stock items? Use summary operators with the CALC operator to count, summarize, average, and find the minimum or maximum values in the fields of yourtables. Like all CALC queries, those using groups also create a new field in the Answer table. Paradox automatically names the new Answer-table fieldaccording to the group calculation. You can use the AS operator to renamethe new field. For information, see Renaming Answer table fields on page326. Example of a basic calculation on a group Suppose you want to know how many of each class of items you have instock. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Double-click the STOCK. DB table. 4Enable the check box beside the Equipment Class field to group thetables records by equipment classification and include this field in the Answer table. Querying your database 361 | 292806769-Paradox-9-Eng.pdf |
5T ype CALC SUM in the Qty field to calculate the sum of the values in this field. 6Click Query, Run Query. Your query result would look like this: Example of performing a group calculation on the entire table If you do not check any fields in a query, Paradox performs the summaryoperation or summary calculation on all the records in the table the wholetable is the group. Suppose you want to know the total number of items ordered, regardless of who ordered them or what they are or cost. 1Click File, New, Query. 2Choose the folder in which your tables are located from the Look In list box. 3Double-click the LINEITEM. DB table. 4T ype CALC SUM in the Qty field to calculate the total number of itemsordered. 5Click Query, Run Query. Your query result would look like this: 362 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Because no field is enabled, the group is the whole Lineitem table; the only field in the Answer table is the Sum of the Qty field (the result of the CALCSUM operation). Example of counting unique values The CALC COUNT query operator counts only unique values. You cannotuse COUNT in Paradox BLOB fields and d BASE memo fields. In these fieldtypes, CALC COUNT counts all values, even if you specify the UNIQUEoperator. Suppose you want to know how many customers have placed orders with your firm. 1Click File, New, Query. 2From the Samples folder, double-click the ORDERS. DB table. 3T ype CALC COUNT in the Customer No field. 4Click Query, Run Query. Your query result would look like this: Because no check boxes are enabled, the whole Orders table is the group; the only field in the Answer table is the Count Of Customer No field (theresult of the CALC COUNT operation). Querying sets of records In general, a set is a collection of objects. In Paradox, a set is a specific groupof records that you intend to query. You can use a SET query to answer aquestion that might otherwise take two or more queries. Use a SET querywhen you need to ask questions about the characteristics of a group ratherthan about individual records. SET queries are particularly useful forrevealing trends and patterns in data. Components of SET queries Every SET query consists of the following components: Querying your database 363 | 292806769-Paradox-9-Eng.pdf |
one or more lines that define a set one or more lines, all of which define other records that meet certain comparisons to the set optionally, one or more lines that display related information Guidelines for querying sets T o query a set, follow these general steps: 1Define the set. 2Define groups to compare to the set. 3Select special groups with set comparisons. Use the following set-comparison operators to compare the set to other records or groups ofrecords: ONLY NO EVERY EXACTLY Using the Group By check Sometimes you might want to group records in a query by the values in a specified field without including those values in the Answer table. T o do so,choose the Group By check from the menu of checks for the field. You canonly use the Group By check with SET queries. You cannot use it in BLOBfields. Defining a set Defining a set of records in a query is very much like selecting the records tobe included in the Answer table. A set definition is a query within a query. To define a set of records in a query 1Click File, New, Query. 2In the Select File dialog box, select the table(s) you want to query. 3In the query image(s), enter selection conditions that define the recordsto be included in the set. If the records are in more than one table, use example elements to link the tables. 4Right-click the left-most field of the query image(s), and click Set. 364 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
5Instead of enabling the check boxes beside fields to define them, type example elements. You must use example elements because lines that are a part of the set definition cannot have their check boxes enabled or contain summaryoperators. When you compare and retrieve records, you will use thesesame example elements to link the comparison lines to the set definition. Example of defining a set This example uses the sample STOCK. DB table. The single line of thisquery defines the set of stock items that are Small Instruments, but it is nota complete query. You must still compare the set to another factor. Performing set comparisons After you have defined a set in a query, you can compare the set to otherrecords. One way of doing this is to compare groups of records to the set. You can make set comparisons of two different kinds:compare other groups of records to the set use the summary operators to compute the SUM, COUNT, AVERAGE, MIN, and MAX of a sets values and then compare the results to values inother records Paradox provides four special set-comparison operators to define differentsets of records. Operator Description ONLY Displays only records that match members of the set NO Displays records that match no members of the set EVERY Displays records that match all members of the set EXACTLY Displays records that match all members of the set and no others You can use set-comparison operators in all field types except Paradox BLOB fields and d BASE memo fields. T o form groups of records to compare to the defined set, you use check marks. The method is the same as for summary operators. Querying your database 365 | 292806769-Paradox-9-Eng.pdf |
Example of performing a set comparison The Stock query image of this query (created in Example of defining a set on page 365) defines the set of stock items that are Small Instruments, but itis not a complete query. T o complete the query, add the Lineitem table andenable the Order No check box to display the group of order numbers thatcontains records that meet the conditions of the set. Now, type the setcomparison-operator ONLY, followed by the example element item, in the Stock No field of Lineitem. The query looks like this: This query: defines the set of stock items that are of the equipment class Small Instruments groups the records in the Lineitem table by order number displays the Order No field of the Lineitem table in the Answer table compares the group of line items of each order number to the set of stockitems that are small instruments, and selects those orders that containonly line items that are only small-instrument stock items The Answer table shows those order numbers that contain line items thatare only of the equipment class Small Instruments. You can use the NO, EVERY, and EXACTLY set-comparison operators the same way you use ONLY. Example of the ONLY set comparison operator The ONLY operator works the same way as summary operators in that itselects groups that contain records with the same value and no others. However, ONLY is not a query summary operator because you cannot use itto perform calculations. You can use ONLY in all field types except Paradox BLOB fields and d BASE memo fields. The following example demonstrates another SET query that is almost the same as the SET query in Example of performing a set comparison onpage 366, except that it includes the Orders table. Both queries produce the 366 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
same Answer table. The difference between the two queries is where you define the group of order numbers. Orders is a parent table to Lineitem and the two tables are linked by their Order No fields; therefore, Lineitem shouldnt have any order numbers thatdont exist in Orders. If records with order numbers that dont exist in Orders were present in Lineitem, those records would be orphans youdhave line items for nonexistent orders. If those orphan records were in Lineitem, their order numbers would appear in the query in Example ofperforming a set comparison, but not in the query of the following example. Suppose you want to query the sample tables to see orders placed for the Small Instruments equipment class and no other class of equipment. T ocreate this query, you must select the tables, join the query images, andcreate the Set comparison. To select the tables and join the query images 1Click File, New, Query. 2From the Samples folder, hold down CTRL and click the LINEITEM. DB,ORDERS. DB, and STOCK. DB tables. 3Click the Open button. 4Click the Join T ables button, and click the Order No fields of the LINEITEM. DB and ORDERS. DB query images. 5Click the Join Tables button and click the Stock No fields of the LINEITEM. DB and STOCK. DB query images. To create the Set comparison 1Click and then right-click the left-most column of the STOCK. DB queryimage, and choose Set from the list of query operations. 2In the Equipment Class field of the STOCK. DB query image, type Small Instruments to define the set of stock items that are small instruments. 3Enable the Order No. check box of the ORDERS. DB query image to groupby the values of this field and display the field in the Answer table. 4Right-click the Order No field of the LINEITEM. DB query image andclick the Group By check mark from the menu to group by the values ofthis field but not display this field in the Answer table. Querying your database 367 | 292806769-Paradox-9-Eng.pdf |
5T ype ONLY before the example element (join2) in the Stock No field of the LINEITEM. DB query image to have Paradox select only orders placedfor Small Instrument stock numbers. 6Click Query, Run Query. If you were to run this query without the ONLY set operator and without SET in the left-most column of STOCK. DB, you would get orders placedfor Small Instruments in combination with any other equipment-classitems. Performing set summaries You can compare groups of records to a defined set. You can also comparegroups of records to summary values derived from a set. T o do this, youdefine the set as usual. In the line of the query that selects the records tocompare to the set, however, you use a summary operator instead of aset-comparison operator. You can place the summary operator in anarithmetic expression. For example, suppose you want to know which dive shops had total invoice averages that were greater than the total invoice average for a particular diveshop, specifically the Adventure Undersea dive shop. You need to select andlink the tables, and then define the query. 368 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
To select and link the appropriate tables 1Click File, New, Query. 2From the Samples folder, hold down CTRL and click the CUSTOMER. DB and ORDERS. DB tables. 3Click the Open button. 4Click the Join T ables button, and click the Customer No fields of the CUSTOMER. DB and ORDERS. DB query images. To define the query 1Click and then right-click the left-most field of both query images andclick Set from the menu of query operators. 2In the CUSTOMER. DB query image, type Adventure Undersea in the Name field to define the set of dive shops that consists of just Adventure Undersea. 3In the CUSTOMER. DB query image, click the Customer No field andpress the DOWN ARROW to add a second line to the field. In the secondline of the Customer No field, press F5 and type customer as anexample element that represents each customer-number value. 4In the second line of the CUSTOMER. DB query image, enable the checkbox beside the Name field. 5In the T otal Invoice field of the ORDERS. DB query image, press F5 andtype TOTAL as an example element that represents the set of thesingle-invoice total for the Adventure Undersea dive shop. 6In the ORDERS. DB query image, click the Customer No field and pressthe DOWN ARROW to add a second line to the field. In the second line ofthe Customer No field, press F5 and type customer as an exampleelement representing each customer number value. 7In the second line of the T otal Invoice field in the ORDERS. DB queryimage, type AVERAGE > AVERAGE, and then press F5 and type TOTAL to select only those dive shops whose total-invoice averages are greater than the total-invoice average for Adventure Undersea. 8Click Query, Run Query. Querying your database 369 | 292806769-Paradox-9-Eng.pdf |
Your query result would look like this: Querying with inclusive links QBE Queries that use example elements to link tables together usually retrieve all the records in one table that match records in another table. Thistype of query represents an exclusive link and is sometimes called an innerjoin. T o produce an Answer table that includes those records that do not match records in the table to which they are linked, use the Paradox inclusion operator (!). This type of query represents an inclusive link and is sometimes called an outer join. Add the !operator to an example element in a query to retrieve all of the records in that table, whether or not they match records in another table. You can also add selection conditions to define the set of master records includedin the answer: Use multiple inclusion (!) operators to retrieve all the records from more than one table. Use!in a query that contains an arithmetic expression. Use both inclusive and exclusive links in the same query. 370 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Selection conditions with inclusive links You can specify selection conditions for inclusive links just as you can in other queries. This lets you fine-tune either the set of master records or the Lookup table records to be matched with them. If you set selection conditions for the master table, the resulting Answer table contains only those records that match the specified selectioncondition. But the Answer table still contains all of those matchingrecords, whether or not they are matched in the lookup table. Linking to all records in a table Sometimes you want all records from one table in a QBE query to appear inthe Answer table even if they are not matched in the joined table. This is called an inclusive link and it uses !(the inclusion operator). When you use the inclusion operator in one of two tables, that table is the master table. The other table is the lookup table. Paradox first retrieves allrecords from the master table. It then looks for and retrieves any matchingrecords in the lookup table. The resulting Answer table contains all recordsfrom the master table but only matched records from the lookup table. You can also use the inclusion operator on both sides of the link. For example, in a database that tracks student and course information, you mightwant to know which students did not sign up for any courses and whichcourses have no students. The choice of which table to put the inclusion operator in is important. That table is the master table and is always processed first. Therefore,two queries that are identical except for the placement of the inclusionoperator, can produce significantly different results. Rules for linking tables You cannot use both an inclusive and an exclusive link in two linked lines. For any two linked lines in a QBE query, you can use either an inclusive link (!) or an exclusive link to associate them, but you cannot use both. This is because an inclusive link includes all the records from the master table;whereas an exclusive link includes only records whose values in the linkedfields match each other. If you use both kinds, Paradox has no way to decidewhich link to process first. The resulting Answer table would be differentdepending on the sequence. Querying your database 371 | 292806769-Paradox-9-Eng.pdf |
You will not violate this rule if you remember that you can use !with any given example element only once per line and twice per query. In other words, you can use only one type of link to associate any two lines in a query. You can use an inclusive and an exclusive link in the same query. You can use both exclusive and inclusive links in the same query as long asthey do not both involve the same pair of lines. When you have both types oflink in one query, they are processed in order from least to most inclusive: 1Exclusive links, which do not retrieve records that are not matched by records in another table, are processed first. 2Asymmetrical inclusive links (with both master and lookup tables), whichretrieve all of the records from the master table but only the matchedrecords from the lookup table(s), are processed next. 3Symmetrical inclusive links (with only master tables), which include allrecords from both tables, are processed last. By processing exclusive links before inclusive links, Paradox guaranteesconsistent results to its queries. If you want Paradox to process the links insome other order, you must break your question into separate queries. Example of linking to all records in a table Suppose you want to find out if the Customer table contains customers whohave never placed an order. If you link Customer and Orders by placing anexample element in both Customer No fields, then check the fields you wantto see in the Answer table, you will see only those customer records thatmatch one or more records in Orders. If, however, you add the inclusion (!) operator after the example element in the Customer No field of Customer, you will see all customer records,including those of customers who have never placed an order. T o create thisquery, you will need to select the appropriate tables, add a new record to the Customer table, and then create the query. To select the appropriate tables 1Click File, New, Query. 2From the Samples folder, hold down CTRL and click the CUSTOMER. DBand ORDERS. DB tables. 3Click the Open button. 372 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
To add a new record to the Customer table 1Click File, Open, Table. 2From the Select File dialog box, double-click the CUSTOMER. DB table. 3Click Record, Go T o, Last to move to the last record in the table. 4Press F9 to switch to Edit mode. 5Press the DOWN ARROW to add a blank record to the table. 6T ype the following information into the appropriate fields of the table: Field Name Data Customer No 9999 Name The Human Gill Dive Shop Street 1225 E. River St. City Savannah State/Prov GA Zip/Postal Code 30541 Country U. S. A. Phone 404-555-1451 First Contact 5/31/92 7Press F9 to end Edit mode. 8Click File, Close to close the table. To create the query 1Click the Join T ables button, and click the Customer No fields of both the CUSTOMER. DB and ORDERS. DB query images. 2T ype ! after the example element (join1) in the Customer No field of the CUSTOMER. DB query image to include all customers from the Customertable in the Answer table, even if they dont have a matching record in the Orders table. 3Enable the check box beside the Customer No and Name fields of the CUSTOMER. DB query image. 4Enable the check box beside the Order No field of the ORDERS. DB queryimage. Querying your database 373 | 292806769-Paradox-9-Eng.pdf |
5Click Query, Run Query. If you scroll to the end of the Answer table, you will notice that customers without an Order No entry appear there. Example of using the Inclusion operator in a QBE query that performs a calculation You can use inclusion operators in a query that performs a calculation. For example, suppose youre concerned about orders you cant fill with your current inventory. More specifically, you want a list of all orders and tohighlight orders for quantities that exceed one quarter of the quantities instock. T o do this, you need to select and join the appropriate tables andcreate the query. To select and join the appropriate tables 1Click File, New, Query. 2From the Samples folder, hold down CTRL and click the STOCK. DB,LINEITEM. DB, and ORDERS. DB tables. 3Click the Open button. 4Click the Join T ables button, and click the Order No fields of the ORDERS. DB and LINEITEM. DB query images. 5Click the Join Tables button to place example elements in the Stock Nofields of the LINEITEM. DB and STOCK. DB query images. To create the query 1T ype ! after the example element in the Order No field of the ORDERS. DB query image to see all order numbers. 2Enable the check box beside the Order No field in the ORDERS. DB queryimage. 3Enable the check boxes beside the Stock No and Qty fields of the LINEITEM. DB query image. 4In the Qty field of the LINEITEM. DB query image, press F5 and type qty as the example element that represents all the values, in turn, of the Lineitem tables Qty field. 5In the Qty field of the LINEITEM. DB query image, type , as Order Qtyafter the qty example element (from step 4). 6Enable the check box beside the Qty field of the STOCK. DB query image. 374 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
7In the Qty field of the STOCK. DB query image, type < (, then press F5 and type qty and a space and type * 4), as Stock Qty. 8Click Query, Run Query. The!operator in Orders ensures that the Answer table contains all orders. The qty example element is used in the expression qty*4t omultiply eachstock item quantity value in the Qty field of the Lineitem table (which represents the order quantity of each stock item) by four. The <comparison operator then looks for actual stock quantities that are less than this amount and retrieves records of orders that exceed one quarter of the inventory. Records in the Answer table that contain only an order number are those thatdo not meet the selection conditions, but are included because the inclusionoperator was used. Inserting, deleting, and changing values with QBE queries Use DELETE, CHANGETO, and INSERT queries to change the data in a table. These types of queries produce temporary tables which appear in aseparate window. The temporary tables hold data that was inserted, deleted,or changed; therefore, you can restore the original table if necessary. You can combine several operations in a single query. If you do, Paradox performs all DELETEs first, then all CHANGETOs, then all INSERT s. Youchoose INSERT and DELETE from a menu in the left-most field of a queryimage. You place CHANGETO in the field that contains the value you want tochange. DELETEdeletes records that match conditions you specify. CHANGETOchanges existing values to a new value you specify. INSERTinserts new records from one table into another table. The table you change with these queries does not have to be open in awindow. Operation order in a query involving multiple operations You can perform multiple table-changing operations in a single query. If youhave more than one query image in a Query window, the only basicrequirement for the query to work is that all tables be linked with exampleelements. You can, for example, perform a single query that deletes records from one table, inserts records into another table, and changes values in yet another Querying your database 375 | 292806769-Paradox-9-Eng.pdf |
table. You can also do a query that does an INSERT, DELETE, and CHANGETO operation in a single table. The following rules describe the order in which Paradox performs queries that involve multiple operations: 1Paradox retrieves records based on all selection conditions. 2Paradox performs any DELETEs in the order specified that is, Paradox looks in the first query image, then the second, and so on. 3Paradox performs any CHANGETOs specified in the order it finds them. 4Paradox performs any INSERT s specified in the order Paradox finds them. 5Paradox displays any temporary tables, including an Answer table,provided you checked any fields in the query image (and have not disabledthe Generate Auxiliary Tables button in the QBE page of the Query Properties dialog box (Query menu)). You can design intricate queries that save you from having to performmultiple, sequential queries. The more operations you design into a singlequery, however, the harder it becomes for you to undo the query. Inserting records with QBE queries Use an INSERT query to insert records from one or more sources into asingle target table. INSERT queries let you map which values from yoursource(s) to insert into fields in your target table. With INSERT you can insert records from one table type into another; for example, from d BASE to Paradox or Paradox to d BASE tables. For example,you can put any numeric data into any numeric field type (Paradox or d BASE) alphanumeric or character data into any alpha or character field dates into date fields Fields you leave blank (with no example element) in the target table receiveno values from the source table(s). You cannot put example elements in Paradox BLOB or bytes fields or in d BASE memo fields; therefore, youcannot insert these types of values into these types of fields. Instead of producing an Answer table, an INSERT query produces a temporary table called INSERTED. DB, which includes only the recordsinserted. 376 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Using INSERT query temporary tables Paradox generates one or two temporary tables during an INSERT query. INSERTED. DB An INSERT query produces a temporary table called INSERTED. DB. As with an Answer table, Paradox saves INSERTED. DB to your privatedirectory, overwrites it each time you run an INSERT query, and deletes itwhen you exit the program. To save INSERTED. DB with a different name 1With INSERTED. DB open, click Format, Rename. 2T ype a new name in the Rename dialog box. You can produce an Answer table in addition to the Inserted table if youenable the check boxes of fields on a separate line of the target query image. If you also supply selection conditions on that line, the records in the Answertable will reflect those conditions. However, such an Answer table does notcontain any information that has to do with the INSERT operation. For moreinformation, see Operation order in a query involving multiple operationson page 375. You can use the INSERTED table along with DELETE to undo an insertion. ERRORINS. DB If you try to insert records that violate the referential integrity of the target table or that violate validity checks established for that table (except picturevalidity checks), Paradox places the new records into a temporary table called ERRORINS. DB. Those records that do not violate referential integrity orvalidity checks are placed in INSERTED. DB. Paradox does not create the INSERTED table if you have enabled the Fast Queries option in the Query Properties dialog box. Performing an INSERT query When you perform an INSERT query, Paradox inserts the records from thesource into the target table for every field you specified. The source table isnot affected by the INSERT query. If the target table is new, you must create it before you create the query. Querying your database 377 | 292806769-Paradox-9-Eng.pdf |
To perform an INSERT query 1Click File, New, Query. 2In the Select File dialog box, hold down CTRL and select the appropriate source and target tables. 3Click the Open button. 4Link all tables using example elements. 5For each source table, specify any selection conditions. 6In the target table, place the word INSERT in the left-most column (underthe table name) by doing one of the following: T ype the letter i. Right-click the column and click Insert. Press SPACEBAR, and click Insert. Do not check any of the fields on the same line as the INSERT operator. If you do, you will get an error. 7Click Query, Run Query. Example of inserting a record with an INSERT query Suppose you want to insert a record of literal values into the CONTACTS. DBtable using an INSERT query. 1Click File, New, Query. 2In the Samples folder, double-click the CONTACTS. DB table. 3Right-click the left-most column of the CONTACTS. DB query image and choose INSERT from the menu of query operations. 4In the Last Name field, type Salviola. 5In the First Name field, type Dolores. 6In the Company field, type Keiths Dive Shop. 7In the Phone field, type 404-555-4251". 8Click Query, Run Query. Paradox opens the INSERTED. DB table. If you open the CONTACTS. DB table and scroll to the end, you will see the record you inserted. 378 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Deleting records with QBE queries Use DELETE queries to remove selected records from a table. DELETE queries are effective when the records to be deleted have something incommon that you can specify in one or more selection conditions. DELETEremoves only records, not specific field values within records. Use CHANGETO to change or remove specific field values. Instead of producing an Answer table, a DELETE query produces a temporary table in the Private folder called DELETED, which includes onlythe records deleted. Using DELETE query temporary tables Paradox generates one or two temporary tables during a DELETE query. DELETED. DB A DELETE query produces a temporary table called DELETED. DB, whichcontains only the deleted records. Paradox saves DELETED. DB to yourprivate directory, overwrites it each time you run a DELETE query, anddeletes it when you exit the program. To save DELETED. DB with a different name 1With DELETED. DB open, click Format, Rename. 2T ype a new name in the Rename dialog box. You can produce an Answer table in addition to the DELETED. DB table ifyou check fields on a separate line of the query image. If you also supplyselection conditions on that line, the records in the Answer table will reflectthose conditions, as you might expect. However, such an Answer table is notparticularly valuable, since it does not contain any information that has to dowith the DELETE operation. Using DELETED. DB to undo a deletion You can use DELETED. DB, along with INSERT, to undo a deletion. Use DELETED. DB as the source table to insert the deleted records back into thetable from which they were deleted. If you are reinserting records youdeleted from an unkeyed table, the records are inserted at the end of thetable and therefore MAY not necessarily be in their original order. You can also reinsert the deleted records into the original table by clicking T ools, Utilities, Add. Apart from these two methods, you have no other wayof recovering records deleted from a Paradox table. Querying your database 379 | 292806769-Paradox-9-Eng.pdf |
ERRORDEL. DB If you try to delete records that violate the referential integrity of the target table or that violate validity checks established for that table (except picturevalidity checks), Paradox places the new records into a temporary table called ERRORDEL. DB. Those records that do not violate referential integrity orvalidity checks are placed in DELETED. DB. Paradox does not create the DELETED. DB table if you have enabled the Fast Queries option in the Query Properties dialog box. Performing a DELETE query Instead of producing an Answer table, a DELETE query produces atemporary table called DELETED, which includes only the records deleted. To perform a DELETE query 1Click File, New, Query. 2In the Select File dialog box, hold down CTRL and select the table fromwhich you want to delete records, and the table(s) (if any) you want to jointo the target table and use to define selection conditions. 3Click the Open button. 4Place the word DELETE in the left-most column (under the table name)of the table whose records you want to delete by doing any of thefollowing in that column: T ype the letter d. Right-click and click Delete from the menu of query operations. Press SPACEBAR, then choose Delete from the menu of query operations. Do not enable any of the check boxes on the same line of the query imageas the DELETE operator. 5T ype any selection condition to select the records to be deleted. You canenter selection conditions in several fields of the same query image or infields of tables linked by example elements. Caution: If you do not enter any selection conditions, Paradox deletes all the records from the table. 6Click Query, Run Query. 380 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
Example of removing a record with a DELETE query Suppose Larrys Diving School has gone out of business and you want to remove this dive shop from the CONTACTS. DB table. 1Click File, New, Query. 2In the Samples folder, double-click the CONTACTS. DB table. 3Right-click the left-most column of the query image and choose DELETE from the menu of query operations. 4In the Company field, type Larrys Diving School. 5Click Query, Run Query. You can undo this query by following the steps in Example of undoing a DELETE query on page 381. Example of undoing a DELETE query Suppose you delete George Ahearn, your contact at Larrys Diving School,then decide you want to keep him as a contact for potential dive-shopcustomers. The easiest way to undo the deletion in this case would be to click T ools, Utilities, Add, and then add the deleted record in DELETED. DB back into CONTACTS. DB. The following example shows you another way to undo a DELETE. The method you use will depend on the complexity of the deletionyou are trying to undo. With any method, you should make copies of thetables at each stage in case you make a mistake in the recovery process andhave to undo the change. Using the Query window from Example of removing a record with a DELETE query: on page 381. 1Clear the existing selection conditions in the CONTACTS. DB query image by pressing CTRL + DEL in any field of the image. 2Add the Deleted. db query image to the Query window. 3Click the Join T ables button, and then click in each pair of matching fields in CONTACTS. DB and DELETED. DB. 4Right-click the left-most column of CONTACTS. DB, and click INSERTfrom the menu of query operations. Querying your database 381 | 292806769-Paradox-9-Eng.pdf |
5Click Query, Run Query. If you open the CONTACTS. DB table and scroll to the end, you will see George Aherns record has been added to the table. Changing values with QBE queries Use CHANGETO queries to change specific field values in a table based onconditions you specify in a query. CHANGETO provides you with a kind ofglobal search-and-replace capability. It is particularly useful when you want tochange many values that have something in common. Instead of producing an Answer table, a CHANGETO query produces a temporary table called CHANGED. DB, which contains a copy of the recordsas they existed before you changed them. Using CHANGETO query temporary tables Paradox generates one or two temporary tables during a CHANGETO query. CHANGED. DB CHANGETO produces a temporary table called CHANGED. DB, whichcontains a copy of the records as they existed before you changed them. Paradox saves CHANGED. DB in your private directory, overwrites it eachtime you run a CHANGETO query, and deletes it when you exit the program. To save CHANGED. DB with a different name 1With CHANGED. DB open, click Format, Rename. 2T ype a new name in the Rename dialog box. You can produce an Answer table in addition to the CHANGED. DB table ifyou check fields on a separate line of the query image. If you also supplyselection conditions on that line, the records in the Answer table will reflectthose conditions, as you might expect. However, such an Answer table is notparticularly valuable because it does not contain any information that has todo with the CHANGETO operation. You can use CHANGED. DB to undo changes made with CHANGETO. ERRORCHG. DB If you try to change records in a way that violates the referential integrity of the table or that violates validity checks established for that table (exceptpicture validity checks), Paradox places the new records into a temporarytable called ERRORCHG. DB. Only those records that do not violatereferential integrity or validity checks are placed in CHANGED. DB. 382 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
If you enabled the Fast Queries option in the Query Properties dialog box, Paradox does not create CHANGED. DB. Performing a CHANGETO query Instead of producing an Answer table, a CHANGETO query produces atemporary table called CHANGED. DB, which contains a copy of the recordsas they existed before you changed them. To perform a CHANGETO query 1T ype the value you want to change in the appropriate field of the queryimage. 2After the value you want to change, type a comma(,). 3After the comma, type CHANGETO and a space. (As with all of Paradoxs operators, you can type it in uppercase or lowercase. ) 4After CHANGETO and the space, type the new value to which you wantto change the current value. You can also type selection conditions in other fields to specify further which records to change. The CHANGETO operator must be on the same line in the query image as any selection conditions. Do not enable any of the check boxes on thisline of the query image. 5Click Query, Run Query. Paradox changes all records that meet the selection conditions. Undoing changes using the Changed table Use the Changed table to verify that the correct records have been changed. If you changed records that you did not mean to change, you can delete thechanged records from the queried table and reinsert the original records backinto the table from CHANGED. DB. To undo changes using the Changed table 1Run a DELETE query on the table whose records you accidentallychanged, by using the new field value(s) the one(s) you changed to as the selection condition(s). This removes the incorrect records. Querying your database 383 | 292806769-Paradox-9-Eng.pdf |
2With CHANGED. DB as the source table, and the original table as the target table, use an INSERT query to insert the deleted records back intothe original table. This action restores the queried table back to its original state. If you are reinserting records into an unkeyed table, Paradox inserts them at the endof the table. Therefore, the records may not be in their original order. For information about running a DELETE query, see Performing a DELETE query on page 380. For information about running an INSERT query, see Performing an INSERT query on page 377. Performing a multi-table CHANGETO query You can create a CHANGETO query to change the records in one table tomatch the records in another table that is linked through referential integrity. To perform a multi-table CHANGETO query 1Click File, New, Query. 2In the Samples folder, hold down CTRL, click both the master and detailtables, and click the Open button. 3Click the Join T ables button, and then click the matching fields of both query images. 4In the query image of the parent table, type CHANGETO and a spacebefore the example element in each field that you want to change. 5Click Query, Run Query. Paradox changes the values of the appropriate fields of the master table to match those of the detail table. Example of using CHANGETO with example elements You can use a CHANGETO query with example elements to perform acalculation on values in a field and to change the original values to the newcalculated values in the same field. (If you were to perform calculations usingthe CALC operator, Paradox would create a new field to hold the results in an Answer table and would leave the original values unchanged. ) 384 Paradox 9: Chapter 7 | 292806769-Paradox-9-Eng.pdf |
This query increases the list price of all stock items in the Stock table by 15%. In the query image, List Price is an example element that representsthe value in the List Price field. Querying your database385 | 292806769-Paradox-9-Eng.pdf |
Working with design objects 387WORKING WITH DESIGN OBJECTS 8 Design objects are the fields, buttons, and other attributes you see when you open a design document in Paradox. A design object can be a simple visualattribute, such as a box or line, or it can be a data entry tool, such as a field. Design objects let you enhance the functionality and effectiveness of theforms and reports you create. For example, a button object can beprogrammed in Object PAL to move forward or backwards through tablerecords. Paradox provides a wide variety of design objects to enhance the appearance and functionality of your design documents: boxes, ellipses, and lines to add graphic elements to your design button objects to send commands to Paradox chart objects to display information graphically crosstab objects to summarize information according to one or more graphics field objects to display data from tables on which the form or report wasbuilt calculated field objects to perform calculations on the values of one ormore fields graphic objects to place bitmap images in a form or report multi-record objects to display several records at one time | 292806769-Paradox-9-Eng.pdf |
notebook objects to organize large forms Active X and native Window controls, enable objects from Paradox to contain data from another application table frame objects for viewing all or part of a source table text objects to add titles, labels, and provide instructions In various instances, design object properties may be modified to suit specificrequirements. You can change an objects visual properties, such as size,color, or text style. You can also control the way an object behaves when yourun your design document. T o find out more about adding Object PAL methods to design objects, seethe Object PAL online reference. For a list of object properties, functions, and ways to modify objects, see Object property reference in the General Reference section of the online Help. Boxes, ellipses, and lines Paradox provides three drawing tools the Box, Ellipse, and Line thatyou can use to add graphic elements to your design. Use the Box tool to create squares, rectangles, and boxes. Use the Line tool to draw horizontal, vertical, or diagonal lines. Use the Ellipse tool to create circles and ellipses. Using boxes and ellipses to keep design objects together When a box or ellipse completely surrounds the borders of another object, the object within the box or ellipse is contained. 388 Paradox 9: Chapter 8 | 292806769-Paradox-9-Eng.pdf |
Contained objects move when you move their containers are deleted when you delete their containers are duplicated with the container as a group when you use the Duplicate command (Design menu) Deleting objects within a box or ellipse If a box or ellipse surrounds an object, and you want to delete the box orellipse but not the object that it contains, make sure the Contain Objectsproperty for the box or ellipse is disabled. For more information about the properties available to boxes, ellipses andlines, see the Object property reference in the online Help. Placing a box on a form or report Place a box around objects to give them frames, or use a box alone for visualimpact. You can surround objects with a box by dragging a box aroundexisting objects or by dragging existing objects into a box. You can customizeboxes to get just the look and functionality you want. To place a box on a form or report 1Click the Box tool. 2Click one of the following: T o create a box with the default size, click the area of the form or report where you want to place the box. Working with design objects 389 An example of acontained object. Theline is containedinside the ellipse. | 292806769-Paradox-9-Eng.pdf |
T o create a box of any size, click the area of the form or report where you want to place the box and drag to size the box. 3Click and drag any of the eight handles that surround the box to create thedesired shape. Placing an ellipse on a form or report Place an ellipse around objects to give them frames, or use an ellipse alonefor visual impact. You can surround objects with an ellipse by dragging anellipse around existing objects, or by dragging existing objects into an ellipse. You can customize ellipses to get just the look and functionality you need. To place an ellipse on a form or report 1Click the Ellipse tool. 2Click one of the following: T o create an ellipse with the default size, click the area of the form or report where you want to place the ellipse. T o create an ellipse of any size, click the area of the form or reportwhere you want to place the ellipse and drag to size the ellipse. 3If you release the mouse button and the ellipse is not the desired size orshape, click and drag any of the eight handles that surround the ellipse. Placing a line on a form or report You can place the following types of lines on your forms: Straight lines at any angle Curved lines Lines with arrows on the ends (only applies to straight lines) You can customize lines to get just the look and functionality you want. To place a line on a form or report 1Click the Line tool. 2Click one of the following:T o create a line at its default size, click the area of the form or report where you want to place the line. 390 Paradox 9: Chapter 8 | 292806769-Paradox-9-Eng.pdf |
T o create a line of any size, click the area of the form or report where you want to start the line and drag to size the line. 3If you release the mouse button and the line is not the desired size orshape, click and drag any of the eight handles that surround the line. To create a curved line 1Right-click the line, click Properties. 2In the Properties dialog box, click the Style page. 3Enable the Curved button. 4Click OK to return to the form or report. 5Drag an endpoint to adjust the angle of the curve. The direction of the curve depends on the direction in which you draw the line, on which endpoint you drag, and on the direction you drag theendpoint. In the following figure, each curved line was drawn in the direction of thearrow above the line. The X shows the endpoint that was dragged to makethe curve. Experiment by dragging either endpoint to get the effect you want. To straighten a curved line 1Right-click the line, click Properties. 2In the Properties dialog box, click the Style page. 3Enable the Straight button. To add arrows to straight lines 1Right-click the line, click Properties. Working with design objects 391 | 292806769-Paradox-9-Eng.pdf |
2In the Properties dialog box, click the Style page. 3Enable one of the following buttons: No Arrowremoves arrows from a line. Arrow On One Endplaces an arrow on the end of the line. The arrow points in the direction you dragged to create the line. Arrow On Both Endsplaces arrows on both ends of the line. Button objects You can create buttons on a form and then use Object PAL to associate amethod with the button. The user clicks the button to initiate the operationyou defined in the Object PAL method. Paradox allows you to create three types of buttons. Button type Appearance and Function Push This is a rectangular button that carries out attached Object PAL code when clicked. You can use the button expert to attach code to a button,or, for more advanced code, you can manually program the buttonthrough the Object Explorer. This is the default button type. Radio This is a labeled round or diamond-shaped button that provides the userwith two options. Every time this button is clicked, its value is toggledbetween true and false. Check Box This is a labeled square button that indicates a yes/no state. Each time the user clicks the button it toggles between yes/true or no/false. Buttons are available only in forms, not in reports. Placing a button on a form You place a button on a form using the button tool. After you add a button toyour form, a text object appears on top of the button to allow you to add alabel. You can also delete the label and use the Graphic tool to place a pictureor icon on the button. To place a button on a form 1Open a form in the Design Window, click the Button tool. 2Click the form to place the button at its default size, or click and drag toplace the button and specify its size. 392 Paradox 9: Chapter 8 | 292806769-Paradox-9-Eng.pdf |
To change the label 1Click the text object. 2Click again to place the insertion point in the text object. 3T ype the new label. To delete the label 1Select the text object. 2Click Edit, Delete. Paradox automatically centers the text on the button. If you dont want the label centered on the button, right-click the button, click Properties, anddisable the Center Label check box on the General page. If you move the label, you will automatically disable the Center Labeloption; you must then enable this option manually if you want to centerthe label. Choosing a button type A buttons type controls its functionality. By default, a button is a standardpush button. You can also create a radio button or check box. See Buttonobjects on page 392 for a description of the three button types. You can create a group of radio buttons or a check box from a field object. The advantage of using a field instead of a button is that a field object (the buttonor check box the user chooses) can post a value to the table to which theform is bound. Clicking the button posts the value to the table. To choose a button type 1Open a form in the Design Window. 2Right-click the button, click Properties. 3Click the General page of the Properties dialog box, choose Button T ypeand enable one of the following buttons: Push Button creates a labeled rectangular button that carries out an action described by an Object PAL method. When the button is pressed,its value is True. When the button is not pressed, its value is False. Push is the default Button T ype. Working with design objects 393 | 292806769-Paradox-9-Eng.pdf |
Radio Button creates a labeled round or diamond-shaped button that provides an option. Each time a user clicks the button, it togglesbetween being empty and being darkened. Each click also toggles itsvalue between False and True. Check Box creates a labeled square button that indicates a yes/nostate. Each time a user clicks the button, it toggles between beingenabled and disabled. Each click also toggles its value betweenFalse and True. See Button type properties in the Object property reference in the online Help for more information about button types. Choosing a button style A buttons style controls its visual display. You can customize the style ofradio buttons or check box buttons. To choose a button style 1Open a form in the Design Window, right-click the button and click Properties. 2Enable the Radio Button button, or the Check Box button on the Generalpage of the Properties dialog box. 3Enable one of the following: The Borland button to create radio buttons and check boxes that have a three-dimensional, raised look. Radio buttons are raised graydiamonds; check boxes are raised gray squares. The Windows 3D button to create radio buttons and check boxes thatlook like the ones you see in many Windows products. Radio buttonsare gray three-dimensional circles; check boxes are squares. See Style property in the Object property reference in the online Help formore information about button styles. Editing button events and methods You can use Object PAL to edit existing events and methods, or you can addnew methods to the button. This is how you assign functionality to thebutton. The user clicks the button to initiate the operation you defined in the 394 Paradox 9: Chapter 8 | 292806769-Paradox-9-Eng.pdf |
Object PAL method. For example, you could add a method to a button that tells Paradox to print a specific report, move to a specific record, or find acertain value when you push the button. To edit button events and methods 1Right-click the button, choose Object Explorer. 2Click on either the Method or Events page. 3Edit one or more Object PAL methods or events for the button. Chart objects Charts can show you the overall view of your data. They can reveal trendsand patterns and show how different parts contribute to a whole. You can usecharts to draw conclusions quickly and to see relationships in your data thatyou might otherwise miss. They expose hidden information in your tablesby breaking it into categories you specify summarizing the data within those categories sorting the summarized information See Working with charts on page 285 for more information charts and their properties. Placing a chart on a form or report T o place a chart on a form or report, you use the chart tool. You make thechart any size. To place a chart in a form or report 1Open a form or report in the Design Window, click the Chart tool. 2Click the area of the form or report where you want to place the chart. An empty tabular chart object appears with undefined x-axis, y-axis, and charted data. 3Drag the sizing handles to resize the chart. Working with design objects 395 | 292806769-Paradox-9-Eng.pdf |
In a report, the scope of a chart is determined in part by the section of the report in which it is placed. Changing chart properties Each part of a chart has unique properties, and the chart object as a wholehas properties. See the Object property reference in the online Help for moreinformation about specific chart properties. To change chart properties 1Right-click the title area to define or customize the display of the title. 2Right-click the background to format its display. 3Right-click the series to define the y-value for each series. 4Right-click the legend to format its display and position. 5Right-click the x-axis to define the field required to form the series alongthe x-axis. 6Right-click the y-axis to define the fields forming the y-axis. 7Right-click the upper left corner of the chart to define the chart object as awhole. Handles do not appear around the separate chart areas when you selectthem. This is because you cannot move the individual components of thechart object. However, the cursor changes to an up arrow when you passover an area of the chart that can be modified. 396 Paradox 9: Chapter 8 | 292806769-Paradox-9-Eng.pdf |