Primary Key for Programmatic View

Hi,
I am using Jdev R2 for ADF. When I create a programmatic VO, Is it necessary to have a primary key for Programmatic VO, if yes, what can be the effective primary key?
- Vinoth

Hi Vino,
Primary keys are used to loop through the collection on tables, list of values and to access rows on a view object.
Juan Camilo

Similar Messages

  • Primary Key for a view?

    Hi everybody,
    I am wondering if there is such thing as primary key for a view? Assuming, that my view is based on a single table and it's just a subset of columns (some of them renamed) including PK of the table it's based on.
    The reason for my question is this - we're using Reverse POCO generator which automatically generates C# Model class and Configuration file for our tables and views. For the view is lists all the columns as a key and therefore I obviously can not use normal
    way of updating that view. I posted that as an issue here https://efreversepoco.codeplex.com/workitem/115 but I am thinking there is no such thing as the "primary key" for a view.
    The query used to generate the classes is extremely complex already but may be it can be modified to get the PK ?
    SELECT [Extent1].[SchemaName],
    [Extent1].[Name] AS TableName,
    [Extent1].[TABLE_TYPE] AS TableType,
    [UnionAll1].[Ordinal],
    [UnionAll1].[Name] AS ColumnName,
    [UnionAll1].[IsNullable],
    [UnionAll1].[TypeName],
    ISNULL([UnionAll1].[MaxLength],0) AS MaxLength,
    ISNULL([UnionAll1].[Precision], 0) AS Precision,
    ISNULL([UnionAll1].[Default], '') AS [Default],
    ISNULL([UnionAll1].[DateTimePrecision], '') AS [DateTimePrecision],
    ISNULL([UnionAll1].[Scale], 0) AS Scale,
    [UnionAll1].[IsIdentity],
    [UnionAll1].[IsStoreGenerated],
    CASE WHEN ([Project5].[C2] IS NULL) THEN CAST(0 AS BIT)
    ELSE [Project5].[C2]
    END AS PrimaryKey
    FROM (
    SELECT QUOTENAME(TABLE_SCHEMA) + QUOTENAME(TABLE_NAME) [Id],
    TABLE_SCHEMA [SchemaName],
    TABLE_NAME [Name],
    TABLE_TYPE
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent1]
    INNER JOIN (
    SELECT [Extent2].[Id] AS [Id],
    [Extent2].[Name] AS [Name],
    [Extent2].[Ordinal] AS [Ordinal],
    [Extent2].[IsNullable] AS [IsNullable],
    [Extent2].[TypeName] AS [TypeName],
    [Extent2].[MaxLength] AS [MaxLength],
    [Extent2].[Precision] AS [Precision],
    [Extent2].[Default],
    [Extent2].[DateTimePrecision] AS [DateTimePrecision],
    [Extent2].[Scale] AS [Scale],
    [Extent2].[IsIdentity] AS [IsIdentity],
    [Extent2].[IsStoreGenerated] AS [IsStoreGenerated],
    0 AS [C1],
    [Extent2].[ParentId] AS [ParentId]
    FROM (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT AS [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_CATALOG = t.TABLE_CATALOG
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    AND c.TABLE_NAME = t.TABLE_NAME
    AND t.TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent2]
    UNION ALL
    SELECT [Extent3].[Id] AS [Id],
    [Extent3].[Name] AS [Name],
    [Extent3].[Ordinal] AS [Ordinal],
    [Extent3].[IsNullable] AS [IsNullable],
    [Extent3].[TypeName] AS [TypeName],
    [Extent3].[MaxLength] AS [MaxLength],
    [Extent3].[Precision] AS [Precision],
    [Extent3].[Default],
    [Extent3].[DateTimePrecision] AS [DateTimePrecision],
    [Extent3].[Scale] AS [Scale],
    [Extent3].[IsIdentity] AS [IsIdentity],
    [Extent3].[IsStoreGenerated] AS [IsStoreGenerated],
    6 AS [C1],
    [Extent3].[ParentId] AS [ParentId]
    FROM (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) AS [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.VIEWS v
    ON c.TABLE_CATALOG = v.TABLE_CATALOG
    AND c.TABLE_SCHEMA = v.TABLE_SCHEMA
    AND c.TABLE_NAME = v.TABLE_NAME
    WHERE NOT (
    v.TABLE_SCHEMA = 'dbo'
    AND v.TABLE_NAME IN ('syssegments', 'sysconstraints')
    AND SUBSTRING(CAST(SERVERPROPERTY('productversion') AS VARCHAR(20)), 1, 1) = 8
    ) AS [Extent3]
    ) AS [UnionAll1]
    ON (0 = [UnionAll1].[C1])
    AND ([Extent1].[Id] = [UnionAll1].[ParentId])
    LEFT OUTER JOIN (
    SELECT [UnionAll2].[Id] AS [C1],
    CAST(1 AS BIT) AS [C2]
    FROM (
    SELECT QUOTENAME(tc.CONSTRAINT_SCHEMA) + QUOTENAME(tc.CONSTRAINT_NAME) [Id],
    QUOTENAME(tc.TABLE_SCHEMA) + QUOTENAME(tc.TABLE_NAME) [ParentId],
    tc.CONSTRAINT_NAME [Name],
    tc.CONSTRAINT_TYPE [ConstraintType],
    CAST(CASE tc.IS_DEFERRABLE
    WHEN 'NO' THEN 0
    ELSE 1
    END AS BIT) [IsDeferrable],
    CAST(CASE tc.INITIALLY_DEFERRED
    WHEN 'NO' THEN 0
    ELSE 1
    END AS BIT) [IsInitiallyDeferred]
    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
    WHERE tc.TABLE_NAME IS NOT NULL
    ) AS [Extent4]
    INNER JOIN (
    SELECT 7 AS [C1],
    [Extent5].[ConstraintId] AS [ConstraintId],
    [Extent6].[Id] AS [Id]
    FROM (
    SELECT QUOTENAME(CONSTRAINT_SCHEMA) + QUOTENAME(CONSTRAINT_NAME) [ConstraintId],
    QUOTENAME(TABLE_SCHEMA) + QUOTENAME(TABLE_NAME) + QUOTENAME(COLUMN_NAME) [ColumnId]
    FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    ) AS [Extent5]
    INNER JOIN (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT AS [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_CATALOG = t.TABLE_CATALOG
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    AND c.TABLE_NAME = t.TABLE_NAME
    AND t.TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent6]
    ON [Extent6].[Id] = [Extent5].[ColumnId]
    UNION ALL
    SELECT 11 AS [C1],
    [Extent7].[ConstraintId] AS [ConstraintId],
    [Extent8].[Id] AS [Id]
    FROM (
    SELECT CAST( NULL AS NVARCHAR (1)) [ConstraintId], CAST( NULL AS NVARCHAR (MAX)) [ColumnId] WHERE 1= 2
    ) AS [Extent7]
    INNER JOIN (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) AS [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.VIEWS v
    ON c.TABLE_CATALOG = v.TABLE_CATALOG
    AND c.TABLE_SCHEMA = v.TABLE_SCHEMA
    AND c.TABLE_NAME = v.TABLE_NAME
    WHERE NOT (
    v.TABLE_SCHEMA = 'dbo'
    AND v.TABLE_NAME IN ('syssegments', 'sysconstraints')
    AND SUBSTRING(CAST(SERVERPROPERTY('productversion') AS VARCHAR(20)), 1, 1) = 8
    ) AS [Extent8]
    ON [Extent8].[Id] = [Extent7].[ColumnId]
    ) AS [UnionAll2]
    ON (7 = [UnionAll2].[C1])
    AND ([Extent4].[Id] = [UnionAll2].[ConstraintId])
    WHERE [Extent4].[ConstraintType] = N'PRIMARY KEY'
    ) AS [Project5]
    ON [UnionAll1].[Id] = [Project5].[C1]
    WHERE NOT ([Extent1].[Name] IN ('EdmMetadata', '__MigrationHistory'));
    Thanks in advance.
    UPDATE. I made a quick Google search and found this
    http://stackoverflow.com/questions/1013333/entity-framework-and-sql-server-view/2715299#2715299
    It sounds as an interesting idea to try although I am not sure it will work with POCO Generator. But I'm going to try it now anyway.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

    UPDATE. Changing my view to be
    USE [SiriusSQL_SysManager]
    GO
    /****** Object: View [dbo].[SiriusV_SalesPointsLicensesList] Script Date: 4/30/2015 1:28:54 PM ******/
    DROP VIEW [dbo].[SiriusV_SalesPointsLicensesList]
    GO
    /****** Object: View [dbo].[SiriusV_SalesPointsLicensesList] Script Date: 4/30/2015 1:28:54 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    create view [dbo].[SiriusV_SalesPointsLicensesList]
    as
    select ISNULL(salespoint,'') as Salespoint
    , CAST(loc_suffix as smallint) as Id
    , CAST(descrip as varchar(25)) as [Description]
    , cast(mode as tinyint) as Mode
    , cast(is_access as bit) as AccessWare
    , cast(is_adv_inv as bit) as AdvInventory
    , cast(is_cw_crdt as bit) as CardwareCredit
    , cast(is_debit as bit) as DebitWare
    , cast(is_dir_net as bit) as DirectNet
    , cast(is_fbquick as bit) as FBQuickService
    , cast(is_fbtable as bit) as FBTableService
    , cast(is_grpschd as bit) as ResourceScheduling
    , cast(is_guests as bit) as Guests
    , cast(is_pass as bit) as PassWare
    , cast(is_pms as bit) as PMSInterface
    , cast(is_rental as bit) as RentWare
    , cast(is_dual as bit) as DualBook
    , cast(is_pod as bit) as PodBook
    , cast(is_private as bit) as PrivateBook
    , cast(is_resrv as bit) as Reservations
    , cast(is_teesht as bit) as TeeSheet
    , cast(is_rungk as bit) as RunGKInSales
    , cast(is_resseat as bit) as ReservedSeating
    , cast(is_kcashls as bit) as KioskCashless
    , cast(is_ksales as bit) as KioskSales
    , cast(is_kwilcal as bit) as KioskWillCall
    , cast(is_payplan as bit) as PaymentPlan
    , cast(is_test as bit) as Test
    from dbo.sales_pt
    where hidden = 0 ;
    GO
    worked!!! I now have just salespoint as the Key.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Having a problem with creating/using a primary key on a view

    I have a problem with a primary key on a view
    I created the view and primary key as follows:
    CREATE OR REPLACE FORCE VIEW "MDD"."ROCK_LU" ("DESCRIPTION",
         UNIQUE ("DESCRIPTION") RELY DISABLE,
         CONSTRAINT "ROCK_LU_PK" PRIMARY KEY ("DESCRIPTION") RELY DISABLE) AS
    SELECT DESCRIPTION
    FROM MRMC_LU
    WHERE ROCK = 'T';
    The view with the primary key appears to have been created as there were no error messages. (The above was from the sql tab in sql developer.)
    When I try to create the foreign key on my mdd_hr table - I get an error
    /* hr_name - foreign key */
    ALTER TABLE mdd_hr add CONSTRAINT hr_name_fk FOREIGN KEY (hr_name) REFERENCES rock_lu(description);
    Error report:
    SQL Error: ORA-02270: no matching unique or primary key for this column-list.
    When I lookup the index in sql developer, rock_lu_pk is not there.
    All my other foreign keys work - but I don't understand what I am doing wrong with this one. Please help.
    glenn
    Background - as to why I want to use a view as a lookup table.
    The MRMC_LU table that the view is created from is structured like:
    DESCRIPTION - MINERAL - ROCK - MODIFIER - COMMODITY
    ANHYDRITE - T - T - T
    APLITE - T - - T
    GRAPHITE - T - - - T
    GREYWACKE - - T
    DESCRIPTION is a list of all names of minerals, rocks, modifiers and commodities. T is entered in each valid field. Often a description name is used for both a mineral and a rock or a mineral and a commodity or any other combination. Because this database is just starting up, it was more efficient to create one table that could be updated (and thereby automatically update the MINERAL_LU, ROCK_LU, MODIFIER_LY, COMMODITY_LU views) rather than create and maintain four separate but similar tables. A primary key cannot be generated for the MRMC_LU table as there are nulls in each column
    except DESCRIPTION.
    Perhaps there is a smarter way to do this?

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Database Copy can't copy primary key for tables

    When I use Tools->Database Copy Wizard to copy my existing schema (for example: azteca_KSMMS) to a brand new schema (azteca), I find the primary key for some of the tables can't be copied, also the views seem not valid under the new schema (azteca). Please give me your comments about that. Thanks for your help.
    Kevin

    For example I have a table called workorder, it has a primary key with name (CW_PKEY_519, on WORKORDERID column) from the source schema (azteca_KSMMS). After I database copy to new schema azteca, the primary key lost. The data of workorder and other indexes have been copied to azteca schema.
    Kevin

  • Why create a primary key on a VIEW?

    One of our developers found that you can establish a primary key on a VIEW. What are the circumstances which would warrant something like that?
    --=Chuck

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:636499119911
    Tom,
    I am a bit confused about Constraints on Views. As per the documentation, they are not enforced. So
    what is the use for constraints on views ?
    As per "SQL Reference" documentation :
    <QUOTE>
    View constraints (at the view and at the column or attribute level) are declarative only. That is,
    Oracle does not enforce them. However, operations on views are subject to the integrity constraints
    defined on the underlying base tables, so you can enforce constraints on views through constraints
    on base tables.
    </QUOTE>
    Thanks for your time.
    Followup February 5, 2002 - 11am Central time zone:
    They are used for complex query rewrites with materialized views and such. It is more "meta data"
    -- it gives the optimizer more information, allows for a broader range of query rewriting to take
    place.
    "

  • How to genarate Primary Key for each record in XI  Mapping

    Hi,
    I need to genarate primary key for each record in the paylod in mapping..
    Eg: if i have a 10 reacords i need to have a primary key for each record..starting with the
    Record      Primary key
    First            001
    Secound      002
    Tenth         010
    If i need to write any user defined funtion... can any one provide the code for it.
    Thanks
    Amaresh

    Hi Bavesh,
    I will explain with the example:
    XML:
    <Record 1>
    <Primary key>
    <value1>
    <value2>
    </Record 1>
    <Record 2>
    <Primary Key>
    </Record 2>
    like above i will be getting n number of recored and in each record i need  to genarate primary key in XI.and the key sould be in sequence...
    like for the first record 1 secound 2 like that primary key should add to the privous Primary key.
    and this is for each payload.
    Thanks
    Amaresh

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How to set primary key for a date column

    hello experts .,
    i need to set primary key for a column consists of the datatype date. how to solve this..?

    1008318 wrote:
    its my personal need..then it is a very bad personal need. DATE is not an appropriate type to be using for a primary key, as it cannot be guaranteed to be unique, especially when inserting multiple rows at once.
    You would be better working to business needs and implementing correct technical solutions to those needs, than to just do things based on your personal needs.

  • No matching unique or primary key for this column-list --error

    CREATE TABLE CUSTOMER(CUS_NUM NUMBER(10) PRIMARY KEY,CUS_NAME VARCHAR2(50),ADDRESS VARCHAR2(50));
    CREATE TABLE ITEM(ITEM_NUM NUMBER(10),ITEM_DESC VARCHAR2(50),TYPE VARCHAR2(50),ITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE));
    CREATE TABLE ITEM_TYPE(TYPE VARCHAR2(50) PRIMARY KEY,TYPE_NAME VARCHAR2(50),SKU VARCHAR2(50),RATING VARCHAR2(50));
    CREATE TABLE ORDERS(ORDER_NUMBER NUMBER(10),CUS_NUM NUMBER(10),ITEM_NUM NUMBER(10),ORDER_POINT VARCHAR2(50),DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM));
    Hi,friends i created tables as above when i creating 'ORDERS' table the error will fir as "ORA-02270: no matching unique or primary key for this column-list".
    can any body solve this issue.
    Cheers,
    Sudhir reddy.

    For your own sanity, you should learn to format your code, or use a tool to do it for you. For the sanity of the forum members, you should preserve that code using the \ tagsCREATE TABLE CUSTOMER
    CUS_NUM NUMBER(10) PRIMARY KEY,
    CUS_NAME VARCHAR2(50),
    ADDRESS VARCHAR2(50)
    CREATE TABLE ITEM
    ITEM_NUM NUMBER(10),
    ITEM_DESC VARCHAR2(50),
    TYPE VARCHAR2(50),
    TYPE is a reserved word.  Call it ITEM_TYPEITEM_STATUS VARCHAR2(50),
    CONSTRAINT PK_ITEM PRIMARY KEY(ITEM_NUM,TYPE)
    CREATE TABLE ITEM_TYPE
    TYPE VARCHAR2(50) PRIMARY KEY,
    again, with the reserved word.TYPE_NAME VARCHAR2(50),
    SKU VARCHAR2(50),
    RATING VARCHAR2(50)
    CREATE TABLE ORDERS
    ORDER_NUMBER NUMBER(10),
    be consistent.  NUM or NUMBER.  Pick one and stick with it.CUS_NUM NUMBER(10),
    ITEM_NUM NUMBER(10),
    ORDER_POINT VARCHAR2(50),
    DISPATCH_POINT VARCHAR2(50),
    PRIORITY VARCHAR2(50),
    ORDER_STATUS VARCHAR2(50),
    CONSTRAINT PK_ORDERS PRIMARY KEY(ORDER_NUMBER,ITEM_NUM),
    CONSTRAINT FK1_ORDERS FOREIGN KEY (CUS_NUM) REFERENCES CUSTOMER(CUS_NUM),
    CONSTRAINT FK2_ORDERS FOREIGN KEY (ITEM_NUM) REFERENCES ITEM(ITEM_NUM)

  • Primary Key for DSO (2LIS_11_VAKON)

    Dear all:
    I have to create a Standard DSO out of 2LIS_11_VAKON Datasource. My question is how do I define the Primary Key for this DSO...
    I mean: (Doc.Number + Pos.Number) is enough?. or do I need some extra(s) field(s) in the Primary Key?
    Regards.

    Hi
    I have to create a Standard DSO out of 2LIS_11_VAKON Datasource. My question is how do I define the Primary Key for this DSO...
    I mean: (Doc.Number + Pos.Number) is enough?. or do I need some extra(s) field(s) in the Primary Key?
    You can Install the Standard content You cannot Create any Standard DSO.
    You can Create a customized DSO . Though the DSO is a Table There is no need of Primery Key Function here. Hope You are Talking about Data Fields and Key Fields.
    But there is a Standard DSO FOR  0SD_O05 Order: Condition Data.. you can install the same.
    Both fields are needed to report analytical data  based on your criteria.
    http://help.sap.com/saphelp_nw70/helpdata/EN/3c/7b88408bc0bb4de10000000a1550b0/frameset.htm

  • Primary key for an column consisting duplicates

    hi,
    ------->i have created a table and
    -------> i have a column consisting of 1000 records (but where i have duplicates)
    and now i want to create a primary key for the column
    how can i do it....

    Hi,
    You can find records which contains duplicate values for the table column using Oracle exceptions table. Please see a small demonstration:-
    SQL> create table test1(id number);
    Table created.
    SQL> insert into test1 values(&id);
    Enter value for id: 1
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(1)
    1 row created.
    SQL> /
    Enter value for id: 2
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(2)
    1 row created.
    SQL> /
    Enter value for id: 3
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(3)
    1 row created.
    SQL> /
    Enter value for id: 1
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(1)
    1 row created.
    SQL> /
    Enter value for id: 3
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(3)
    1 row created.
    SQL> /
    Enter value for id: 4
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(4)
    1 row created.
    SQL> /
    Enter value for id: 5
    old 1: insert into test1 values(&id)
    new 1: insert into test1 values(5)
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> alter table test1 add constraint id_pk primary key(id);
    alter table test1 add constraint id_pk primary key(id)
    ERROR at line 1:
    ORA-02437: cannot validate (SYS.ID_PK) - primary key violated
    SQL> alter table test1 add constraint id_pk primary key(id) exceptions into exceptions;
    alter table test1 add constraint id_pk primary key(id) exceptions into exceptions
    ERROR at line 1:
    ORA-02445: Exceptions table not found
    SQL> @?/rdbms/admin/utlexcpt
    Table created.
    SQL> alter table test1 add constraint id_pk primary key(id) exceptions into exceptions;
    alter table test1 add constraint id_pk primary key(id) exceptions into exceptions
    ERROR at line 1:
    ORA-02437: cannot validate (SYS.ID_PK) - primary key violated
    SQL> desc exceptions
    Name Null? Type
    ROW_ID ROWID
    OWNER VARCHAR2(30)
    TABLE_NAME VARCHAR2(30)
    CONSTRAINT VARCHAR2(30)
    SQL> select * from exceptions;
    ROW_ID OWNER TABLE_NAME CONSTRAINT
    AAAc95AABAAA9EpAAD SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAA SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAE SYS TEST1 ID_PK
    AAAc95AABAAA9EpAAC SYS TEST1 ID_PK
    SQL> select * from test1 where rowid in(select row_id from exceptions);
    ID
    3
    1
    1
    3
    Thanks
    Edited by: rarain on May 28, 2013 12:10 PM

  • Setting a Primary Key for a newly added Column

    Is it possible for setting a primary key for a newly added column in a table having records?

    Hi,
    km**** wrote:
    oh if the table has records then it is not possible ah...No, the table can have rows at the time you add the Primary Key constraint. Solomon was just saying that the column(s) that you are making into the Primary Key must already have unique values. A Primary Key can not be NULL, so you must do the steps in this order:
    (1) ALTER TABLE to add the column(s) (if this hasn't been done already)
    (2) UPDATE the table, to put unique values in all rows for the Primary Key column(s)
    (3) Add the PRIMARY KEY constraint
    You need to do step (2) before you do step (3)

  • Primary key for table

    I have a table Gr_order which was populated ages ago and now it need to be populated
    with some more look up data.
    "Orderid" is primary key for the table but question is how do I insert "orderid" in insert statement in procedure. I could not find any sequence name. There are 1230
    records which need to be inserted.
    Desc Gr_order
    Orderid  Number Primary key
    Desc     Varchar2
    INSERT INTO gr_order (orderid,desc) 
    VALUES (???, upper(each_pom.desc);Thanks
    sandy

    You find the code that inserts into the table and see if it uses the sequence ;-) . A sequence is not "attached" to a particular table - it is up to the inserting statement to decide if a sequence is to be used.
    You might want to check if the table has a trigger - some developers like to emulate MS-sql server behaviour by having a trigger on the table that selects from a sequence. If it has such a trigger, then you just do your inserts without specifying order_id. But if the table does not have such a trigger, then you cannot know if the table was originally populated using a sequence or not (unless you can find the insert statements somewhere.)

  • Primary key for a Materialized view

    Hi,
    Can I create a primary key on a materialized view.
    Regards,
    Poulose

    Hi,
    The follwoing is my Mview query, But I am getting missing key word error. Please help.
    create materialized view d_ledger_type_code_mv
    with primary key
    as
    select -1 as ledger_type_code_skey, 'Unknown' as ledger_type_code from dual
    union all
    select rownum as ledger_type_code_skey , replace(ledger_type_code,'''','') from
    select substr (txt,
    instr (txt, ',', 1, level ) + 1,
    instr (txt, ',', 1, level+1) - instr (txt, ',', 1, level) -1 )
    as ledger_type_code, GTA_EDW_CONFIG_FILTER_VALUE
    from (select ','||GTA_EDW_CONFIG_FILTER_VALUE||',' txt, GTA_EDW_CONFIG_FILTER_VALUE from gta_enterprise.GTA_EDW_CONFIG
    where GTA_EDW_CONFIG_FILTER_BKEY = 'GL_TYPE_FILTER')
    connect by level <= length(GTA_EDW_CONFIG_FILTER_VALUE)-length(replace(GTA_EDW_CONFIG_FILTER_VALUE,',',''))+1
    Poulose

  • Primary Key for Read Only Entity Beans In EJB 3.0

    Hi,
    I have checked the spec for ejb 3.0 which mentions that, there is no common standard for the vendor to implement the Read only Entity Beans.
    My question over here is how it is implemented in OC4J??
    Do we need to specify a primary key attribute in the read-only entity bean?
    w.r.t BC4J(ADF) i remember, we used to create a read-only View Object with out specifying a primary key.
    Just want to check is that the way it works in EJB 3.0 (Implemented by OC4J).
    Thanks for your help in advance.
    Shiva

    Hi,
    Try using the JBoss embedded container:
    http://docs.codehaus.org/display/MAVENUSER/How+to+use+the+JBoss+Embedded+EJB3+Container+for+Unit+testing
    /klejs

Maybe you are looking for

  • A flex success story

    I’ve run into some surprisingly great Flex results recently. I’m not a professional recording engineer, I’m a gigging multi-instrumentalist musician and home song writer. Over the past decade I’ve been recording on a Korg hard drive 16 track recorder

  • Question marks in email.

    When I send email using the rich text setting, the receiving party sees "?" marks at the end of every line. Any ideas?

  • Live view different from design view

    Hi folks, Does anyone know why, in dreamweaver, there is a difference between the site design in Design View and what you see in live view; and how should oneapproach this difference? Thanks.

  • Enum to ascii

    How can I convert enum datatype to ASCII..? Solved! Go to Solution.

  • XML Files - PLEASE help!!

    Hi guys! Am desperately seeking some help on an XML issue please!! Am just wondering if anyone knows any limitations of having large XML files within B2B applications. Everywhere I look seems to suggest that there's no limit on the size of an XML fil