DBSERVERNAME and SITENAME Operators

The DBSERVERNAME operator returns the SQL identifier of the database server, as defined by the DBSERVERNAME parameter in the ONCONFIG file for the HCL OneDB™ instance where the current database resides, or as specified in the INFORMIXSERVER environment variable. SITENAME is a keyword synonym for the DBSERVERNAME operator.

You can use the DBSERVERNAME operator to specify 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 in the CREATE TABLE or ALTER TABLE statements, the column must be 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.

The following examples use DBSERVERNAME or SITENAME in DML statements.
  • The first SELECT statement returns the name of the database server instance where the customer table resides. (Because the query is not restricted by a WHERE clause, it returns the same DBSERVERNAME value for every row in the table. If you include the DISTINCT keyword in the projection clause, the query returns DBSERVERNAME only once.)
  • The second statement adds a row that contains the name of the current database server to a table.
  • The third statement returns all rows that have the name of the current database server in the host_tab.site_col column.
  • The last statement changes to the name of the current database server the value of the customer.company column in the row whose SERIAL value of customer_num is 120:
SELECT DBSERVERNAME FROM customer;

INSERT INTO host_tab VALUES ('1', SITENAME);

SELECT * FROM host_tab WHERE site_col = DBSERVERNAME;

UPDATE customer SET company = SITENAME
    WHERE customer_num = 120;