The DBSERVERNAME operator returns the database server name, as defined in the ONCONFIG file for the installation where the current database resides, or as specified in the INFORMIXSERVER environment variable. The two operators, DBSERVERNAME and SITENAME, are synonymous. You can use the DBSERVERNAME operator to determine the location of a table, to put information into a table, or to extract information from a table. You can insert DBSERVERNAME into a simple character field or use it as a default value for a column.
If you specify DBSERVERNAME as a default column value, the column must have a CHAR, VARCHAR, LVARCHAR, NCHAR, or NVARCHAR data type.
If you specify DBSERVERNAME or SITENAME as the default value for a column, the size of the column should be at least 128 bytes long. You risk getting an error message during INSERT and ALTER TABLE operations if the length of the column is too small to store the default value.
In the following example, the first statement returns the name of the database server where the customer table resides. Because the query is not restricted with a WHERE clause, it returns DBSERVERNAME for every row in the table. If you add the DISTINCT keyword to the SELECT clause, the query returns DBSERVERNAME once. The second statement adds a row that contains the current site name to a table. The third statement returns all the rows that have the site name of the current system in site_col. The last statement changes the company name in the customer table to the current system name:
SELECT DBSERVERNAME FROM customer INSERT INTO host_tab VALUES ('1', DBSERVERNAME) SELECT * FROM host_tab WHERE site_col = DBSERVERNAME UPDATE customer SET company = DBSERVERNAME WHERE customer_num = 120Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]