Cast Dialog¶
Use the Cast dialog to define a cast. A cast specifies how to convert a value from one data type to another.
The Cast dialog organizes the development of a cast through the following dialog tabs: General and Definition. The SQL tab displays the SQL code generated by dialog selections.
Create Cast dialog - General tab¶
Use the fields in the General tab to identify the cast:
The
Namefield is disabled. The name that will be displayed in theBrowsertree control is theSourcetype concatenated with theTargettype, and is generated automatically when you make selections on theCastdialogDefinitiontab.Store notes about the cast in the
Commentfield.
Click the Definition tab to continue.
Create Cast dialog - Definition tab¶
Use the fields in the Definition tab to define parameters:
Use the drop-down listbox next to
Source typeto select the name of the source data type of the cast.Use the drop-down listbox next to
Target typeto select the name of the target data type of the cast.Use the drop-down listbox next to
Functionto select the function used to perform the cast. The function’s result data type must match the target type of the cast.Move the
Contextswitch to theImplicitposition if the cast is implicit. By default, a cast can be invoked only by an explicit cast request. If the cast is markedImplicitthen it can be invoked implicitly in any context, whether by assignment or internally in an expression.
Click the SQL tab to continue.
Your entries in the Cast dialog generate a SQL command (see an example below). Use the SQL tab for review; revisit or switch tabs to make any changes to the SQL command.
Example
The following is an example of the sql command generated by user selections in the Cast dialog:
Create Cast dialog - SQL tab¶
The cast uses a function named int4(bigint) to convert a biginteger data type to an integer.
Click the
Infobutton (i) to access online help. View context-sensitive help in theTabbed browser, where a new tab displays the PostgreSQL core documentation.Click the
Savebutton to save work.Click the
Cancelbutton to exit without saving work.Click the
Resetbutton to restore configuration parameters.