Firebird Documentation IndexFirebird 2.5 Release NotesProcedural SQL (PSQL) → Borrow Database Column Type for a PSQL Variable
Firebird Home Firebird Home Prev: Autonomous TransactionsFirebird Documentation IndexUp: Procedural SQL (PSQL)Next: New Extensions to EXECUTE STATEMENT

Borrow Database Column Type for a PSQL Variable

Adriano dos Santos Fernandes

Tracker reference CORE-1356.

This feature extends the implementation in v.2 whereby domains became available as “data types” for declaring variables in PSQL. Now it is possible to borrow the data type of a column definition from a table or view for this purpose.

Syntax Pattern

    data_type ::=
         <builtin_data_type>
       | <domain_name>
       | TYPE OF <domain_name>
       | TYPE OF COLUMN <table or view>.<column>
    

Note

TYPE OF COLUMN gets only the type of the column. Any constraints or default values defined for the column are ignored.

Examples

CREATE TABLE PERSON (
  ID INTEGER,
  NAME VARCHAR(40)
  );

CREATE PROCEDURE SP_INS_PERSON (
  ID TYPE OF COLUMN PERSON.ID,
  NAME TYPE OF COLUMN PERSON.NAME
  )
  AS
DECLARE VARIABLE NEW_ID TYPE OF COLUMN PERSON.ID;
BEGIN
  INSERT INTO PERSON (ID, NAME)
    VALUES (:ID, :NAME)
    RETURNING ID INTO :NEW_ID;
END
    
Prev: Autonomous TransactionsFirebird Documentation IndexUp: Procedural SQL (PSQL)Next: New Extensions to EXECUTE STATEMENT
Firebird Documentation IndexFirebird 2.5 Release NotesProcedural SQL (PSQL) → Borrow Database Column Type for a PSQL Variable