Why is the FK parent table read

0
SQL Server 2012 Enterprise. I have two tables with a FK relationship. The referencing column in the child table is NOT NULL. The FK is trusted. I create a view that joins the two tables with an INNER JOIN on the foreign key column and no filter. When I SELECT
COUNT(*) from the view, it returns the count of rows in the child table (as expected), but looking at actual execution plan, it reads the parent table to do so. I see no reason to read from the parent table. The trusted FK on a NOT NULL column in the
child table means that for every row in the child table there HAS to be a corresponding row in the parent table, so reading the parent table should be unnecessary. If I change the view's join to an OUTER JOIN, the parent table is not read with a SELECT COUNT(*)
from the view. Is this a shortcoming in the optimizer (not really a bug), or am I missing something? Here's an example:
USE tempdb;
GO
IF OBJECT_ID('dbo.vChild') IS NOT NULL DROP VIEW dbo.vChild;
IF OBJECT_ID('dbo.Child') IS NOT NULL DROP TABLE dbo.Child;
IF OBJECT_ID('dbo.Parent') IS NOT NULL DROP TABLE dbo.Parent;
CREATE TABLE dbo.Parent (PKey int NOT NULL PRIMARY KEY,
 SomeCol varchar(10) NOT NULL);
GO
CREATE TABLE dbo.Child (PKey int NOT NULL,
 SeqNum int NOT NULL,
 CONSTRAINT ChildPK PRIMARY KEY (PKey, SeqNum));
ALTER TABLE dbo.Child WITH CHECK ADD CONSTRAINT FK_Parent_Child FOREIGN KEY(PKey)
 REFERENCES dbo.Parent (PKey);
GO
select is_not_trusted, * from sys.foreign_keys
 WHERE [name] = 'FK_Parent_Child';
GO
CREATE VIEW dbo.vChild AS
SELECT C.PKey, C.SeqNum, P.SomeCol
 FROM dbo.Child AS C
 JOIN dbo.Parent AS P
  ON C.PKey = P.PKey
GO
SELECT COUNT(*) FROM dbo.vChild;
Thanks, Vern
Vern Rabe

