Constraints on views

can any tell that it is possible to define constraints on views and if yes then please explain the use of constraint on views and how it works and how it can define on the views. please help me in this topic

1) While Creating the View we can define the Constraints.
2) Basically to filter out the data as per the requirements.
3) a. Works as an Sql query and
b. Define, as we do it in an query.

Similar Messages

  • Constraint On Views

    Dear All,
    Can we Implement Constraints ,like UNIQUE,PRIMARY KEY,FOREIGN KEY
    on a view.
    we are using Oracle 10g.
    Waiting for ur valuable replies,
    Muhammad Mohsin Zia

    No Mr.mohsin. Its not possible i think.
    K y do you want it to be on view. A view is nothing but a image of a actual base table. If you want a column to be constrained you make it in the base table
    chikki

  • Primary Key constraint on Views

    Hi
    Can primary key or unique key constraint can be imposed on a View created in Oracle 9i?
    Thanks in advance

    Hi
    Can primary key or unique key constraint can be
    imposed on a View created in Oracle 9i?
    Thanks in advanceNot sure whether you want to know about Materialized view or not !
    But if it is just a View then the Primary Key and Unique Key can be imposed in its underlying Table(s).
    Thanks

  • View constraints in 10g

    In 10g what is the use of primary key constraint on view .
    Data will come from base table. So constraints of base table will affect data.

    Hi Avinash,
    It enables sophisticated Query Rewrites, see:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/constra.htm#sthref418
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:636499119911#13041565979243
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:636499119911#2695797455172
    Edited by: hoek on Jun 28, 2009 12:54 PM YAL

  • 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.

  • Questions about updateable views

    Greetings,
    Some problems which I experienced with Delphi + Crlab ODAC + Oracle DB 10g Express and complex (joined tables) updateable views.
    1. Required field (NOT NULL) in a joined table remains required in the view. My data access components read the meta information and throw error, when nothing (NULL) is put into that field. If something different than NULL is put though, the DB throws error because this is attempt to update multiple tables. That functionality may be disabled
    in the data access components, resulting not that clean and easy to maintain exception
    handling code.
    2. CONSTRAINTS problem. It seems that any constraints on VIEW cannot be applied.
    In the original table. I had UNIQUE field, and I placed UNIQUE DISABLED NOVALIDATE
    in the view as constraint to that field in the view. It didn't prevent me to put several
    rows with the same value in that field, which appeared in the original table.
    It would be perfect if I could somehow manipulate the view meta information so my application can work with it as it was the original table (well, the original table with several read-only columns more). Is that possible in Oracle DB?

    Hi.
    For this part
    "..the DB throws error because this is attempt to update multiple tables"
    You may want to write an Instead-of-trigger
    Regards
    Peter

  • Problem with object view with primary-key based object identifier

    Hello!
    I met such problem.
    t1 is persinstent-capable class:
    class t1 : public PObject { .... };
    T1OV is object view, based on object table T1OT
    I1 is primary key of the table T1OT.
    Next code:
    t1* t = new (conn, "T1OV") t1(...);
    conn->commit();
    try
    t->markDelete();
    conn->commit(); // exception throws here
    Works fine if T1OV defined as:
    create view t1ov of t1 with object identifier default
    as select * from t1ot;
    And throws an exception
    "ORA-22883: object deletion failed"
    if:
    create view t1ov of t1 with object identifier (I1)
    as select * from t1ot;
    Such problem also occurs when object view is based on relational table/view (OID is primary-key based).
    Also it occurs when
    t->markModified() used insted of t->markDelete()
    I am using Oracle 9i second release for windows and
    MS VC++
    Thank You

    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.

  • 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.
    "

  • Constraints Questions

    Whats the difference between declarative constraints. What are the difference between declarative constraints and constraints enforced by Oracle?

    Yeah i know that. Actually i was going through Oracle's documentation Oracle 10g concepts. I was reading the topic "Constraints on Views". Its written that we can define declarative constraints on views. The below line is copied from the doc. Kindly refer below
    "Only logical constraints, that is, constraints that are declarative and not enforced by Oracle, can be defined on views. The purpose of these constraints is not to enforce any business rules but to identify multidimensional data. The following constraints
    can be defined on views:
    Primary key constraint
    Unique constraint
    Referential Integrity constraint"

  • 1-to-1 Relationship Between UI and subVI Data Cluster

    Discussion continued from here.
    In summary:
    JackDunaway wrote:
    Yes,
    I can see clear benefits in implementing this Idea - that is, if your
    underlying datatype elements have a 1:1 relationship with the UI
    elements.
    I will
    illustrate this point by showing some potential flaws in your example:
    "Profile Running" and "Profile Complete" are mutually exclusive, no?
    Wouldn't it be better to have a single enum named "Profile" with three
    elements "Idle, Running, and Complete" for the underlying datatype?
    Having two mutually exclusive pieces of data in an underlying datatype
    is among my favorite of code smell indicators.
    Also, the underlying datatype probably only needs "Forward Miles" and
    "Reverse Miles" since "Total Miles" is derived. Exclude "Total Miles"
    from the underlying cluster and just show the sum for display.
    Another
    argument against using a 1:1 relationship: the customer now wants to
    multiply speed by -1 if Direction==Reverse and not show the Direction
    enum on the UI. The data source (the VI that generates the data) would
    need to be updated using your 1:1 relationship. Using underlying data
    different from the display data, only the data client (the UI front
    panel) needs to change. I would be much more inclined to service the UI
    FP for a cosmetic upgrade rather than tracing the data source back
    through the HMI framework, through TCP, back to the RT, back to FPGA...
    Basically...
    I question a perfectly overlapped Venn Diagram where the set of data
    shown to the user equals the dataset used for underlying data
    processing/messaging/storing. The underlying datatype should be as
    stripped and streamlined as possible, while the display datatype can
    inherit all the flair and post-processing that Upper Management wants to
    see in a UI.
    LabBEAN wrote:
    <JackDunaway wrote
    I will illustrate this point by showing some potential flaws in your example...
    <LabBEAN response
    The data you see maps directly to tags on the PLC.
    <JackDunaway wrote
    Yes, I can see clear benefits in implementing this Idea - that is, if your underlying datatype elements have a 1:1 relationship with the UI elements.
    <LabBEAN response
    JackDunaway wrote:
    This is a good indicator that we're both aware at this point that I'm
    missing something... in all seriousness, could you reply to the 1:1
    argument? I really want to understand this Idea and learn how/if I need
    to apply it to my own style (our last back-and-forth turned out to be an enlightening and introspective exercise for me).
    ***EDIT: By all means, please start a discussion on the LabVIEW board so we're not hindered by the Exchange's interface. ***
    My long delayed response:
    The indicators you see map to tags on the PLC.  That is, we were connecting through OPC to an application on a PLC that was written ~15 years ago.  I have a VI where I read a bunch of SVs (Shared Variables).  Each SV is bound through OPC to a PLC tag.  In the interest of disclosure, two 16-bit tags are required to represent each 32-bit mileage number.  In the same subVI, I read each set of mileage tags, convert, and feed my subVI cluster indicator.  The same is true for wheel size:  three bits get converted to the enum.  Regardless, though, I have one subVI that reads SVs and outputs the same "underlying data" cluster that is seen on the UI.  The UI has a "Faults" cluster full of fault Booleans that follows the same logic.  When the user configures a profile of steps, they do so via an array of "step" clusters (although the cluster look is hidden for aesthetics).  It's the same thing as above except we write tags instead of reading them.
    In my case, each set of 16-bit tags is worthless as two 16-bit numbers.  They are only useful as a 32-bit mileage, so I don't pass around the raw 16-bit data.  The same is true for the wheel size bits. My software can just as easily (in fact, more easily) operate on the enum.  So, the underlying cluster from the subVI is programmatically useful and applicable to the UI.  I would guess that the same is true for a lot of RT applications, where the read VI can have some intelligence to process the data into useful / applicable clusters.
    There are going to be cases where "Upper Management" would like to see "flair and post-processing" as you say.  Your speed illustration is a good example of this.  There are also instances where the cluster works fine on the UI the way it is (like this one and many others that we've seen).
    <JackDunaway wrote
    "Profile Running" and "Profile Complete" are mutually exclusive, no?
    Wouldn't it be better to have a single enum named "Profile" with three
    elements "Idle, Running, and Complete" for the underlying datatype?
    <LabBEAN response
    Did you mean "not" mutually exclusive?  We combined 3 "dependent" (not mutually exclusive) Booleans into an enum for Wheel Size, as I mentioned above.  Not sure now why we went the other way with these two (this was 2 years ago).  In any event, with regard to UI representation, I still pass a cluster out of my read-raw-data-and-process-into-cluster subVI up to the applicable queued state machines and to the UI.
    <JackDunaway wrote
    Having two mutually exclusive pieces of data in an underlying datatype
    is among my favorite of code smell indicators.
    <LabBEAN response
    Working with applications written in ladder logic, it is not uncommon to see separate Booleans that indicate the same condition.  This seems to be especially true when safety is a concern.  That is, ladder Coil A ON and Coil B OFF == switch open.  Coil A OFF and Coil B ON == switch closed.  If you ever read OPC tags from Coil A and Coil B and the two are the same, you know the ladder is in transition (hasn't updated the tags).  Throw that point out and read again.
    I, too, appreciate our back-and-forths.  Good discussion.
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs

    Thanks for replying, Jason. Let me see if I can craft a coherent response after getting back up to speed...
    (...later)
    OK, let's go. I'm going to fully agree with you that LabVIEW imposes a strange constraint unique from most other languages where a Typedef defines two things: the underlying data structure, and also the view. A Strict Typedef should be more accurately deemed the Datatype-View-Definition, and a Typedef would be more accurately called the Datatype-Definition-and-View-Suggestion. And to be clear, there are two types of views: the programmer's view (a SubVI look and feel) and the UI view (what the user and Upper Management sees). (Finally, I admit I'm ignorant whether view or View is more a more appropriate term)
    Linking the programmer's view to the datatype is perfectly fine with me, and based on your original Idea I think we both agree that's OK. I think we run into a disagreement where you have loosely tied the concept of "Strict TD" to "UI View".
    Historically, I have used Strict Typedefs for the programmer's view (SubVIs), since I like to maintain a "functional UI" at the SubVI level. I don't use type definitions on User Interfaces - only Controls. That's the reason your Idea does not appeal to me, but perhaps if your Idea were implemented, it would appeal to me since View and Implementation would be divorced as separate entities within the Type Definition. (Does that classify as a Catch-22?) So, you're Idea is fundamentally suggesting that Type Definition .ctl files should be more accurately called "a container that holds both a Type Definition and any number of View Definitions as well".
    Fundamentally, I think I finally understand the gist of your Idea: "let's ditch this weird constraint where View and Datatype are inextricably defined together in one file", and for that, I'll give Kudos to the original Idea. I got really tied up with the example you used to present the Idea, and plus I'm still learning a lot.
    Additional thoughts:
    This Idea reminds me of another: Tag XControl as Class View
    We've still got some arguing to do on a 1:1 relationship between underlying datatype and UI presentation, so put your mean face back on: 
    Since our last conversation, interestingly, I have been on an anti-Typedef kick altogether.  Why don't you drop some feedback on my attempt at a completely typedef-free UI framework?
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

  • Bug:4705928 PLSQL: Memory leak using small varrays

    We have Oracle version 10.2.0.1.0
    We have a problem with a procedure.
    In our scenario we make use of VARRAY in the procedure to pass some filter parameters to a select distinct querying a view made on three tables.
    Unfotunately not always execution it is successful.
    Sometimes it returns wrong value (0 for the count parameter), sometimes (rarely) the server stops working.
    We suspect that this is caused by a bug fixed in versione 10.2.0.3.0
    Bug:4705928 PLSQL: Memory leak using small varrays when trimming the whole collection and inserting into it in a loop
    We suspect this becasue we made two procedure the first (spProductCount) uses a function (fnProductFilter) to calculate the values of a varray and passes them into the select,
    while in the second procedure (spProductCount2) parameters are passed directly into the statement without varray
    and there are failures only in the first procedure.
    On the other hand on another server 10.2.0.1.0 we never have this problem.
    The instance manifesting the bug runs under shared mode, while the other is under dedicated mode.
    Turning the first one to dedicated mode makes the bugs disapear.
    Unfortunately this is not a solution.
    In the sample there are the three table with all constraints, the view, tha varray custom type, the function and the two procedures.
    Is there someone that may examine our sample and tell us if the pl/sql code corresponds to the bug desciption.
    We also want to know if it's possibile that the same server running under different mode (SHARED/DEDICATED) doesn't behave the same way.
    The tables:
    --Products
    CREATE TABLE "Products" (
         "Image" BLOB
         , "CatalogId" RAW(16)
         , "ProductId" RAW(16)
         , "MnemonicId" NVARCHAR2(50) DEFAULT ''
         , "ProductParentId" RAW(16)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M04" CHECK ("CatalogId" IS NOT NULL)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M05" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "Products"
    ADD CONSTRAINT "PK_Products"
    PRIMARY KEY ("ProductId")
    CREATE INDEX "IX_Products"
    ON "Products" ("CatalogId", "MnemonicId")
    CREATE UNIQUE INDEX "UK_Products"
    ON "Products" (DECODE("MnemonicId", NULL, NULL, RAWTOHEX("CatalogId") || "MnemonicId"))
    --Languages
    CREATE TABLE "Languages" (
         "Description" NVARCHAR2(250)
         , "IsStandard" NUMBER(1)
         , "LanguageId" RAW(16)
         , "MnemonicId" NVARCHAR2(12)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M05" CHECK ("MnemonicId" IS NOT NULL)
    ALTER TABLE "Languages"
    ADD CONSTRAINT "PK_Languages"
    PRIMARY KEY ("LanguageId")
    ALTER TABLE "Languages"
    ADD CONSTRAINT "UK_Languages"
    UNIQUE ("MnemonicId")
    --ProductDesc
    CREATE TABLE "ProductDesc" (
         "Comment" NCLOB
         , "PlainComment" NCLOB
         , "Description" NVARCHAR2(250)
         , "DescriptionText" NCLOB
         , "PlainDescriptionText" NCLOB
         , "LanguageId" NVARCHAR2(12)
         , "ProductId" RAW(16)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM02" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "PK_ProductDesc"
    PRIMARY KEY ("ProductId", "LanguageId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc1"
    FOREIGN KEY("ProductId") REFERENCES "Products" ("ProductId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc2"
    FOREIGN KEY("LanguageId") REFERENCES "Languages" ("MnemonicId")
    /The view:
    --ProductView
    CREATE OR REPLACE VIEW "vwProducts"
    AS
         SELECT
               "Products"."CatalogId"
              , "ProductDesc"."Comment"
              , "ProductDesc"."PlainComment"
              , "ProductDesc"."Description"
              , "ProductDesc"."DescriptionText"
              , "ProductDesc"."PlainDescriptionText"
              , "Products"."Image"
              , "Languages"."MnemonicId" "LanguageId"
              , "Products"."MnemonicId"
              , "Products"."ProductId"
              , "Products"."ProductParentId"
              , TRIM(NVL("ProductDesc"."Description" || ' ', '') || NVL("ParentDescriptions"."Description", '')) "FullDescription"
         FROM "Products"
         CROSS JOIN "Languages"
         LEFT OUTER JOIN "ProductDesc"
         ON "Products"."ProductId" = "ProductDesc"."ProductId"
         AND "ProductDesc"."LanguageId" = "Languages"."MnemonicId"
         LEFT OUTER JOIN "ProductDesc" "ParentDescriptions"
         ON "Products"."ProductParentId" = "ParentDescriptions"."ProductId"
         AND ("ParentDescriptions"."LanguageId" = "Languages"."MnemonicId")
    /The varray:
    --CustomType VARRAY
    CREATE OR REPLACE TYPE Varray_Params IS VARRAY(100) OF NVARCHAR2(1000);
    /The function:
    --FilterFunction
    CREATE OR REPLACE FUNCTION "fnProductFilter" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId                    NVARCHAR2 := N'it-IT',
         parFilterValues                    OUT Varray_Params
    RETURN INTEGER
    AS
         varSqlCondition                    VARCHAR2(32000);
         varSqlConditionValues          NVARCHAR2(32000);
         varSql                              NVARCHAR2(32000);
         varDbmsCursor                    INTEGER;
         varDbmsResult                    INTEGER;
         varSeparator                    VARCHAR2(2);
         varFilterValue                    NVARCHAR2(1000);
         varCount                         INTEGER;
    BEGIN
         varSqlCondition := '(T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId )';
         varSqlConditionValues := CHR(39) || TO_CHAR(parCatalogId) || CHR(39) || N', ' || CHR(39 USING NCHAR_CS) || parLanguageId || CHR(39 USING NCHAR_CS);
         parFilterValues := Varray_Params();
         varSql := N'SELECT FilterValues.column_value FilterValue FROM TABLE(Varray_Params(' || varSqlConditionValues || N')) FilterValues';
         BEGIN
              varDbmsCursor := dbms_sql.open_cursor;
              dbms_sql.parse(varDbmsCursor, varSql, dbms_sql.native);
              dbms_sql.define_column(varDbmsCursor, 1, varFilterValue, 1000);
              varDbmsResult := dbms_sql.execute(varDbmsCursor);
              varCount := 0;
              LOOP
                   IF (dbms_sql.fetch_rows(varDbmsCursor) > 0) THEN
                        varCount := varCount + 1;
                        dbms_sql.column_value(varDbmsCursor, 1, varFilterValue);
                        parFilterValues.extend(1);
                        parFilterValues(varCount) := varFilterValue;
                   ELSE
                        -- No more rows to copy
                        EXIT;
                   END IF;
              END LOOP;
              dbms_sql.close_cursor(varDbmsCursor);
         EXCEPTION WHEN OTHERS THEN
              dbms_sql.close_cursor(varDbmsCursor);
              RETURN 0;
         END;
         FOR i in parFilterValues.first .. parFilterValues.last LOOP
              varSeparator := ', ';
         END LOOP;
         RETURN 1;
    END;
    /The procedures:
    --Procedure presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varResult := "fnProductFilter"(parCatalogId, parLanguageId, varFilterValues);
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, varFilterValues(1), varFilterValues(2);
    END;
    --Procedure NOT presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount2" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, parCatalogId, parLanguageId;
    END;Edited by: 835125 on 2011-2-9 1:31

    835125 wrote:
    Using VARRAY was the only way I found to transform comma seprated text values (e.g. "'abc', 'def', '123'") in a collection of strings.A varray is just a functionally crippled version of a nested table collection type, with a defined limit you probably don't need. (Why 100 specifically?) Instead of
    CREATE OR REPLACE TYPE varray_params AS VARRAY(100) OF NVARCHAR2(1000);try
    CREATE OR REPLACE TYPE array_params AS TABLE OF NVARCHAR2(1000);I don't know whether that will solve the problem but at least it'll be a slightly more useful type.
    What makes you think it's a memory leak specifically? Do you observe session PGA memory use going up more than it should?
    btw good luck with all those quoted column names. I wouldn't like to have to work with those, although they do make the forum more colourful.
    Edited by: William Robertson on Feb 11, 2011 7:54 AM

  • Trying to Reverse Engineer SAP Setup

    Hello,
    I'm a junior administrator providing remote support to a computer supplies company. Years ago, their administrators set them up to use SAP NetWeaver which they access through Juniper Instant Virtual Extranet. These administrators are no longer with the company and did not leave documentation behind. As a result, my client is now looking to add a user to be able to use SAP as well.
    I have no idea where to begin, and am wondering where to go for this. I do not think SAP itself has "users", so I'm thinking this is a Juniper issue, and will probably need to contact them.
    If anyone has any ideas, by all means, let me know.
    Thanks,
    -Jason

    Hi,
    DB2 on iSeries is not supported natively, it's treated as third party JDBC source. So you shouldn't set database type to "DB2/..." in connection properties - set empty value on that combo box.
    DB2 on iSeries supports information_schema views so in addition to standard JDBC import you'll be able to import definitions of check constraints and views.
    You can use JDBC-ODBC bridge (not included in Java 8 anymore) but usually JDBC drivers are better than their ODBC counterpart, so you can try what you'll get through third party JDBC driver path:
    this link could help on that Where do I download JDBC drivers for DB2 that are compatible with JDK 1.5? - Stack Overflow
    1)you need to add jar files using "Tools>Preferences>Data modeler>Third party JDBC drivers"
    2) set driver class in connection properties - from link above - com.ibm.as400.access.AS400JDBCDriver
    3) set JDBC URL - from link above - jdbc:as400://10.10.10.10;promt=false
    you need to put IP address of your database there
    4) leave database type empty
    Philip

  • [ACCEPT][PROMPT] Input not taken into account in the script

    Hi,
    I'm preparing sql scripts to create schemas, one of the script is the main one.
    In that one I'm requesting the passwords for two users, and a path to create an oracle directory.
    The password for the first user and the path are taken into account.
    But the second password requested seems not to be retained.
    Here is the script:
    SET ECHO OFF;
    spool epss_schema.log;
    ACCEPT EPSS_PASSWD char PROMPT 'Enter EPSS Schema password: ' hide;
    ACCEPT PIC_DIRECTORY char PROMPT 'Enter The Directory where the PIC dump files will be stored:' ;
    create user epss10 identified by &EPSS_PASSWD default tablespace users temporary tablespace temp;
    grant dba to epss10;
    connect epss10/&EPSS_PASSWD;
    @EPSS_SCHEMA.sql
    @EPSS_ACTIVITY_CODES_DATA.sql
    @EPSS_BCP_TABLE_DATA.sql
    @EPSS_CALL_SETUP_TYPE.sql
    @EPSS_COUNTRY_CD_DATA.sql
    @EPSS_ERC_KEYWORDS_DATA.sql
    @EPSS_ERC_KEYWORDS_LS_DATA.sql
    @EPSS_ERC_KEYWORDS_PE_DATA.sql
    @EPSS_ERC_KEYWORDS_SH_DATA.sql
    @EPSS_GEN_ACTIVITY_CODES_DATA.sql
    @EPSS_INSTRUMENT_LIST_DATA.sql
    @EPSS_KEYWORDS_DATA.sql
    @EPSS_NACE_CD_DATA.sql
    @EPSS_REVIEW_PANELS_DATA.sql
    @EPSS_REVIEW_PANELS_GEN_DATA.sql
    @EPSS_STATE_DATA.sql
    create or replace directory PIC_IMP_DIR as '&PIC_DIRECTORY';
    ACCEPT EPSS_DUMP_PASSWD char PROMPT 'Enter EPSS_DUMP Schema password: ' hide;
    create user epss_dump10 identified by &EPSS_DUMP_PASSWD default tablespace users temporary tablespace temp;
    grant connect,resource,JAVAUSERPRIV to epss_dump10;
    grant CREATE DATABASE LINK to epss_dump10;
    grant CREATE PUBLIC SYNONYM to epss_dump10;     
    grant CREATE SYNONYM to epss_dump10;
    grant CREATE TABLE to epss_dump10;
    grant CREATE VIEW to epss_dump10;
    grant UNLIMITED TABLESPACE to epss_dump10;
    grant read,write on directory PIC_IMP_DIR to epss_dump10;
    connect epss_dump10/&EPSS_DUMP_PASSWD
    @EPSS_DUMP_SCHEMA.sql
    spool off;
    exit;
    I don't understand why the two first work and not the last one.
    I already tried by moving the third ACCEPT at the top of the script without any success.
    I had thought, as I'm frst connecting as sysdba asking for passwords and then connect as another user meaning another session, the script would have lost the variables values. But no as now I'm rerquesting the second password after the second connection.
    Advice are welcome.
    Thanks and regards.

    Hi,
    I just made some extended tests.
    Code :
    SET ECHO OFF;
    spool epss_dump_schema.log;
    ACCEPT EPSS_DUMP_PASSWD char PROMPT 'Enter EPSS_DUMP Schema password: ' hide;
    ACCEPT EPSS_PASSWD char PROMPT 'Enter EPSS Schema password: ' hide;
    ACCEPT PIC_DIRECTORY char PROMPT 'Enter The Directory where the PIC dump files will be stored:' ;
    prompt &EPSS_DUMP_PASSWD;
    prompt &EPSS_PASSWD;
    prompt &PIC_DIRECTORY;
    The variables have the right information.
    Now create the users will work without any problem
    If I first connect with the first user (EPSS_DUMP) and then connect directly with the other one, that will work.
    Code :
    SET ECHO OFF;
    spool epss_dump_schema.log;
    ACCEPT EPSS_DUMP_PASSWD char PROMPT 'Enter EPSS_DUMP Schema password: ' hide;
    ACCEPT EPSS_PASSWD char PROMPT 'Enter EPSS Schema password: ' ;
    ACCEPT PIC_DIRECTORY char PROMPT 'Enter The Directory where the PIC dump files will be stored:' ;
    prompt &EPSS_DUMP_PASSWD;
    prompt &EPSS_PASSWD;
    prompt &PIC_DIRECTORY;
    CREATE user epss_dump10 IDENTIFIED BY &EPSS_DUMP_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE user epss10 IDENTIFIED BY &EPSS_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE OR REPLACE directory PIC_IMP_DIR AS '&PIC_DIRECTORY';
    GRANT connect,resource TO epss_dump10;
    GRANT dba TO epss10;
    GRANT connect,resource,JAVAUSERPRIV TO epss_dump10;
    GRANT CREATE DATABASE LINK TO epss_dump10;
    GRANT CREATE PUBLIC SYNONYM TO epss_dump10;     
    GRANT CREATE SYNONYM TO epss_dump10;
    GRANT CREATE TABLE TO epss_dump10;
    GRANT CREATE VIEW TO epss_dump10;
    GRANT UNLIMITED TABLESPACE TO epss_dump10;
    GRANT READ,WRITE ON directory PIC_IMP_DIR TO epss_dump10;
    connect epss_dump10/&EPSS_DUMP_PASSWD
    PROMPT 'EPSS PASSWORD: &EPSS_PASSWD';
    connect epss10/&EPSS_PASSWD;
    Now If I run additional script after I'm connected with the first user and then I connect with the second user, the connection will faill telling wrong login/password.
    Code :
    SET ECHO OFF;
    spool epss_dump_schema.log;
    ACCEPT EPSS_DUMP_PASSWD char PROMPT 'Enter EPSS_DUMP Schema password: ' hide;
    ACCEPT EPSS_PASSWD char PROMPT 'Enter EPSS Schema password: ' ;
    ACCEPT PIC_DIRECTORY char PROMPT 'Enter The Directory where the PIC dump files will be stored:' ;
    prompt &EPSS_DUMP_PASSWD;
    prompt &EPSS_PASSWD;
    prompt &PIC_DIRECTORY;
    CREATE user epss_dump10 IDENTIFIED BY &EPSS_DUMP_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE user epss10 IDENTIFIED BY &EPSS_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE OR REPLACE directory PIC_IMP_DIR AS '&PIC_DIRECTORY';
    GRANT connect,resource TO epss_dump10;
    GRANT dba TO epss10;
    GRANT connect,resource,JAVAUSERPRIV TO epss_dump10;
    GRANT CREATE DATABASE LINK TO epss_dump10;
    GRANT CREATE PUBLIC SYNONYM TO epss_dump10;     
    GRANT CREATE SYNONYM TO epss_dump10;
    GRANT CREATE TABLE TO epss_dump10;
    GRANT CREATE VIEW TO epss_dump10;
    GRANT UNLIMITED TABLESPACE TO epss_dump10;
    GRANT READ,WRITE ON directory PIC_IMP_DIR TO epss_dump10;
    connect epss_dump10/&EPSS_DUMP_PASSWD
    @EPSS_DUMP_SCHEMA.sql
    @COMPILE_INVALID_OBJECTS.sql
    PROMPT 'EPSS PASSWORD: &EPSS_PASSWD';
    connect epss10/&EPSS_PASSWD;
    My script EPSS_DUMP_SCHEMA.sql is just a script to create tables with constraints, synonyms, views, packages and so on.
    Nothing seems strange.
    Well the only strange thing is that if you call a script inside the main script, it seems that all the variables have lost their values.
    Code :
    SET ECHO OFF;
    spool epss_dump_schema.log;
    ACCEPT EPSS_DUMP_PASSWD char PROMPT 'Enter EPSS_DUMP Schema password: ' hide;
    ACCEPT EPSS_PASSWD char PROMPT 'Enter EPSS Schema password: ' ;
    ACCEPT PIC_DIRECTORY char PROMPT 'Enter The Directory where the PIC dump files will be stored:' ;
    prompt &EPSS_DUMP_PASSWD;
    prompt &EPSS_PASSWD;
    prompt &PIC_DIRECTORY;
    CREATE user epss_dump10 IDENTIFIED BY &EPSS_DUMP_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE user epss10 IDENTIFIED BY &EPSS_PASSWD DEFAULT tablespace users TEMPORARY tablespace temp;
    CREATE OR REPLACE directory PIC_IMP_DIR AS '&PIC_DIRECTORY';
    GRANT connect,resource TO epss_dump10;
    GRANT dba TO epss10;
    GRANT connect,resource,JAVAUSERPRIV TO epss_dump10;
    GRANT CREATE DATABASE LINK TO epss_dump10;
    GRANT CREATE PUBLIC SYNONYM TO epss_dump10;     
    GRANT CREATE SYNONYM TO epss_dump10;
    GRANT CREATE TABLE TO epss_dump10;
    GRANT CREATE VIEW TO epss_dump10;
    GRANT UNLIMITED TABLESPACE TO epss_dump10;
    GRANT READ,WRITE ON directory PIC_IMP_DIR TO epss_dump10;
    connect epss_dump10/&EPSS_DUMP_PASSWD
    @EPSS_DUMP_SCHEMA.sql
    PROMPT 'EPSS PASSWORD: &EPSS_PASSWD';
    PROMPT 'EPSS_DUMP PASSWORD: &EPSS_DUMP_PASSWD';
    PROMPT 'PIC DIRECTORY: &PIC_DIRECTORY';
    The three prompts return
    &EPSS_PASSWD
    &EPSS_DUMP_PASSWD
    &PIC_DIRECTORY
    Thanks for your help.

  • When a table is dropped

    when a table is dropped, are the associated indexes, constraints and views automatically dropped?

    CASCADE CONSTRAINTS allows you to drop a parent table before a child table that has a foreign key constraint that references the parent table. The constraints that you are dropping in this case are not constraints on the table you're dropping, they are constraints on other tables that refer to the table you're dropping.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • SQL Server Data Compare doesn't retrieve table list

    I'm trying to do a data compare in Visual Studio 2013.  I have chosen my source and targets and successfully tested the connection to each of them in the connections dialog. 
    When I choose next, there's a few seconds delay as though the compare tool is checking with the source and target and then it shows a dialog with what to compare.  There is a checkbox next to Tables and next to Views.  Those are the only two options
    shown. 
    What should be in this dialog, left of Tables and Views, is an arrow to expand them and show the list of tables and views in the source database.  The arrow is missing and I cannot expand any list of tables or views.  There's just nothing shown
    to compare.
    When I click Next again, the compare appears to run but when complete it reports that zero tables or views were compared - under the circumstances this is as expected because the previous dialog did not allow me to check any tables to compare.
    Why am I not getting the arrow to expand the list of tables?  What's wrong with Data Compare?
    Thanks,
    Dale

    Hi Dale,
    >>In your image you show a primary key value in comparison key but my tables did not have a primary key assigned
    >>Is the comparison key requirement by design? 
    I repro it, I get the same issue as yours, if no key, we couldn't compare the tables.
    Like the document here:
    https://msdn.microsoft.com/en-us/library/dn266029%28v=vs.103%29.aspx?f=255&MSPPError=-2147217396
    https://msdn.microsoft.com/en-us/library/aa833428(v=vs.100).aspx
    Requirements
    When you compare data in a table or view, the table or view in the source database must share several attributes with a table or view in the target database. Tables and views that do not meet the following criteria are not compared and do not appear
    on the second page of the      New Data Comparison   wizard:
    Tables must have matching column names that have compatible data types.
    Names of tables, views, and owners are case-sensitive.
    Tables must have the same primary key, unique index, or unique constraint.
    Views must have the same unique, clustered index.
    You can compare a table with a view only if they have the same name.
    Each object has a key or an index that determines the other objects to which it corresponds. However, each table or view can have more than one primary key, unique index, or unique constraint. Therefore, you might want to specify which key, index,
    or constraint to use.
    As my understanding, it would have the specific requirements.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • How do I make one corner rounded?

    Hey, Firstly, I'm using Illustrator CS6. I'd like to round a specific corner of a shape (a rectangle to be specific). I've seen in other posts that the CornerEffects.jsx script should work. But every time I select my rectangle, go to File > Scripts >

  • How to change the exchange rate filled in a posted Invoice?

    Hi All, an user has posted an invoice in foreign currency. He has forgotten filling in a particular exchange rate. I wonder if is possible to change the document filling, in the exchange rate required, so to have the right amount in local currency. T

  • Diff ws and gui upload

    difference between ws_upload and gui_upload

  • Output Requirement not Fulfilled (But output generated anyway?)

    Hello Gurus, I am facing a very strange situation. I have added a custom field to the field catalog for output determination. The setup looks all good, the communication structure is populating the field just fine and the output gets triggered as exp

  • IPod Touch gen 2 disabled

    I have the old iPod Touch (Gen 1 or 2), my friend disabled it, and it says to connect to iTunes. When I connect it to iTunes it says "This iPod cannot be started because the Apple Mobile Device service is not started" What do I do to fix it?