3.8. Conversions

In the object hierarchy of every schema are conversions. You can add conversions by selecting CREATE CONVERSION from the conversions context menu. Once a conversion has been created, it can be dropped. This section describes how to create and drop a conversion with Administrator.

The CREATE CONVERSION dialog consists of an entry box at the top for the name of the conversion. Below, is the Default checkbox. Below that are the From and To combo-boxes. These specify the source and target encoding for the conversion. Finally, there is the From Function. This is the function that will be used to carry out the actual data conversion.

In this example, you will create a simple conversion called big5_to_utf8 under the public schema. Note that a conversion for big5 to utf8 already exists under the pg_catalog schema. This example will simply create a second one in the public schema.

  1. Start by expanding the database under which you wish to create the conversion (click the [O-] beside the database name), then expand the public schema.

  2. Next, right click on the Conversions header and choose CREATE CONVERSION.

  3. For the name, type: big5_to_utf8

  4. Next is the Default checkbox; leave this unchecked as you are only creating an example and are not interested in making this the default conversion.

  5. Next is a combo-box for selecting the source encoding (From). As you are writing a conversion from big5 to utf8, the source in this case is big5.

  6. Set the target combo-box (To) to utf8.

  7. For conversion function (From Function), select the function:

    big5_to_utf8(pg_catalog.int4, pg_catalog.int4, 
                 pg_catalog.cstring, pg_catalog.cstring, 
                 pg_catalog.int4)

    Figure 3-32. The CREATE CONVERSION Dialog

  8. Click OK to create the conversion.

Figure 3-33. The public Schema Conversion Tree View and Detail View

Note that the conversion big5_to_utf8 has been added under the Conversions node in the Tree View.

Administrator also enables you to perform the following operation on existing conversions:

Dropping

To drop a conversion, right-click on the conversion and select either DROP RESTRICT or DROP CASCADE. DROP RESTRICT will not drop the conversion if there are any dependent objects. DROP CASCADE automatically drops the conversion and all objects that depend on it.

If Preferences => Ask For Confirmations is enabled, you are asked to confirm that you want the conversion dropped (and all the dependent objects in case of a DROP CASCADE); if it is disabled, the conversion is dropped immediately (along with its dependent objects if DROP CASCADE was selected). This action cannot be undone.