The company number used during execution of a BAAN 4GL query is the current company number. The current company number is:
The <table>._compnr field enables the use of different company numbers. This field specifies the actual company number of the table. When this field is undefined, the current company number is taken as the default. 'Undefined' is denoted by the value -1.
When a record is selected with 'select <table>.*', the field <table>._compnr in the record contains the company number of the table. When inserting a record in a table with a specific company number, you must fill <table>._compnr with the corresponding company number. The function db.insert() takes care of this and writes the record in the correct (physical) table. No special file pointers are necessary (for example, by using db.bind()).
Example
The record where the field ttadv100._compnr = 000 belongs to the
(physical) table ttadv100000
The record where the field ttadv100._compnr = 200 belongs to the
(physical) table ttadv100200
Using <table>._compnr in the WHERE clause
You can also use <table>._compnr in the WHERE clause of a Baan SQL statement. In this case it is used as a search condition. For example:
SELECT ttadv100.*
FROM ttadv100
WHERE ttadv100._compnr = 200 AND ttadv100.cpac = 'tt'
This query lists all records from table ttadv100200 where ttadv100.cpac has the value 'tt'.
You can use <table>._compnr in the following ways:
A list of AND conditions can contain only one condition that includes <table>._compnr. So, the following construction is possible:
WHERE <table>._compnr = 100 AND <condition>
but the following is not possible:
WHERE <table>._compnr = 100 AND <table>._compnr = 200
In a list of OR conditions, each condition must have a condition on <table>._compnr, or none of them. So, the following construction is possible:
WHERE (<table>._compnr = 100 OR <table>._compnr = 200)
AND <condition>
but the following is not possible:
WHERE (<table>._compnr = 100 OR <other_field> = <value>)
AND <condition>
Related Post:
- the default company number ( defined in the session "Maintain User Data" )
- a company number specified by the compnr.check() function
The <table>._compnr field enables the use of different company numbers. This field specifies the actual company number of the table. When this field is undefined, the current company number is taken as the default. 'Undefined' is denoted by the value -1.
When a record is selected with 'select <table>.*', the field <table>._compnr in the record contains the company number of the table. When inserting a record in a table with a specific company number, you must fill <table>._compnr with the corresponding company number. The function db.insert() takes care of this and writes the record in the correct (physical) table. No special file pointers are necessary (for example, by using db.bind()).
Example
The record where the field ttadv100._compnr = 000 belongs to the
(physical) table ttadv100000
The record where the field ttadv100._compnr = 200 belongs to the
(physical) table ttadv100200
Using <table>._compnr in the WHERE clause
You can also use <table>._compnr in the WHERE clause of a Baan SQL statement. In this case it is used as a search condition. For example:
SELECT ttadv100.*
FROM ttadv100
WHERE ttadv100._compnr = 200 AND ttadv100.cpac = 'tt'
This query lists all records from table ttadv100200 where ttadv100.cpac has the value 'tt'.
You can use <table>._compnr in the following ways:
- <table>._compnr = <number> or <number> = <table>._compnr where <number> specifies an integer number. The value of <number> is taken as the company number. It must be a 3-digit number.
- <table>._compnr = <string> where <string> specifies a list of company numbers, separated by commas [,]. This construction can be used to check a condition for a range of company numbers. The string can contain only digits and commas. (So, you specify company numbers 0 and 23 by <table>._compnr = "000,023"). For example:
- SELECT ttadv100.*
- WHERE ttadv100._compnr = "200,300" AND <condition>
- This query results in a list of the records from the table ttadv100 (with company numbers 200 and 300) that match <condition>.
- <table>._compnr IN <set specification> where <set specification> is a set of constants or a subquery.
A list of AND conditions can contain only one condition that includes <table>._compnr. So, the following construction is possible:
WHERE <table>._compnr = 100 AND <condition>
but the following is not possible:
WHERE <table>._compnr = 100 AND <table>._compnr = 200
In a list of OR conditions, each condition must have a condition on <table>._compnr, or none of them. So, the following construction is possible:
WHERE (<table>._compnr = 100 OR <table>._compnr = 200)
AND <condition>
but the following is not possible:
WHERE (<table>._compnr = 100 OR <other_field> = <value>)
AND <condition>
Related Post:
0 comments:
Post a Comment