learningnothing
learningnothing

Reputation: 51

create a view with hard coded values without writing insert

Hi i'm creating a view in the following way

CREATE OR REPLACE FORCE VIEW tableA (field1, field2)
AS
  SELECT 
    CAST("state" AS        CHAR(2)),
    CAST("LOCALITY_NAME" AS   CHAR(31)),
  FROM tableB;

I need to add one more column called 'id' and populate it with hard coded value 'abc' for all the rows. Is it possible to do that while creating the view? I have seen this thread , but i was not able to understand how it fits in my case.

Upvotes: 0

Views: 4365

Answers (2)

juergen d
juergen d

Reputation: 204756

SELECT 'abc' as id,
        CAST("state" AS CHAR(2)),
        CAST(LOCALITY_NAME AS CHAR(31)),
FROM tableB

Upvotes: 2

D Stanley
D Stanley

Reputation: 152521

Sure, just add it as a constanct value:

CREATE OR REPLACE FORCE VIEW tableA (field1, field2)
AS
  SELECT
    CAST("state" AS        CHAR(2)),
    CAST("LOCALITY_NAME" AS   CHAR(31)),
    'abc' AS id 
  FROM tableB;

Upvotes: 0

Related Questions