I got the same plan as you and I am running SP1 and CU4. I've installed CU4 because of another bug
Confusing error message
Here is my plan as a text:
StmtText
  |--Compute Scalar(DEFINE:([Expr1004]=CONVERT_IMPLICIT(int,[Expr1007],0)))
       |--Stream Aggregate(DEFINE:([Expr1007]=Count(*)))
            |--Nested Loops(Inner Join, OUTER REFERENCES:([C].[PKey]))
                 |--Clustered Index Scan(OBJECT:([tempdb].[dbo].[Child].[ChildPK] AS [C]))
                 |--Clustered Index Seek(OBJECT:([tempdb].[dbo].[Parent].[PK__Parent__5E190D18084EC2A6] AS [P]), SEEK:([P].[PKey]=[tempdb].[dbo].[Child].[PKey] as [C].[PKey]) ORDERED FORWARD)
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • Why do I get a table read error in DB Tools Execute Query.vi

    Hello all,
    I am using LV8 and the database connectivity toolkit.  I can connect to my server database and use the "DB Tools List Tables.vi" to pull the list of tables in the database, but when I try to use an sql command into "DB Tools Execute Query.vi" I get a : Error -2147217911 occurred at Conn Execute.vi->DatabaseTest2.vi message.  In the possible reasons it says : Possible reason(s):
    Exception occured in Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'tblShopOrders'. in Conn Execute.vi->DatabaseTest2.vi
    I can open and edit this table with MSAccess.
    Any ideas as to the cause of this error?
    Jim
    Jim
    LV 2013

    Hey Andy,
    Since my first post I have discovered a bit more (not enough yet).  Firstly, I can access all of the tables using MSAccess (causing me to assume that I have the necessary permissions).  I am using the "DB Tools Execute Query.vi" with an SQL query and "DB Tools Fetch Recordset Data.vi" objects to try to get data.  I don't get an error when connecting to the database, but the error occurs at the execute query vi.  The database has a large number of tables, and I discovered that I can retrieve data from some of them using the above method.  I looked into the user and group permissions in the MS access security settings and found that the permissions were checked for all of the tables that I could open, and not for the rest.  I checked them on the ones I want to open, but this didn't help.  I went back into Access and made sure that they were still checked and they were.  And that's as far as I have gotten so far.
    Thank you for any help that you can provide.
    Jim
    Jim
    LV 2013

  • Why is the returned internal table contains same values?

    Hi all,
    I got a bapi that returned an internal table type MARC.
    For testing in R/3, the internal table returns 3 material no. with different values,
    but in vb.net, it returns 3 entries with same values,
    (I've passed the internal table as ByRef in the vb)
    what's wrong are there?
    Thanks.

    Please post your test code.

  • Why does the screen say, "Adobe Reader is blocked for this website."

    When I try to continue on to the site and trust the site, I recieve a different message stating, "Before viewing PDF documents, in this browser, you must launch Adobe Reader and accept the end user agreement, then Quit and relaunch the browser." 
    I have tried redownloading the program and accepting the agreement again, but this does not seem to be working.  I am out of ideas......

    Did you actually read the message you got?  It doesn't say anything about redownloading; it says to launch (open) the Adobe Reader application and accept the EULA.

  • Why scrolling the pages in adobe reader very slow

    hi,
    why  when i try to scoll the pages with my mouse it move the pages very slowly its like slow motion move
    i want to scoll the page smoothly without facing the issue
    thank you for help.

    so there isn't  a solution for slow mouse scolling
    and by the way its a lot faster to scroll pages when im using foxit reader

  • Last Name within the Contact Parent actually reads "Task Name" when editing it

    I created a new contact type named New Hire for a workflow I am working on. The contact type was from existing group Core Contact and Calendar Columns. I noticed "Last Name" source is "Item" when all the other contact
    fields are "Contact". Then when I open it to change it from Optional to Required, the field actually shows "Task Name" for the Column Name. This is not right. Please let me know how to fix...
    How I got there…
    - Site Settings
    - Site Content Types
    - Created a new Contact Type named New Hire
    - Last Name is Item and not part of the type “Contact” like the others
    - And when I open up Last Name and Edit it, I see “Task Name"
    How can I fix this?

    Hi,
    Content types are organized into a hierarchy that allows one content type to inherit its characteristics from another content type. All SharePoint OOTB content type  inherits System content type. For detail, you can see that Item content type inherits
    System content type, Folder content type inherits Item content type, Document content type inherits Item content type and so on.
    Reference:
    https://support.office.microsoft.com/en-in/article/Introduction-to-content-types-and-content-type-publishing-a5026d23-8df8-42f6-b0d6-1920880c0d03?CorrelationId=d954de50-76c9-4003-81bb-49f3dfc68854&ui=en-US&rs=en-IN&ad=IN#__toc256601761
    As Contact content type inherits Item content type, Contact  content type inherit the Title column of Item content type. So Last Name is tied to Title.
    For your issue, Last Name should be the Title. Also you can create a separate Title field.
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Check the Existance of  Table

    Hi,
    How to check the Existance of table, My require ment i have two tables lets say A And B, If table B does not exist then delete records in table A.
    Can any one tel me how to write a query.
    Thanks in Advance

    hi,
    whether your requirement is to check the existence of table B in the entire database or only in your schema.
    because:
    the user_tables contains the tables owned by the owner of the schema,
    and all_tables caontains the tables that can be access by you,
    and dba_tables contains all teh tables in your database.
    so based on your req query any one of the table and check as suggested earlier by others.
    and the 'tab' table also shows if there is any synonym with the table name as 'B'.
    so if you are going for 'tab' table then also specify the column "TABTYPE = 'TABLE' ".

  • Can't delete from parent table if FK constraint on the out-of-line table

    Using Oracle XML DB 11g
    I am using out-of-line storage table to store a collection of XML elements in conjuction with storeVarrayAsTable="true". So what I have is a parent table containing a nested table of VARRAY of REFs to rows in the out-of-line table.
    In addition, I have a foreign key constraint placed on a column in the out-of-line table.
    My problem is that I am not able to delete rows from the parent table when the FK constraint is placed on the out-of-line table. Only when I drop the FK constraint does the deletion work - all associated rows in the nested table and out-of-line table
    gets deleted correctly.
    With the FK constraint, deleting the child document like this
    dbms_xdb.deleteResource('/project-1.xml')
    gives me this error:
    ORA-31018: Error deleting XML document
    ORA-03001: unimplemented feature
    *Cause:  The XMLType object pointed to by the given REF could not
    be deleted because either the REF was invalid or it pointed to a non-existent table.
         *Action:  Either use FORCE deletion or supply a valid REF.
    I have tried deleting with the FORCE options as well with no success.
    Using DBMS_XDB.DELETE_RECURSIVE_FORCE option doesn't produce an error, but doesn't perform the deletion either.
    Here is the XML Schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xlink="http://www.w3.org/1999/xlink"
    elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true">
    <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>
    <xs:element name="project" xdb:defaultTable="PROJECT_TAB">
    <xs:complexType xdb:SQLType="PROJECT_TYP">
    <xs:sequence>
    <xs:element name="resourceList" minOccurs="0" xdb:SQLName="RESOURCE_LIST">
    <xs:complexType xdb:SQLType="RESOURCE_LIST_TYP">
    <xs:sequence>
    <xs:element name="aResource" type="refType" minOccurs="0" maxOccurs="unbounded" xdb:SQLInline="false"
    xdb:SQLName="A_RESOURCE_REF" xdb:defaultTable="RESOURCE_REF_TAB"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="aguid" type="xs:string" use="required" xdb:SQLName="AGUID"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="aResource" xdb:defaultTable="A_RESOURCE_TAB">
    <xs:complexType xdb:SQLType="A_RESOURCE_TYP">
    <xs:complexContent>
    <xs:extension base="contactType">
    <xs:attribute name="aguid" type="xs:string" use="required" xdb:SQLName="AGUID"/>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    </xs:element>
    <xs:complexType name="contactType" xdb:SQLType="CONTACT_TYP">
    <xs:sequence>
    <xs:element name="name" type="xs:string" xdb:SQLName="NAME"/>
    <xs:element name="email" type="xs:string" minOccurs="0" xdb:SQLName="EMAIL"/>
    <xs:element name="phone" type="xs:string" xdb:SQLName="PHONE"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="refType" xdb:SQLType="REF_TYP">
    <xs:attribute ref="xlink:href" use="required"/>
    <xs:attribute name="oref" type="xs:string" use="optional" xdb:SQLName="OREF"/>
    </xs:complexType>
    </xs:schema>
    I registered the schema using structured storage with these options:
    BEGIN
    DBMS_XMLSCHEMA.registerschema(
    SCHEMAURL => 'LSDProjects.xsd',
    SCHEMADOC => xdbURIType('/home/LSDProject2/LSDProjects.xsd').getClob(),
    LOCAL => TRUE, -- local
    GENTYPES => TRUE, -- generate object types
    GENBEAN => FALSE, -- no java beans
    GENTABLES => TRUE -- generate object tables
    END;
    The PK and FK constraints were added like this:
    -- Add PK constraints on aResource/@aguid attributes
    ALTER TABLE A_RESOURCE_TAB ADD CONSTRAINT A_RESOURCE_AGUID_IS_UNIQUE UNIQUE (XMLDATA."AGUID");
    -- Add FK constraint on out-of-line table
    ALTER TABLE RESOURCE_REF_TAB
    ADD (CONSTRAINT ref_resource_aguid_is_valid FOREIGN KEY (XMLDATA."OREF")
    REFERENCES A_RESOURCE_TAB(XMLDATA."AGUID"));
    Here are the XML instance documents:
         where resource-1.xml looks like this :
    <aResource aguid="resource-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LSDProjects.xsd">
         <name>Jane Doe</name>
         <email>[email protected]</email>
    <phone/>
    </aResource>
         and project-1.xml looks like this :
         <project aguid="project-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LSDProjects.xsd"
                   xmlns:xlink="http://www.w3.org/1999/xlink">               
              <resourceList>
                   <aResource xlink:href="/resource-1.xml" oref="resource-1"/>                         
              </resourceList>     
         </project>
    where <project> document contains a collection of <aResource> elements stored in the out-of-line table and
    project/@oref attribute is a foreign key to the primary aResource/@aguid attribute.
    Can someone shed some light on why I am unable to delete "project-1.xml" from the repository when the FK constraint is applied onto the out-of-line table.
    Any advice/suggestions would be appreciated. Thanks!

    Thank you for the quick reply, mdrake.
    I am currently prototyping and testing out (best) ways to achieve data integrity with XML data in XML DB.
    I have instance documents that makes cross references to values in other instance documents
    (not of the same root nodes). What I'm trying to enforce is a referential constraint between the documents
    so that a document cannot be inserted if the referenced document doesn't exists.
    In this situation, a <project> document contains a collection of elements with @oref attributes.
    The collection is stored in an out-of-line table.
    For example:
    <project>
    <resourceList>
    <aResource ... oref="resource-1"/>
    <aResource ... oref="resource-2"/>
    </resourceList>
    </project>
    The @oref (FK) attribute above references a @aguid (PK) attribute in <aResource> document (below):
    <aResource aguid="resource-1"> .... </aResource>
    Basically, I want to ensure that the value of
    /project/resourceList/aResource/@oref
    correspond to a valid
    /aResource/@aguid
    Note that I was able to add the FK constraint on the OOL table without any issues.
    And the constraint did work as expected as I was not allowed to insert a <project> document
    that referenced a non-existent /aResource/@aguid.
    The problem was that I could not delete the <project> document from the XML DB repository
    once the FK contraint was added. Deleting with the DELETE_RECURSIVE_FORCE option did not give
    me any errors - is just didn't do anything.
    I guess there are certain limitations with using out-of-line tables.
    BTW, sorry the examples are hard to read as the indentations are removed when posting.

  • How to Insert 3 Column details in a single table from the parent table.

    From the Parent Table i need to insert rows which are all under this column {(TradeIn_1_VIN),(TradeIn_2_VIN),(TradeIn_3_VIN) } into SALES_TRADEIN Table .
    I have used the below Query,
    But it reads only (TradeIn _1_Vin) Column in the SALES_TRADEIN table rest 2 records got skipped..
    INSERT INTO SALES_TRADEIN
    SalesID,
    TradeIn_VIN,
    TradeIn_Make,
    TradeIn_Model,
    TradeIn_ExteriorColor,
    TradeIn_Year,
    TradeIn_Mileage,
    TradeIn_Gross,
    TradeIn_Payoff,
    TradeIn_ACV,
    TradeIn_InteriorColor
    VALUES
    @SalesID,
    case when @TradeIn_1_VIN is null then @TradeIn_2_VIN else @TradeIn_1_VIN end,
    case when @TradeIn_1_Make is null then @TradeIn_2_Make else @TradeIn_1_Make end,
    case when @TradeIn_1_Model is null then @TradeIn_2_Model else @TradeIn_1_Model end,
    case when @TradeIn_1_ExteriorColor is null then @TradeIn_2_ExteriorColor else @TradeIn_1_ExteriorColor end,
    case when @TradeIn_1_Year is null then @TradeIn_2_Year else @TradeIn_1_Year end,
    case when @TradeIn_1_Mileage is null then @TradeIn_2_Mileage else @TradeIn_1_Mileage end,
    case when @TradeIn_1_Gross is null then @TradeIn_2_Gross else @TradeIn_1_Gross end,
    case when @TradeIn_1_Payoff is null then @TradeIn_2_Payoff else @TradeIn_1_Payoff end,
    case when @TradeIn_1_ACV is null then @TradeIn_2_ACV else @TradeIn_1_ACV end,
    case when @TradeIn_1_InteriorColor is null then @TradeIn_2_InteriorColor else @TradeIn_1_InteriorColor end
    END TRY
    Actually my problem is
     If  [(TradeIn_1_VIN),(TradeIn_2_VIN),(TradeIn_3_VIN)] these 3 columns have details i need all the 3 columns  details need to be read to SALES_TRADEIN table.
    Suppose if we have data only in [(TradeIn_1_VIN),(TradeIn_2_VIN)] then these column details need to loaded in the SALES_TRADEIN table.
    If any columns are blank no problem it can move next process.
    Please help me change those particular lines to insert all the 3 records  (TradeIn_1_VIN) (TradeIn_2_VIN) (TradeIn_3_VIN) in to the table.

    you've not given us the full info about the tables. The posted code also makes not much sense to me as all I can see are values getting inserted from some variables which is not required here as your values come from a table and variables can handle only
    one set of values a time which would require unnecessary iteration logic.
    I think what you need is something like below
    INSERT INTO SALES_TRADEIN
    SalesID,
    TradeIn_VIN,
    TradeIn_Make,
    TradeIn_Model,
    TradeIn_ExteriorColor,
    TradeIn_Year,
    TradeIn_Mileage,
    TradeIn_Gross,
    TradeIn_Payoff,
    TradeIn_ACV,
    TradeIn_InteriorColor
    SELECT t.TradeIn_VIN,
    t.TradeIn_Make,
    t.TradeIn_Model,
    t.TradeIn_ExteriorColor,
    t.TradeIn_Year,
    t.TradeIn_Mileage,
    t.TradeIn_Gross,
    t.TradeIn_Payoff,
    t.TradeIn_ACV,
    t.TradeIn_InteriorColor
    FROM Parent p
    CROSS APPLY (VALUES
    (TradeIn_1_VIN,
    TradeIn_1_Make,
    TradeIn_1_Model,
    TradeIn_1_ExteriorColor,
    TradeIn_1_Year,
    TradeIn_1_Mileage,
    TradeIn_1_Gross,
    TradeIn_1_Payoff,
    TradeIn_1_ACV,
    TradeIn_1_InteriorColor),
    (TradeIn_2_VIN,
    TradeIn_2_Make,
    TradeIn_2_Model,
    TradeIn_2_ExteriorColor,
    TradeIn_2_Year,
    TradeIn_2_Mileage,
    TradeIn_2_Gross,
    TradeIn_2_Payoff,
    TradeIn_2_ACV,
    TradeIn_2_InteriorColor),
    (TradeIn_3_VIN,
    TradeIn_3_Make,
    TradeIn_3_Model,
    TradeIn_3_ExteriorColor,
    TradeIn_3_Year,
    TradeIn_3_Mileage,
    TradeIn_3_Gross,
    TradeIn_3_Payoff,
    TradeIn_3_ACV,
    TradeIn_3_InteriorColor)
    )t(TradeIn_VIN,
    TradeIn_Make,
    TradeIn_Model,
    TradeIn_ExteriorColor,
    TradeIn_Year,
    TradeIn_Mileage,
    TradeIn_Gross,
    TradeIn_Payoff,
    TradeIn_ACV,
    TradeIn_InteriorColor)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

  • CMP Beans from Tables: Why does the Container try to create new tables?

    I'm trying to develop an EJB application using JDeveloper on 9iAS. I have several CMPs and have my tables that I want my CMPs to be based on already defined in my DB schema. I want to use CMP but I don't want the Container to create the tables, rather I want the Container to map my CMP EJBs to the already existing tables.
    The issue is:
    While creating these CMP EJBs in JDeveloper I chose the "New Enterprise Java Bean" EJB creation wizard using the option labeled "Container-managed Entity Beans from Tables". My assumption is that this does what I want, because the wizard prompts for a schema and table you want to map to. Then it creates the attributes & getter/setter methods, PK class, etc. all based on the table defintion automatically. Great. So why when I try to run my application do I get error messages for each EJB such as:
    Auto-creating table: create table STREET_TYPE (PK_STYP_ID NUMBER(8), STREET_TYPE VARCHAR2(20), primary key (PK_STYP_ID, STREET_TYPE))
    Warning: Error creating table: ORA-00955: name is already used by an existing object
    Huh?? I thought the idea is that the CMP EJB is mapped to the existing table in my schema. Why is the Container trying to create new tables?? Is this possible? Or am I missing something fundamental about how Containers create and manage CMPs? Or is this just a JDevelop container issue? TIA

    I presume you are getting the problem on application
    deploy? This happens when upon initialization of the application using the built-in OC4J container/app server that is part of JDeveloper. Here is the full messaging:
    [Starting OC4J using the following ports: HTTP=8989, RMI=23892, JMS=9228.]
    C:\OraHome1\jdk\bin\javaw.exe -ojvm -classpath C:\OraHome1\j2ee\home\oc4j.jar com.evermind.server.OC4JServer -config C:\OraHome1\jdev\system\oc4j-config\server.xml
    [waiting for the server to complete its initialization...]
    Copying default deployment descriptor from archive at Q:\CBTCOF\COF_APPLICATION\COF_Project\classes/META-INF/orion-ejb-jar.xml to deployment directory C:\OraHome1\jdev\system\oc4j-config\application-deployments\current-workspace-app\classes...
    Auto-deploying file:/Q:/CBTCOF/COF_APPLICATION/COF_Project/classes/ (No previous deployment found)...
    Auto-creating table: create table STREET_TYPE (PK_STYP_ID NUMBER(8), STREET_TYPE VARCHAR2(20), primary key (PK_STYP_ID, STREET_TYPE))
    Warning: Error creating table: ORA-00955: name is already used by an existing object
    [...OTHER SIMILAR ERROR MESSAGES]
    done.
    Oracle9iAS (9.0.2.0.0) Containers for J2EE initialized
    If so, in the application.xml file of you
    OC4J instance the is a setting autocreate-tables,
    which by default is true!
    Set it to false as below and that should clear up
    your problem.
    <orion-application autocreate-tables="false"
    default-data-Hmm. I found at least a dozen or so files with that name and set everyone that had this attriute to "false", restarted the OC4J server and still got these errors.

  • Query the name of the parent table in a foreign key constraint

    Hello,
    Does anyone know how to query for the parent table name in a foreign key constraint? I don't see that relationship in ALL_CONS_COLUMNS or ALL_CONSTRAINTS.
    Thanks in advance,
    Michael

    or try this...
    SELECT rc.TABLE_NAME "PK_Table_Name",cc.TABLE_NAME "FK_Table_Name",
           case when cc.column_name = rc.column_name
                then c.TABLE_NAME || '(' || cc.COLUMN_NAME || ')'
                else r.TABLE_NAME || '(' || rc.COLUMN_NAME || ') = ' ||c.TABLE_NAME || '(' || cc.COLUMN_NAME || ')' end as "TABLE_NAME(COLUMN_NAME)"
    from all_constraints c,
         all_constraints r,
         all_cons_columns cc,
         all_cons_columns rc
    WHERE
         r.table_name = upper('emp')
    and      c.CONSTRAINT_TYPE = 'R'
    and     c.R_OWNER = r.OWNER
    and     c.R_CONSTRAINT_NAME = r.CONSTRAINT_NAME
    and     c.CONSTRAINT_NAME = cc.CONSTRAINT_NAME
    and     c.OWNER = cc.OWNER
    and     r.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
    and     r.OWNER = rc.OWNER
    and     cc.POSITION = rc.POSITION
    ORDER BY r.TABLE_NAME;

  • In the parent table has a ROWID of an index of the child table FK!

    From the structure of the heap table is a problem.
    PK has a parent table.
    Child table has a FK.
    If you have FK to the parent table has a ROWID, I think in terms of speed to get the best performance.
    what do you think?
    Edited by: user5647868 on 2011. 9. 29 오후 10:46

    Of course, if the parent table FK ribildeuhal should rebuild the index.
    In reality, however, if the parent table, there were no ribildeuhaneun.
    If you need to rebuild a lot if you have a DOWNTIME.
    In some cases, even given the option to ALTER TABLE will be.
    Is the child table FK halgeot rebuild?
    FK using ROWID in the index of the parent decide to disable?
    And so on.

  • Why is the Rows Fixed in a Table in Smartforms?

    Hi,
    I am new to smartforms. This one particular Smartform has a Table defined in the Main Window. In the “Data Tab” of the Table under the “Loop” heading an internal table is used to pass information to the Table. There is no Loop defined. Only the Table is defined in the Main Window. The funny part is when the SamrtForm is run 15 rows get displayed. The program that populates the SmartForm always sends 15 rows to the SmartForm. I tried to send the actual number of rows, then nothing gets displayed in the SmartForm. It seems that some where in the SmartForm the 15 rows is doing some spooky things. How to solve this?
    Thanks,
    Kishan

    Kishan,
    The TABLE node in SmartForms automatically loops through the table specified inthe "Data" tab. The data passed through the TABLES paramater are defined with reference to Table Types. They have no header line. So in the "Data" tab, you must also define a work area for the TABLE node to loop into.
    That is why in the "Data" tab, you see in the Loop section, a INTO (or ASSIGNING) operand. You need to pass the record into a work area. When you are displaying the data, just like in a normal ABAP program, you use the work area.
    Not sure what you mean by "I tried to send the actual number of rows, then nothing gets displayed in the SmartForm".
    Hope this helps.
    Cheers,
    Pat.

  • HT1237 Why doesn't the "Available Firmware" table show the iMac8.1?

    The "Available Firmware" table at http://support.apple.com/kb/HT1237 does not list the iMac 8.1 (mid 2008). Anyone know why?

    A number of Macs have none. No firmware update is necessary.

Maybe you are looking for

  • How to use Macbook Pro 17" as a second monitor for iMac?

    I have a new iMac with Lightning connector and USB. And I have a Macbook Pro 17" with Firewire and USB. Is there a way to connect the Macbook Pro to the iMac and make it into a second monitor for my iMac? Thanks!

  • How do I print through an ASUS RT-N66U Router?

    Since we changed routers to the ASUS RT-N66U router I have been unable to print to any of my net work printers.  What do I need to do?  Is this router not compatible with my system?  I run through a PC XP Professional server.

  • I don't have a HD TV...

    Hey guys -- I know this has probably been asked before but I couldn't find it in the archives. I haven't yet purchased an HDTV so I'm wondering what's involved in connecting an AppleTV to my "regular" TV. Currently, our DVD player, DVR, etc. is conne

  • Oracle iLearning - playing content is very slow

    Hello, We have problem with iLearning speed. When the content is played in the application server, it shows the content really quickly, but when it is played on the local PC, the speed decreases dramatically. We have checked the servers, the network,

  • BAPI for updating Evaluation Group1 field in Asset Master

    Hi, The business requirement is to Update the Assets master fields with the current location of the Tools with respect to movement of the material only to be used for assets. To keep a track for tools being moved to vendor location or internal compan