PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, December 9, 2022

[FIXED] Why doesn't Oracle recognize a stored generated column definition?

 December 09, 2022     calculated-columns, oracle, sql, syntax     No comments   

Issue

I have the following generated column defined within a CREATE TABLE statement:

NET_ROWS_ADDED NUMBER(18) GENERATED ALWAYS AS (ROW_COUNT - PREV_ROW_COUNT) /*STORED*/,

ROW_COUNT and PREV_ROW_COUNT are simple NUMBER(18) columns previously defined in the same table.

Everything works fine as it's written.
But if I un-comment the STORED option, I get:

ORA-00907: missing right parenthesis

I need to convert this into a STORED generated column.
What is wrong with the syntax here? It all looks correct to me ...


Solution

Oracle doesn't store a virtual column on disk, it is only evaluate on demand. You are probably confused with the STORED option in MySQL. Since there is no STORED clause in Oracle, it throws a syntax error.

From documentation:

GENERATED ALWAYS

The optional keywords GENERATED ALWAYS are provided for semantic clarity. They indicate that the column is not stored on disk, but is evaluated on demand.

VIRTUAL

The optional keyword VIRTUAL is provided for semantic clarity.



Answered By - Lalit Kumar B
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing