0

How to add a computed column to a table referring a field from current row at Sybase IQ 16

Here is want I want to achieve: When inserting a new row (or updating a row) I want to have a column updated based on a function referencing another field. To make an example

I've got this table:

CREATE TABLE "myTable" (
    id integer,
    sales integer,
    bonus integer
)

Where bonus should be calculated as sales * 10 -- remember, just an example.

I was thinking about adding some trigger functions doing this, but then I found computed columns -- unfortunately wasn't able to get this running.

frlan
  • 499
  • 4
  • 26

1 Answers1

1

Page Considerations When Using the CREATE TABLE Statement from the Sybase IQ 16 online manual:

Computed Columns

Computed column support differs as follows:

  • SAP SQL Anywhere supports computed columns that can be indexed.

  • Adaptive Server Enterprise and SAP Sybase IQ do not.


It seems to support views though, so you could define a view that contains the columns of the table plus the function, as another column (the column values will not be materialized this way, only computed when needed.)

ypercubeᵀᴹ
  • 92,106
  • 13
  • 189
  • 284