Setting not null EJB relationships

I have a table with a one to one relation to another table through a foreign key. The foreign key is a not null column. OC4J won't let me set the relationship in ejbCreate, but because the field is not null I can't set it in ejbPostCreate. Do I have any options besides making the column accept null values?

You have two options.
Option: 1
Declare the not null constraint as deferrable; the constraint are checked only when the data is committed
Option 2:
In the Entity Bean, you have to add an addition cmp-field ( customerid) for the FK in addition to the existing CMR ( altered ejb-jar.xml & orion-ejb-jar).
You have to set the customerid in the ejbCreate segment & set up the relationship in the ejbPostCreate section.
regards
Debu

Similar Messages

  • Avoid NOT NULL error on CMR

    When I try to create an EJB with an CMR field passed on the ejbCreate I have two options:
    1. set the CRM in ejbCreate (setXXX method): not posible, illegal state (ok by EJB 2.0 specifications)
    2. set the CMR in ejbPostCreate (setXXX method): not posible - after ejbCreate the container tries to make the insert and gets the "unable to insert null into XXX" because the id of the CMR must be set NOT NULL in the database.
    On bea there is something like delay-insert-until ejbCreate or ejbPostCreate.
    What are my options on oc4j 9.0.3?

    I will state the obvious, but nevertheless, have you restarted the j2ee engine?

  • How can I set my WebI filters to Null and not Null

    Folks,
    I have created a report in WebI and now I am to set up some filters as Null and some Not Null.
    How can I set my WebI filters to Null and not Null?
    Regards,
    Bashir Awan

    Hi,
    As you said you could do it at the report level and also at the universe level.
    One more way is to create the filters in the universe levele and add them in thequery filter.
    Ex: in the filter you need to write :
    Column1 is null and and column 2 is not null etc.
    Hope this will help.
    If this did't  solve your problem then please explain it in detail.
    Cheers,
    Ravichandra K

  • Set-IRMConfiguration failed with error "Cou ld not establish trust relationship for the SSL/TLS secure channel."

    Hi, experts 
    I'm trying to configure a lab environment according tutorial http://www.msexchange.org/articles-tutorials/exchange-server-2010/compliance-policies-archiving/rights-management-server-exchange-2010-part3.html
    After completing configuration, I execute cmdlet Set-IRMConfiguration -InternalLicensingEnabled $true, but get error
    The remote certificate is invalid according to the validation procedure. ---> The underlying connection was closed: Cou
    ld not establish trust relationship for the SSL/TLS secure channel. ---> Failed to get Server Info from https://exhv-65
    94/_wmcs/certification/server.asmx.
        + CategoryInfo          : InvalidOperation: (:) [Set-IRMConfiguration], Exception
        + FullyQualifiedErrorId : C810E449,Microsoft.Exchange.Management.RightsManagement.SetIRMConfiguration
    Then I run cmdlet Test-IRMConfiguration -Sender [email protected] and get error
    Results : Checking Exchange Server ...
                  - PASS: Exchange Server is running in Enterprise.
              Loading IRM configuration ...
                  - PASS: IRM configuration loaded successfully.
              Retrieving RMS Certification Uri ...
                  - PASS: RMS Certification Uri: https://server1/_wmcs/certification.
              Verifying RMS version for https://server1/_wmcs/certification ...
                  - WARNING: Failed to verify RMS version. IRM features require AD RMS on Windows Server 2008 SP2 with the
              hotfixes specified in Knowledge Base article 973247 (http://go.microsoft.com/fwlink/?linkid=3052&kbid=973247)
               or AD RMS on Windows Server 2008 R2.
              Microsoft.Exchange.Security.RightsManagement.RightsManagementException: Failed to get Server Info from https:
              //server1/_wmcs/certification/server.asmx. ---> System.Net.WebException: The underlying connection was clos
              ed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authenticatio
              n.AuthenticationException: The remote certificate is invalid according to the validation procedure.
                 at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest async
              Request, Exception exception)
                 at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest async
              Request)
                 at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
                 at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest async
              Request)
                 at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
                 at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest async
              Request)
                 at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
                 at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequ
              est asyncRequest)
                 at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
                 at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Obje
              ct state)
                 at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
                 at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
                 at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
                 at System.Net.ConnectStream.WriteHeaders(Boolean async)
                 --- End of inner exception stack trace ---
                 at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
                 at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
                 at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
                 at Microsoft.Exchange.Security.RightsManagement.SOAP.Server.ServerWS.GetServerInfo(ServerInfoRequest[] req
              uests)
                 at Microsoft.Exchange.Security.RightsManagement.ServerWSManager.ValidateServiceVersion(String featureXPath
                 --- End of inner exception stack trace ---
                 at Microsoft.Exchange.Security.RightsManagement.ServerWSManager.ValidateServiceVersion(String featureXPath
                 at Microsoft.Exchange.Management.RightsManagement.IRMConfigurationValidator.ValidateRmsVersion(Uri uri, Se
              rviceType serviceType)
                 at Microsoft.Exchange.Management.RightsManagement.IRMConfigurationValidator.TryGetRacAndClc()
              OVERALL RESULT: PASS with warnings on disabled features
    From the error message, this issue seem to related with SSL/TLS connection. So I go back to check configuration and find out a difference to tutorial. Current SCP url is https://server1/_wmcs/certification, but in tutorial it is https://server1:433/_wmcs/certification.
    On my opinion, I don't think it is the real reason.
    So, how can I resolve this error? Could you give me some suggestion? Thanks in advance.
    System Info:
    Windows Server 2008 R2 + Exchange Server 2010 SP3 RTM

    Hi
    Please have a try with the solution on this KB article
    “Error message when you try to test access from the Microsoft Dynamics CRM E-mail Router: "Incoming Status: Failure - The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel"”
    http://support.microsoft.com/kb/954584/en-us
    Cheers
    Zi Feng
    TechNet Community Support

  • How to set ResultSet not null?

    Hello !
    How can I set my ResultSet null? rs.next( ) is null.
    Thanks in advance.

    "...Hey, do you guys have an idea how to apply operator to method getTime() e.g rs.getTime("TimeOut") - rs.getTime("TimeIn")?..."
    It can't be done.
    One thing you should be checking is whether or not the last value returned from the result set was null, using the wasNull() method.
    If you're getting a NPE, it could be that one of the values you think you're getting back from the database is really null.
    Are you sure you want java.sql.Time? Not java.sql.Timestamp?
    Code it like this:
    java.sql.Timestamp timeIn = rs.getTimestamp("TimeIn");
    java.sql.Timestamp.timeOut = rs.getTimestamp("TimeOut");
    long duration = 0L;
    if ((timeIn != null) && (timeOut != null))
        long millisecondsIn = timeIn.getTime();
        long millisecondsOut = timeOut.getTime();
        duration = millisecondsOut - millisecondsIn;
        assert (duration >= 0L);
    }MOD

  • EJB Relationship FUBAR

    In evaluating the latest release of JDeveloper (9.0.3), I have noticed that the CMP EJB wizard does not produce compilable code when generating default relationships. It appears that the set methods for the PrimaryKey and ID values are not generated properly. I guess I have to create those methods manually.
    Is this the way JDev is supposed to work ?
    I have not found any information in the JDeveloper docs that cover this issue. Any help would be appreciated.
    TIA.
    Steve Guilford...>>>

    Steve-
    Can you describe what is wrong with the CMR setters? Are you working with basic (single column) or compound (multi-column) primary/foreign keys?
    There may be some issues lurking when using multi-column PK's, particularly if the PK includes a foreign key (if represented by a CMR field), but in some cases these are caused by an invalid CMR condition (such as a non-deferred NOT NULL constraint on a FK column -- the EJB spec implicitly prevents this condition).
    If you can send me your schema or codegen details, I'll be happy to take a look.
    Jon

  • Default Value , Not Null and EJB2.1

    Hi ,
    Am using Weblogic10.3 + Oracle Db + EJB2.1 Local Entity Beans .
    The issue is that one of the table has createdDt which is not null and is defualt is set to Sysdate. When I try to create this Entity with createdDt null , I get an exception like below , But since I have mentioned default value , I shouldnt be getting this. Have I missed something ?
    Code is quite straighforward
    Organisation org = organisationHome.create();
    ....org.setter methods..
    java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-01400: cannot insert NULL into ("XXX"."ORGANISATION_T"."CREATEDDT_F")
    ErrorCode=1400 SQLState=23000
    java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-01400: cannot insert NULL into ("XXX"."ORGANISATION_T"."CREATEDDT_F")
         at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
         at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
         at weblogic.jdbc.oracle.OracleImplStatement.execute(Unknown Source)
         at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
         at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
         at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
         at weblogic.jdbcspy.SpyPreparedStatement.executeUpdate(Unknown Source)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:159)
         at weblogic.ejb.container.manager.BaseEntityManager.executeInsertStmt(BaseEntityManager.java:763)
         at weblogic.ejb.container.internal.TxManager$TxListener.executeInsert(TxManager.java:900)
         at weblogic.ejb.container.internal.TxManager$TxListener.executeDBOperations(TxManager.java:831)
         at weblogic.ejb.container.internal.TxManager$TxListener.beforeCompletion(TxManager.java:1054)
         at weblogic.transaction.internal.ServerSCInfo.doBeforeCompletion(ServerSCInfo.java:1217)
         at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:1195)
         at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:118)
         at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1302)
         at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:2114)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:263)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:230)
         at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:621)
         at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:60)
         at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(BaseRemoteObject.java:441)
         at com.tieto.tix.core.domain.DomainServices_7p8lqs_EOImpl.createOrganisation(DomainServices_7p8lqs_EOImpl.java:7717)
         at com.tieto.tix.core.domain.DomainServices_7p8lqs_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    parmTest( , "param2") is syntactically incorrect, so there can be no "workaround".
    In addition to solutions offered by SwapnilVJ and Saransoft84, you could also use a rest parameter:
    function parmTest(... args)
    // set up default values
    var val1:Boolean=true;
    var val2:String="";
    switch(args.length)
      case 0:break;
      case 1:
       if(args[0] is String){val2=args[0] as String;}
       else{val1=args[0] as Boolean;}
       break;
      case 2:
      default:
       val1=args[0] as Boolean;
       val2=args[1] as String;
       break;
       trace(val1 + " " +val2);
    parmTest();
    parmTest("hello");
    parmTest(null,"hello");
    parmTest("hello",null);

  • When primary table is also join table and you have NOT NULL constraints

    Hi,
    Me again. This is similar to the message titled "Problem with an
    optional 1 to 1 relationship modelled using a link table". Whats
    different about this case is we are dealing with a one to many relationship.
    Given this SQL:
    create table person (
    pid INTEGER(10) NOT NULL,
    language_code VARCHAR(3) NOT NULL
    create table language_person (
    pid INTEGER(10) NOT NULL REFERENCES person(pid),
    language_code VARCHAR(3) NOT NULL,
    first_name VARCHAR(20) NOT NULL
    I wrote these classes (abbreviated)
    Person:
    * @jdo:persist
    * @jdo:identity-type application
    * @jdo:objectid-class PersonId
    * @jdo:requires-extent false
    * @jdo:extension vendor-name="kodo" key="table"
    * value="PERSON"
    * @jdo:extension vendor-name="kodo" key="lock-column"
    * value="none"
    * @jdo:extension vendor-name="kodo" key="class-column"
    * value="none"
    public class Person {
    * @jdo:primary-key true
    * @jdo:extension vendor-name="kodo" key="data-column"
    * value="PID"
    private int pid;
    * @jdo:extension vendor-name="kodo" key="data-column"
    * value="LANGUAGE_CODE"
    private String languageCode;
    * @jdo:collection element-type="LanguagePerson"
    * @jdo:extension vendor-name="kodo" key="pid-data-column"
    * value="PID"
    * @jdo:extension vendor-name="kodo" key="table"
    * value="LANGUAGE_PERSON"
    * @jdo:extension vendor-name="kodo" key="pid-ref-column"
    * value="PID"
    * @jdo:extension vendor-name="kodo"
    key="languageCode-data-column"
    * value="LANGUAGE_CODE"
    * @jdo:extension vendor-name="kodo"
    key="languageCode-ref-column"
    * value="LANGUAGE_CODE"
    private Set languagePersons = new HashSet();
    public Person(int pid, String languageCode) {
    this.pid = pid;
    this.languageCode = languageCode;
    public void addLanguagePerson(LanguagePerson languagePerson) {
    languagePersons.add(languagePerson);
    public Set getLanguagePersons() {
    return languagePersons;
    LANGUAGE_PERSON
    * @jdo:persist
    * @jdo:identity-type application
    * @jdo:objectid-class LanguagePersonId
    * @jdo:requires-extent false
    * @jdo:extension vendor-name="kodo" key="table"
    * value="LANGUAGE_PERSON"
    * @jdo:extension vendor-name="kodo" key="lock-column"
    * value="none"
    * @jdo:extension vendor-name="kodo" key="class-column"
    * value="none"
    public class LanguagePerson {
    * @jdo:primary-key true
    * @jdo:extension vendor-name="kodo" key="data-column"
    * value="PID"
    private int pid;
    * @jdo:primary-key true
    * @jdo:extension vendor-name="kodo" key="data-column"
    * value="LANGUAGE_CODE"
    private String languageCode;
    * @jdo:extension vendor-name="kodo" key="data-column"
    * value="FIRST_NAME"
    private String firstName;
    public LanguagePerson(int pid, String languageCode, String firstName) {
    this.pid = pid;
    this.languageCode = languageCode;
    this.firstName = firstName;
    And then I do this:
         PersistenceManager pm = JDOFactory.getPersistenceManager();
    pm.currentTransaction().begin();
    final Person person = new Person(1,"EN");
    final LanguagePerson languagePerson = new
              LanguagePerson(1,"EN","Mike");
    person.addLanguagePerson(languagePerson);
    pm.makePersistent(person);
    pm.currentTransaction().commit();
    The SQL that issues forth is this:
    1125 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    preparing statement <17089909>: INSERT INTO PERSON(LANGUAGE_CODE, PID)
    VALUES (?, ?)
    1125 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    executing statement <17089909>: [reused=1;params={(String)EN,(int)1}]
    1125 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    preparing statement <9818046>: INSERT INTO
    LANGUAGE_PERSON(LANGUAGE_CODE, PID) VALUES (?, ?)
    1125 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    executing statement <9818046>: [reused=1;params={(String)EN,(int)1}]
    1140 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    preparing statement <24763620>: INSERT INTO LANGUAGE_PERSON(FIRST_NAME,
    LANGUAGE_CODE, PID) VALUES (?, ?, ?)
    1140 [main] INFO jdbc.SQL - [ C:6588476; T:6166426; D:2891371 ]
    executing statement <24763620>:
    [reused=1;params={(String)Mike,(String)EN,(int)1}]
    And the second INSERT fails on Oracle because FIRST_NAME is null, and
    the table definition requires it to be NOT NULL.
    Is there anyway I can get Kodo to figure out its dealing with the same
    table for inserting the link columns and the full row, and optimize
    accordingly i.e do one INSERT for LANGUAGE_PERSON?
    I guess my only other options are a) introduce an explicit link table or
    b) define a custom mapping?
    Thanks,
    Mike.

    There are examples of 1-Many mappings in the documentation:
    http://www.solarmetric.com/Software/Documentation/latest/docs/
    ref_guide_meta_examples.html
    The important point I think you've missed is that right now, 1-many
    mappings always require an inverse 1-1 mapping. Again, see the docs
    above.
    So your LanguagePerson needs a field of type Person, and whenever you add
    a LanguagePerson to a Person, make sure to set that LanguagePerson's
    Person too. LanguagePerson.person will use the same PID column as
    LanguagePeson.pid. Kodo has no problem with having 2 mappings
    mapped to the same column.
    Kodo 3.0 will allow 1-Many relations without an inverse 1-1.

  • Passing not null parameter

    I'm working on a report and one of the fields that I use to pass a parameter shows with no data but it has a length of 1. I can run a query that shows the data that I need if I enter in the criteria 'IS NOT NULL'. Is there a way to pass this value or set the parameter initial value to not null?

    OK, if i understand correctly now, the root of the problem is that there is no Team information, but functional group information exists. If this is true, then my first thought is that the root problem lies in data entry, but that is another story.
    I think what you want to do is force the team information to come across, even if it has been left out (if functional group information exists). To accomplish this, try adding an outer join to your WHERE clause this way:
    WHERE
    team(+) = :TEAM
    Also, add a NVL around TEAM in the select statement like this:
    closeddate,
    NVL(team, 'Unknown Team'),
    functionalgroup
    Depending on the data relationships, you may have to play with the outer joins some to make sure you are returning the correct data set. In fact, now that I think about this, the table you are querying off of is a custom table/view isn't it? The problem then may truly lie in the script used to create the table. There are still some possibilities as to why you are experiencing this problem. If the table/view is a custom table/view, please post the script used to create it. If you have TOAD, open up a schema browser and select the table on the left. This will open up the table on the right hand side. There is a tab across the top labeled 'Scripts'. Copy and paste what is under this tab so I can advise further. If you don't have TOAD, you're going to need another way to find out what tables the data is being pulled from.
    Again, my guess is that the field is NULL and Reports is just using a place holder to tell the developer that the field does indeed exist.
    Anyway, I hope I've helped shed some light on the problem and that you get some ideas over the weekend!
    Good luck,
    Steve

  • Is not null and null join

    Hi, I am trying to properly display a list of tasks for a project however without a join to the project number (which I was aware of) and the employee table, I get over 500 results.
    The task can be created without a employee assigned to it so therefore the page does not require the field to be filled in.
    Here is the SQL code, any does anyone have any ideas?
    select
        pd.pk_proj_detail_id    "Task Number",
        pd.task_title           "Task Title",
        pd.DETAIL_STATUS        "Task Status",
        pm.name                 "Associated Project",
        pps.last_name||', '||pps.first_name||', '||pps.middle_initial||'.' "Assigned Employee",
        pd.TRACKIT_NUMBER       "TrackIt! Number",
        pd.CREATEBY_DATE        "Date Entered",
        pd.DATE_BEGIN           "Date Began",
        pd.ESTIMATED_DATE       "Estimated Completion Date",
        pd.DATE_END             "Date Completed"
    from
        PROTRAC_DETAIL pd,
        protrac_master pm,
        cobr.vw_pps_payroll pps,
        resources r
    where
        pd.fk_proj_master_id = pm.PK_PROJ_MASTER_ID
        and r.fk_master_id = pm.PK_PROJ_MASTER_ID
        and (r.emp_id = pps.emple_no
            or r.emp_id is null)

    It's 10g r2 with Application Express 3.1.0.00.32
    This is the tasks (detail) table
    ALTER TABLE PROTRAC_DETAIL
    DROP PRIMARY KEY CASCADE;
    DROP TABLE PROTRAC_DETAIL CASCADE CONSTRAINTS;
    CREATE TABLE PROTRAC_DETAIL
      PK_PROJ_DETAIL_ID      NUMBER                 NOT NULL,
      FK_PROJ_MASTER_ID      NUMBER,
      TRACKIT_NUMBER         NUMBER,
      DETAIL_DESCRIPTION     VARCHAR2(4000 CHAR),
      DETAIL_STATUS          VARCHAR2(19 CHAR),
      DETAIL_STATUS_COMMENT  VARCHAR2(4000 CHAR),
      DATE_BEGIN             DATE,
      DATE_END               DATE,
      ESTIMATED_DATE         DATE,
      CREATEBY_DATE          DATE,
      CREATEBY_USER          VARCHAR2(50 CHAR),
      LASTMOD_DATE           DATE,
      LASTMOD_USER           VARCHAR2(50 CHAR),
      TASK_TITLE             VARCHAR2(100 CHAR)
    TABLESPACE DEVPROTRAC_DATA
    PCTUSED    0
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    CREATE UNIQUE INDEX PROTRAC_DETAIL_PK ON PROTRAC_DETAIL
    (PK_PROJ_DETAIL_ID)
    TABLESPACE DEVPROTRAC_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    CREATE OR REPLACE TRIGGER BUI_PROTRAC_DETAIL
    before insert or update
    on PROTRAC_DETAIL
    referencing new as New old as Old
    for each row
    begin
        if inserting then
            select users_seq.nextval, sysdate, apex_application.g_user
                into :new.pk_proj_detail_id, :new.createby_date, :new.createby_user
                from dual;
        elsif updating then
            select sysdate, apex_application.g_user
                into :new.lastmod_date, :new.lastmod_user
                from dual;
        end if;
    end;
    SHOW ERRORS;
    ALTER TABLE PROTRAC_DETAIL ADD (
      CONSTRAINT PROTRAC_DETAIL_PK
    PRIMARY KEY
    (PK_PROJ_DETAIL_ID)
        USING INDEX
        TABLESPACE DEVPROTRAC_DATA
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       2147483645
                    PCTINCREASE      0
    ALTER TABLE PROTRAC_DETAIL ADD (
      CONSTRAINT PROTRAC_DETAIL_NUM
    FOREIGN KEY (FK_PROJ_MASTER_ID)
    REFERENCES PROTRAC_MASTER (PK_PROJ_MASTER_ID));
    ALTER TABLE DEVPROTRAC.RESOURCES ADD (
      FOREIGN KEY (FK_DETAIL_ID)
    REFERENCES DEVPROTRAC.PROTRAC_DETAIL (PK_PROJ_DETAIL_ID));
    SET DEFINE OFF;
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (34, 24, NULL, 'test', 'Queued',
        NULL, NULL, NULL, NULL, TO_DATE('10/30/2008 13:37:01', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', TO_DATE('11/03/2008 15:19:35', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'bananana');
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (41, 40, NULL, '2354234', 'Queued',
        NULL, NULL, NULL, NULL, TO_DATE('10/31/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', TO_DATE('11/03/2008 13:52:02', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', 'I can type on the keyboarddf');
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (49, 32, 78888, 'one day fishsticks will walk on the moon.', 'Queued',
        'waiting for fishsticks.', NULL, NULL, NULL, TO_DATE('11/03/2008 11:28:11', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', NULL, NULL, 'Fix the keyboard');
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (50, 38, NULL, 'dfdfdfdfdfdfdfdfdf', 'Queued',
        NULL, NULL, NULL, NULL, TO_DATE('11/03/2008 12:03:06', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', TO_DATE('11/03/2008 15:19:44', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'resreeeeeeeeee');
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (33, 31, NULL, 'Make sure the bananas are fresh', 'Queued',
        NULL, NULL, NULL, NULL, TO_DATE('10/29/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', TO_DATE('11/03/2008 15:19:52', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'e543563465');
    Insert into PROTRAC_DETAIL
       (PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
        DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
        CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
    Values
       (48, 37, NULL, 'guitar heros! yay', 'Queued',
        NULL, NULL, NULL, NULL, TO_DATE('11/03/2008 11:26:06', 'MM/DD/YYYY HH24:MI:SS'),
        'LREDMOND', TO_DATE('11/03/2008 15:19:57', 'MM/DD/YYYY HH24:MI:SS'), NULL, '34444444444444543etfg');
    COMMIT;This is for the resources table:
    ALTER TABLE RESOURCES
    DROP PRIMARY KEY CASCADE;
    DROP TABLE RESOURCES CASCADE CONSTRAINTS;
    CREATE TABLE RESOURCES
      PK_RESOURCES_ID   NUMBER,
      FK_DETAIL_ID      NUMBER,
      EMP_ID            NUMBER,
      RESOURCE_STATUS   VARCHAR2(8 CHAR),
      RESOURCE_COMMENT  VARCHAR2(4000 CHAR),
      CREATEBY_DATE     DATE,
      CREATEBY_USER     VARCHAR2(50 CHAR),
      LASTMOD_DATE      DATE,
      LASTMOD_USER      VARCHAR2(50 CHAR),
      FK_MASTER_ID      NUMBER
    TABLESPACE DEVPROTRAC_DATA
    PCTUSED    0
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    CREATE UNIQUE INDEX RESOURCES_PK ON RESOURCES
    (PK_RESOURCES_ID)
    TABLESPACE DEVPROTRAC_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    CREATE OR REPLACE TRIGGER BUI_RESOURCES
    before insert or update
    on RESOURCES
    referencing new as New old as Old
    for each row
    begin
        if inserting then
            select users_seq.nextval, sysdate, apex_application.g_user
                into :new.pk_resources_id, :new.createby_date, :new.createby_user
                from dual;
        elsif updating then
            select sysdate, apex_application.g_user
                into :new.lastmod_date, :new.lastmod_user
                from dual;
        end if;
    end;
    SHOW ERRORS;
    ALTER TABLE RESOURCES ADD (
      CONSTRAINT RESOURCES_PK
    PRIMARY KEY
    (PK_RESOURCES_ID)
        USING INDEX
        TABLESPACE DEVPROTRAC_DATA
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       2147483645
                    PCTINCREASE      0
    ALTER TABLE RESOURCES ADD (
      FOREIGN KEY (FK_DETAIL_ID)
    REFERENCES PROTRAC_DETAIL (PK_PROJ_DETAIL_ID),
      FOREIGN KEY (FK_MASTER_ID)
    REFERENCES PROTRAC_MASTER (PK_PROJ_MASTER_ID));
    SET DEFINE OFF;
    Insert into RESOURCES
       (PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
        CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
    Values
       (53, 50, 356654, 'Active', NULL,
        TO_DATE('11/04/2008 09:32:06', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', NULL, NULL, NULL);
    Insert into RESOURCES
       (PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
        CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
    Values
       (51, 41, 447250, 'Active', 'No Sure.',
        TO_DATE('11/03/2008 14:23:11', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('11/04/2008 09:00:04', 'MM/DD/YYYY HH24:MI:SS'), NULL, 40);
    Insert into RESOURCES
       (PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
        CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
    Values
       (54, 50, 323829, 'Active', NULL,
        TO_DATE('11/04/2008 10:26:08', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', NULL, NULL, 38);
    Insert into RESOURCES
       (PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
        CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
    Values
       (52, 33, 8915, 'Active', 'get to work',
        TO_DATE('11/03/2008 15:20:18', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', TO_DATE('11/03/2008 15:35:10', 'MM/DD/YYYY HH24:MI:SS'), NULL, NULL);
    COMMIT;The results I want is everything above regardless of emp_id assigned (if any). Without the r.emp_id = pps.emple_no join, the query will generate 234234239482304234 results.
    Hope this helps.
    Edited by: leland on Nov 4, 2008 12:56 PM

  • BOOLEAN DEFAULT FALSE NOT NULL for key-column

    Hello,
    These statements show an unexpected behavior when a column is added to a table as 'BOOLEAN DEFAULT FALSE NOT NULL' and added afterward to the table's primary key column set:
    create table test_1 (a char(1))
    insert into test_1 values('A')
    alter table test_1 add b boolean default false not null
    alter table test_1 add primary key (a,b)
    create table test_2 (a char(1), b boolean default false not null)
    insert into test_2 (a) values('A')
    alter table test_2 add foreign key f_test_1 (a,b) references test_1 (a,b)
          -> [350]: Referential integrity violated
    update test_1 set b=false
    alter table test_2 add foreign key f_test_1 (a,b) references test_1 (a,b)
          -> success
    delete from test_2
    delete from test_1
    insert into test_1 (a,b) values('A',false)
    insert into test_2 (a) values('A')
          -> success
    I think the error message '[350] Referential integrity violated' should not happen because the column 'b' really contains 'false'. But there obviously seem to be a difference before and after setting the column 'b' explicitly to 'false'. I can imagine that this depends on the way how the index for the primary key is updated. Probably the index is not properly updated in this context(?)
    Gabriel

    Hi Gabriel,
    you're right, this is a bug and indeed seems to caused by the way the DEFAULT boolean is stored in the page.
    (There is no separate index for the primary key in MaxDB as all data is stored in B*trees - basically the table is the primary key).
    This is how the record looks like when column b is 'false' only due to the change of the DEFAULT value:
    ROOT/LEAF 460  perm       entries : 1         [block 0]
         bottom  : 93         filevers: 14888     convvers: 83
                                                  writecnt: 1
      1: (pos 00081)
    00001      recLen      : 12                recKeyLen   : 4
    00005      recVarcolOff: 0                 recVarcolCnt: 0
         record
          1  2  3  4  5  6  7  8  9 10 11 12
         81 82 83 84 85 86 87 88 89 90 91 92
    dec: 12  0  4  0  0  0  0  0 32 65  0  0
    hex: 0C 00 04 00 00 00 00 00 20 41 00 00
    chr:                             A
    And this is how it looks like after the explicit UPDATE:
    ROOT/LEAF 460  perm       entries : 1         [block 0]
         bottom  : 93         filevers: 14888     convvers: 84
                                                  writecnt: 2
      1: (pos 00081)
    00001      recLen      : 11                recKeyLen   : 3
    00005      recVarcolOff: 0                 recVarcolCnt: 0
         record
          1  2  3  4  5  6  7  8  9 10 11
         81 82 83 84 85 86 87 88 89 90 91
    dec: 11  0  3  0  0  0  0  0 32 65  0
    hex: 0B 00 03 00 00 00 00 00 20 41 00
    chr:                             A
    Little difference but this leads to the problems during the foreign key validation.
    I'll inform the developers next week about this.
    As a workaround you'll have to explicitly update the columns for which you change the default setting.
    regards,
    Lars

  • ORA-01400 - not null column with default value and item with authorization

    I've searched - I would think someone has run into this. APEX 3.0.0.00.20 - I've created a simple form on a table. One of the column is a not null column with a default value. I have a select list on that item, but it has security on it - authorization scheme. So, it checks the user and if that user isn't of the right role, it will not even display that item. However, APEX appears to still send in the column in its sql! So, the default value is useless, it sends in null each time. Even if I set the default at the Item level, I get null. Argg. That's got to be a bug...
    In debug, I do not see the item listed at all. It's not used. That's fine - but why is it trying to insert the value? I would think it would leave it off??? I think because the item is associated with a database column. But, getting around this is ugly. Having to create a hidden item for each one, and then check to see if I need to take the list value... horrible. Any way to get around this???

    I should add - I guess I can always put my own custom process in to replace the DML. Just seems like a simple thing - if the value doesn't appear on the debug, isn't set with any default value... don't include it in the DML.

  • How To know Which Columns are not null and Which are null

    Hi Freinds,
    I want to Know ,How by Wrting a Query we can get the Names of The Columns from the Table which is set to not-null or null,
    Thanks
    Shoaib

    SELECT * FROM user_tab_columns
    WHERE table_name='Your_Table_Name'Check NULLABLE column.

  • Get list of Not Null and PK Columns

    hi All,
    I need to get the list of all the columns which are part of PK and not null, can you help me on this?
    with the below query I am getting the not null ones but need to get the PK columns  also
    SqlServer Version is 2008R2
    SELECT TABLE_CATALOG AS Database_Name, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, IS_NULLABLE
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'Express'
    AND IS_NULLABLE = 'NO'
    Thanks!
    Neil

    Give this a go. It includes by bitval solver function, as the status column is stored that way.
    CREATE FUNCTION dbo.solveBitVal(@val BIGINT)
    RETURNS @result TABLE (id INT, bitvalue BIGINT)
    BEGIN
    DECLARE @bitTranslate TABLE (id INT, bitvalue BIGINT)
    DECLARE @numbah TABLE (num INT)
    DECLARE @loopah INT
    SET @loopah = 1
    WHILE @loopah <= 63
    BEGIN
    INSERT INTO @bitTranslate (id, bitvalue) VALUES (@loopah, POWER(CAST(2 AS BIGINT),@loopah-1))
    INSERT INTO @numbah (num) VALUES (@loopah)
    SET @loopah = @loopah + 1
    END
    WHILE @val > 0
    BEGIN
    INSERT INTO @result
    SELECT MAX(id), MAX(bitvalue) FROM @bitTranslate WHERE bitvalue <= @val
    SELECT @val = @val - MAX(bitvalue) FROM @bitTranslate WHERE bitvalue <= @val
    END
    RETURN
    END
    GO
    ;WITH cons AS (
    SELECT o.name, c.*, b.id AS statusID, ROW_NUMBER() OVER (PARTITION BY c.id, colid ORDER BY b.id) AS seq
    FROM sys.sysconstraints c
    INNER JOIN sys.objects o
    ON c.id = o.object_id
    CROSS APPLY dbo.solveBitVal(c.status) b
    ), rCTE AS (
    SELECT c.name, c.constid, c.id, c.colid, c.spare1, c.status, c.actions, c.error, CAST(CASE WHEN statusID = 1 THEN 'PRIMARY KEY constraint '
    WHEN statusID = 2 THEN 'UNIQUE KEY constraint '
    WHEN statusID = 3 THEN 'FOREIGN KEY constraint '
    WHEN statusID = 4 THEN 'CHECK constraint '
    WHEN statusID = 5 THEN 'DEFAULT constraint '
    WHEN statusID = 16 THEN 'Column-level constraint'
    WHEN statusID = 32 THEN 'Table-level constraint '
    END AS NVARCHAR(MAX)) AS statusName, c.seq, c.statusID
    FROM cons c
    WHERE seq = 1
    UNION ALL
    SELECT c.name, c.constid, c.id, c.colid, c.spare1, c.status, c.actions, c.error, CAST(r.statusName + ', ' + CASE WHEN c.statusID = 1 THEN 'PRIMARY KEY constraint '
    WHEN c.statusID = 2 THEN 'UNIQUE KEY constraint '
    WHEN c.statusID = 3 THEN 'FOREIGN KEY constraint '
    WHEN c.statusID = 4 THEN 'CHECK constraint '
    WHEN c.statusID = 5 THEN 'DEFAULT constraint '
    WHEN c.statusID = 16 THEN 'Column-level constraint'
    WHEN c.statusID = 32 THEN 'Table-level constraint '
    END AS NVARCHAR(MAX)), c.seq, c.statusID
    FROM cons c
    INNER JOIN rCTE r
    ON c.id = r.id
    AND c.colid = r.colid
    AND c.seq - 1 = r.seq
    SELECT *
    FROM rCTE
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • NULL IS NOT NULL filter issue

    Can someone explain why 'Y' = 'N' is not working with PARALLEL Plan? i.e. With the filter like 'Y' = 'N' specified and if PQ is used , it does not return instantly. In fact it reads the entire table.
    Here is the test case.. Goal is to execute only one of the SQL joined by union all. I have included 'Y' = 'N' in both SQLs for the test purpose.
    DB Version is 10.2.0.4
    Create table test_tbl_01 nologging as select do.* from dba_objects do , dba_objects d1 where rownum < 22000001;
    Create table test_tbl_02 nologging as select do.* from dba_objects do , dba_objects d1 where rownum < 22000001;
    execute DBMS_STATS.GATHER_TABLE_STATS('SCOTT', 'TEST_TBL_01');
    execute DBMS_STATS.GATHER_TABLE_STATS('SCOTT', 'TEST_TBL_02');
    *Serial path with 2 table join*
    SQL> select
      2    /* parallel(t1,2 ) parallel(t2,2) */
      3    t1.*
      4    from test_tbl_01 t1 ,test_tbl_02 t2
      5    where t1.object_name = t2.object_name
      6    and  'Y' = 'N'
      7    and  t1.object_type = 'TABLE'
      8    union all
      9    select
    10    /* parallel(t1,2 ) parallel(t2,2) */
    11    t1.*
    12    from test_tbl_01 t1 ,test_tbl_02 t2
    13    where t1.object_name = t2.object_name
    14    and  'Y' = 'N'
    15  /
    no rows selected
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3500703583
    | Id  | Operation            | Name        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |             |     2 |   168 |       |     0   (0)|          |
    |   1 |  UNION-ALL           |             |       |       |       |            |          |
    |*  2 |   FILTER             |             |       |       |       |            |          |
    |*  3 |    HASH JOIN         |             |   660G|    50T|   449M|  6242K (99)| 24:16:38 |
    |*  4 |     TABLE ACCESS FULL| TEST_TBL_01 |  5477K|   386M|       | 41261   (2)| 00:09:38 |
    |   5 |     TABLE ACCESS FULL| TEST_TBL_02 |    22M|   212M|       | 40933   (2)| 00:09:34 |
    |*  6 |   FILTER             |             |       |       |       |            |          |
    |*  7 |    HASH JOIN         |             |  2640G|   201T|   467M|    24M(100)| 95:54:53 |
    |   8 |     TABLE ACCESS FULL| TEST_TBL_02 |    22M|   212M|       | 40933   (2)| 00:09:34 |
    |   9 |     TABLE ACCESS FULL| TEST_TBL_01 |    21M|  1546M|       | 41373   (3)| 00:09:40 |
    Predicate Information (identified by operation id):
       2 - filter(NULL IS NOT NULL)
       3 - access("T1"."OBJECT_NAME"="T2"."OBJECT_NAME")
       4 - filter("T1"."OBJECT_TYPE"='TABLE')
       6 - filter(NULL IS NOT NULL)
       7 - access("T1"."OBJECT_NAME"="T2"."OBJECT_NAME")
    Statistics
              1  recursive calls
              0  db block gets
              0  consistent gets
              0  physical reads
              0  redo size
            567  bytes sent via SQL*Net to client
            232  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processed
    *Parallel path with 2 table join*
    SQL> select
      2    /*+ parallel(t1,2 ) parallel(t2,2) */
      3    t1.*
      4    from test_tbl_01 t1 ,test_tbl_02 t2
      5    where t1.object_name = t2.object_name
      6    and  'Y' = 'N'
      7    and  t1.object_type = 'TABLE'
      8    union all
      9    select
    10    /*+ parallel(t1,2 ) parallel(t2,2) */
    11    t1.*
    12    from test_tbl_01 t1 ,test_tbl_02 t2
    13    where t1.object_name = t2.object_name
    14    and  'Y' = 'N'
    15  /
    no rows selected
    Elapsed: 00:01:09.34
    Execution Plan
    Plan hash value: 1557722279
    | Id  | Operation                   | Name        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT            |             |     2 |   168 |       |     0   (0)|          |     |         |            |
    |   1 |  PX COORDINATOR             |             |       |       |       |            |          |     |         |            |
    |   2 |   PX SEND QC (RANDOM)       | :TQ10004    |       |       |       |            |          |  Q1,04 | P->S | QC (RAND)  |
    |   3 |    BUFFER SORT              |             |     2 |   168 |       |            |          |  Q1,04 | PCWP |            |
    |   4 |     UNION-ALL               |             |       |       |       |            |          |  Q1,04 | PCWP |            |
    |*  5 |      FILTER                 |             |       |       |       |            |          |  Q1,04 | PCWC |            |
    |*  6 |       HASH JOIN             |             |   660G|    50T|   224M|  3465K (99)| 13:28:42 |  Q1,04 | PCWP |            |
    |   7 |        PX JOIN FILTER CREATE| :BF0000     |  5477K|   386M|       | 22861   (2)| 00:05:21 |  Q1,04 | PCWP |            |
    |   8 |         PX RECEIVE          |             |  5477K|   386M|       | 22861   (2)| 00:05:21 |  Q1,04 | PCWP |            |
    |   9 |          PX SEND HASH       | :TQ10000    |  5477K|   386M|       | 22861   (2)| 00:05:21 |  Q1,00 | P->P | HASH       |
    |  10 |           PX BLOCK ITERATOR |             |  5477K|   386M|       | 22861   (2)| 00:05:21 |  Q1,00 | PCWC |            |
    |* 11 |            TABLE ACCESS FULL| TEST_TBL_01 |  5477K|   386M|       | 22861   (2)| 00:05:21 |  Q1,00 | PCWP |            |
    |  12 |        PX RECEIVE           |             |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,04 | PCWP |            |
    |  13 |         PX SEND HASH        | :TQ10001    |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,01 | P->P | HASH       |
    |  14 |          PX JOIN FILTER USE | :BF0000     |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,01 | PCWP |            |
    |  15 |           PX BLOCK ITERATOR |             |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,01 | PCWC |            |
    |  16 |            TABLE ACCESS FULL| TEST_TBL_02 |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,01 | PCWP |            |
    |* 17 |      FILTER                 |             |       |       |       |            |          |  Q1,04 | PCWC |            |
    |* 18 |       HASH JOIN             |             |  2640G|   201T|   233M|    13M(100)| 53:15:52 |  Q1,04 | PCWP |            |
    |  19 |        PX RECEIVE           |             |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,04 | PCWP |            |
    |  20 |         PX SEND HASH        | :TQ10002    |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,02 | P->P | HASH       |
    |  21 |          PX BLOCK ITERATOR  |             |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,02 | PCWC |            |
    |  22 |           TABLE ACCESS FULL | TEST_TBL_02 |    22M|   212M|       | 22679   (1)| 00:05:18 |  Q1,02 | PCWP |            |
    |  23 |        PX RECEIVE           |             |    21M|  1546M|       | 22924   (2)| 00:05:21 |  Q1,04 | PCWP |            |
    |  24 |         PX SEND HASH        | :TQ10003    |    21M|  1546M|       | 22924   (2)| 00:05:21 |  Q1,03 | P->P | HASH       |
    |  25 |          PX BLOCK ITERATOR  |             |    21M|  1546M|       | 22924   (2)| 00:05:21 |  Q1,03 | PCWC |            |
    |  26 |           TABLE ACCESS FULL | TEST_TBL_01 |    21M|  1546M|       | 22924   (2)| 00:05:21 |  Q1,03 | PCWP |            |
    Predicate Information (identified by operation id):
       5 - filter(NULL IS NOT NULL)
       6 - access("T1"."OBJECT_NAME"="T2"."OBJECT_NAME")
      11 - filter("T1"."OBJECT_TYPE"='TABLE')
      17 - filter(NULL IS NOT NULL)
      18 - access("T1"."OBJECT_NAME"="T2"."OBJECT_NAME")
    Statistics
           1617  recursive calls
              3  db block gets
         488929  consistent gets
         493407  physical reads
            636  redo size
            567  bytes sent via SQL*Net to client
            232  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
              0  rows processedHowever single table with UNION ALL and PQ works..
    *NO Joins (i.e. Single Table with PQ )  , Issue does not show-up.*
    _*SERIAL PLAN with one Table*_
    SQL> select
      2    /* parallel(t1,2 )   */
      3    t1.*
      4    from test_tbl_01 t1
      5    where 'Y' = 'N'
      6    and  t1.object_type = 'TABLE'
      7    union all
      8    select
      9    /* parallel(t1,2 )   */
    10    t1.*
    11    from test_tbl_01 t1
    12    where 'Y' = 'N'
    13  /
    no rows selected
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 2870519681
    | Id  | Operation           | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |             |     2 |   148 |     0   (0)|          |
    |   1 |  UNION-ALL          |             |       |       |            |          |
    |*  2 |   FILTER            |             |       |       |            |          |
    |*  3 |    TABLE ACCESS FULL| TEST_TBL_01 |  5477K|   386M| 41261   (2)| 00:09:38 |
    |*  4 |   FILTER            |             |       |       |            |          |
    |   5 |    TABLE ACCESS FULL| TEST_TBL_01 |    21M|  1546M| 41373   (3)| 00:09:40 |
    Predicate Information (identified by operation id):
       2 - filter(NULL IS NOT NULL)
       3 - filter("T1"."OBJECT_TYPE"='TABLE')
       4 - filter(NULL IS NOT NULL)
    Statistics
              0  recursive calls
              0  db block gets
              0  consistent gets
              0  physical reads
              0  redo size
            567  bytes sent via SQL*Net to client
            232  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processed
    _*PARALLEL PLAN with one Table*_
    SQL> select
      2    /*+ parallel(t1,2 )      */
      3    t1.*
      4    from test_tbl_01 t1
      5    where 'Y' = 'N'
      6    and  t1.object_type = 'TABLE'
      7    union all
      8    select
      9    /*+ parallel(t1,2 )      */
    10    t1.*
    11    from test_tbl_01 t1
    12    where 'Y' = 'N'
    13  /
    no rows selected
    Elapsed: 00:00:00.09
    Execution Plan
    Plan hash value: 3114025180
    | Id  | Operation              | Name        | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT       |             |     2 |   148 |     0   (0)|          |        |      |            |
    |   1 |  PX COORDINATOR        |             |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)  | :TQ10000    |       |       |            |          |  Q1,00 | P->S | QC (RAND)  |
    |   3 |    UNION-ALL           |             |       |       |            |          |  Q1,00 | PCWP |            |
    |*  4 |     FILTER             |             |       |       |            |          |  Q1,00 | PCWC |            |
    |   5 |      PX BLOCK ITERATOR |             |  5477K|   386M| 22861   (2)| 00:05:21 |  Q1,00 | PCWC |            |
    |*  6 |       TABLE ACCESS FULL| TEST_TBL_01 |  5477K|   386M| 22861   (2)| 00:05:21 |  Q1,00 | PCWP |            |
    |*  7 |     FILTER             |             |       |       |            |          |  Q1,00 | PCWC |            |
    |   8 |      PX BLOCK ITERATOR |             |    21M|  1546M| 22924   (2)| 00:05:21 |  Q1,00 | PCWC |            |
    |   9 |       TABLE ACCESS FULL| TEST_TBL_01 |    21M|  1546M| 22924   (2)| 00:05:21 |  Q1,00 | PCWP |            |
    Predicate Information (identified by operation id):
       4 - filter(NULL IS NOT NULL)
       6 - filter("T1"."OBJECT_TYPE"='TABLE')
       7 - filter(NULL IS NOT NULL)
    Statistics
             28  recursive calls
              3  db block gets
              7  consistent gets
              0  physical reads
            628  redo size
            567  bytes sent via SQL*Net to client
            232  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
              0  rows processed

    The same behvious appears in 11.1.0.6, and you don't need such a large data set to prove the point. The paralllel distribution may change to a broadcast with a smaller data set, but I demonstrated the effect when my two tables simply selected 30,000 rows each from all_objects.
    I think you should pass this to Oracle Corp. as a bug - using the smaller data set.
    The problem seems to be the way that Oracle combines multiple lines of a plan into groups of operations (as in PCWC, PCWC, PCWP). It looks like this particularly example has managed to fold the FILTER into a group in such a way that Oracle has lost track of the fact that it is a 'pre-emptng - i.e. always false' filter rather than an ordinary data filter; consequently the filter doesn't apply until after the hash join starts running.
    In my example (which did a broadcast distribution) I could see that Oracle read the entire first table, then started to read the second table, but stopped after one row of the second table, because my plan allowed the join and filter to be applied immediately after the first row from the second table. And I think Oracle decided that the filter was alway going to be false at that moment - so stopped running the second tablescan. You've used a hash/hash distribriution, which has resulted in both scans completing because the slaves in each layer don't talk to each other.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan

Maybe you are looking for

  • File adapter in OSB

    Hi , I am trying to use file adapter in OSB. My intention is the OSB should write a file in a specified location in my sytem. I have configured the Business Service with Messagin service in (general tab), request msg as text and response msg as none

  • What to do about Apple Mobile Device failed to start problem??

    I had iTunes on my computer but when I went to update to the new version  of iTunes it kept popping up that my Mobile Device Service failed to  start. So I uninstalled iTunes and tried reinstalling but now I have a  different box that pops up saying

  • Service Start Issues

    I'm experiencing some "finicky" behavior with the CF Application Server. I recently (about 2 weeks ago) reformatted my laptop and repartitioned my drive. I'm currently running XP Pro with 512 ram. I have reinstalled CFMX7 and have it running as my we

  • Running 2nd display... (question)

    Hey everyone. My brother has a Powermac G5 dual 1.8 with 4GB RAM and it's currently got an old AGP graphics card in - I think it's a Radeon 9800 Pro. Anyway, he's picked up another cinema display and wants to use 2 screens for editing however his gra

  • SAP Notes status can't be implemented?

    Hi All I would like to know, why few SAP notes status can't be implemented. your view will be appreciated and will rewarded with <<removed by moderator>>. Regards Madhavi Edited by: kishan P on Sep 1, 2010 1:03 PM