SQL constraint (Is this allowed)?!

Dear all,
I'm designing a database at the moment. I have a table called Student. In this table I have the following fields:
Student ID, Name, Grant ID*, Fund ID*
The Grant ID* and Fund ID* are foreign keys referencing a grant table and a fund table.
In a normal situation, the student has a grant OR typical fund such as self funding or scholarship etc.
the question is : can I have a constraint to force the table entry to one column only but not the other and vise versa.So the student will only have a grant OR typical fund?
I don't know the name of this constraint, I have searched for a long time but without knowing what I am searching for Its like searching for a needle in a hay stack.

Something like this perhaps
SCOTT @ jcave102 Local> ed
Wrote file afiedt.buf
  1  create table a (
  2    col1 number,
  3    col2 number,
  4    constraint chk_a1 check( (col1 is not null and col2 is null) or
  5                             (col2 is not null and col1 is null))
  6* )
SCOTT @ jcave102 Local> /
Table created.
Elapsed: 00:00:00.01
SCOTT @ jcave102 Local> insert into a values( 1, null );
1 row created.
Elapsed: 00:00:00.01
SCOTT @ jcave102 Local> insert into a values( null, 1 );
1 row created.
Elapsed: 00:00:00.01
SCOTT @ jcave102 Local> insert into a values( 1, 1 );
insert into a values( 1, 1 )
ERROR at line 1:
ORA-02290: check constraint (SCOTT.CHK_A1) violated
Elapsed: 00:00:00.07
SCOTT @ jcave102 Local> insert into a values( null, null );
insert into a values( null, null )
ERROR at line 1:
ORA-02290: check constraint (SCOTT.CHK_A1) violated
Elapsed: 00:00:00.01Justin

Similar Messages

  • An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider,

    An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider,
    error: 40 - Could not open a connection to SQL Server)

    An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named
    Pipes Provider, error: 40 - Could not open a connection to SQL Server)
    Hello,
    Make sure your SQL Server service is started.
    Make sure TCP\IP and names pipes protocol is enabled
    Make sure you have made an exception in firewall for SQL Server connection
    Make sure SQL Server browser service is enabled
    Make sure you connect with correct name hostname\instance name for named instance,MSSQLSERVER for default instance and Hotname\SQLEXPRESS for express edition.
    Please make sure you use port no when connecting to SQL server listeing on different port (hostname\instance ,portno)
    http://blogs.msdn.com/sql_protocols/archive/2006/09/30/SQL-Server-2005-Remote-Connectivity-Issue-TroubleShooting.aspx
    Hope this helps
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • SQL operations are not allowed with no global transaction by default for X

    Hi All,
    I am getting the above mentioned error.
    java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA drivers. If the XA driver supports performing SQL operations with no global transaction, explicitly allow it by setting "SupportsLocalTransaction" JDBC connection pool property to true. In this case, a
    lso remember to complete the local transaction before using the connection again for global transaction, else a XAER_OUTSIDE XAException may result. To complete a local transaction, you can either set auto commit to true or call Connection.commit() or Connection.rollback().
    I am developing a web application. I have jsp, servlets, JDBC classes.
    I am using DataSource and Connection pools.
    I am on WLS 8.1 sp3 and Oracle 10.1.
    Part of My Config file looks as follows:
    <JDBCConnectionPool DriverName="weblogic.jdbcx.oracle.OracleDataSource" KeepLogicalConnOpenOnRelease="true" KeepXAConnTillTxComplete="false" Name="AUMDataSource" NeedTxCtxOnClose="false" NewXAConnForCommit="false" Password="{3DES}AKRkWgdzXN8WrXSRtSvJ6g==" Properties="user=pibsrmgr;portNumber=1521;SID=pibsrdod;serverName=pibsrdod.dtu.mlam.ml.com" RollbackLocalTxUponConnClose="true" SupportsLocalTransaction="false" Targets="myserver" TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:bea:oracle://pibsrdod.dtu.mlam.ml.com:1521" XAEndOnlyOnce="false" />
    <JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="jdbc/AUMDataSource" Name="AUMDataSource" PoolName="AUMDataSource" Targets="myserver" />
    Any help will be appreciated.
    Thanks
    ---Radhe

    Hi,
    Regarding Transactions , the following link can helpful to you .
    Regards,
    Prasanna Yalam

  • ORA-02253: constraint specification not allowed here

    I'm trying to create a table clients with primairy key, but I'm getting the error "ORA-02253: constraint specification not allowed here"
    if anyone call what to do
    CREATE TABLE CLIENTS
    NUMERO NUMBER(6) CONSTRAINT PK_CLIENTS PRIMAIRY KEY,
    NOM VARCHAR(63), NOT NULL,
    PRENOM VARCHAR(63),
    NAISSANCE DATE
    Edited by: user10397656 on Oct 13, 2008 1:40 AM

    There are some errors in your script :
    PK_CLIENTS PRIMAIRY KEY
    and
    NOM VARCHAR(63)*,* NOT NULL,
    Try this way
    CREATE TABLE CLIENTS
    NUMERO NUMBER(6) CONSTRAINT PK_CLIENTS PRIMARY KEY,
    NOM VARCHAR(63) NOT NULL,
    PRENOM VARCHAR(63),
    NAISSANCE DATE
    );

  • What does SQL write to that allow changes to be undone or rolled back in case of a system failure?

    What does SQL write to that allow changes to be undone or rolled back in case of a system failure?

    What does SQL write to that allow changes to be undone or rolled back in case of a system failure?
    Hello,
    If i read your question correctly you are asking about how uncommited transaction are rolled back.For this, concept of transaction log came into picture.where first changes were first made to transaction log and then into memory .Before any change is made
    to real data file change is made to trn log files so that if rollback comes it can see in log and rollback it.
    I would suggest you to read Famous article by log which will explain you
    http://technet.microsoft.com/en-us/magazine/2009.02.logging.aspx
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Executing the SQL statement is not allowed - Error

    I am getting "Executing the SQL statement is not allowed" for an INSERT cfquery that I'm running.  I checked the usual suspects:
    - DSN allows INSERT
    - I've seen reports online where certain field names or values are considered key words, so for protection CF blocks the query in this way (it would be nice if there was a different error message when it gets blocked this way vs. the DSN doesn't allow INSERT error message).  The field names and values were all benign strings, so it didn't seem like that.
    I took the same string for the query and ran it on another page and it ran fine (same DSN, too).

    SOLVED: I decided to enter this in here, just to get it into web searches for others since I couldn't find anything.
    - I was calling a function for one of the values in the query:  get_db_status_code("initialize")  Apparently CF parses the query to see if it's allowed BEFORE it runs the CFML in it, so something in that function name, or the parameter "initialize" was a key word that CF doesn't allow.  I moved the function call outside of the query and loaded a temp variable for use in the query and it then worked.

  • Installing windows on macbook pro without bootcamp. Will this allow for switchable graphics?

    Hi everyone, I was thinking of buying a new Macbook Pro Retina 15 Inch with the discrete nvidia graphics card inbuilt with it.
    I love windows and I am planning on running windows 7/8 on the macbook pro as my primary OS (because of advantages of gaming and being familarized with windows os), however I have heard the issue of running windows on bootcamp severally drains battery life as apple does not allow you to switch the nvidia graphics to the integrated graphics. Is this true? I have heard that running windows 7/8 on bootcamp allows for only around 3:30 hours of battery life, whilst OSX allows for 8+ since it uses the integrated graphics primarily when not running GPU demanding applications.
    I am wondering if you can install windows 7 without bootcamp which will wipe apple OS from the laptop completely. Will this allow for the laptop to do switable graphics without problems allowing the laptop to save much needed battery life?
    Thanks in advance.
    Michael

      Sorry it seems to have taken so long for you to get an answer on this question!
      Your last post was mostly right... It IS a bad idea to go that route!
      While it's technically POSSIBLE to get Windows in place without OSX, it's a MAJOR technical hassle and you need to jump through several hoops to get to that point.
      In addition to the hassle required, having an OSX partition can be incredibly useful at times - I've had my Windows system break several times in the past where the automated (and even manual) startup-repair process failed to get Windows booting again, but a short boot into OSX later, I have the problem resolved (via OSX) and am able to get back into Windows.
      Finally, you need to be aware that the graphics card situation isn't because of the presence of OSX. Just because you get rid of MacOS doesn't mean you suddenly will be able to use either graphics card! The limitation comes into play with the hardware drivers necessary to get all your hardware working in Windows - they just don't have the facility to switch graphics cards built into them.
      I'm afraid you're stuck with the NVidia card when using Windows, one way or another!
      Bootcamp is a prerequisite BTW. Without it you won't be able to get Windows installed at all (at least not without MAJOR stumbling block, again!), and again, the graphics card limitation isn't due to OSX or Bootcamp.
      Also, battery life... Yes. You'll have significantly less in Windows, and this isn't entirely because of the graphics card situation either. MacOS is just built so well, with the limited hardware used by Apple in mind, that power-management when using OSX os significantly better! The legendary battery life of Apple systems is actually primarily due to the operating system, not the batteries themselves!
      As a helpful indication: On my 2009 17" MBP I get about 7 hours on the integrated chip in OSX (8 is pusing it, but is possible sometimes); about 5 hours in OSX when using the NVidia; and about 3 and a half when I'm in Windows.
      Hope this all helps you. If you have any further questions feel free!
      Apologies for the scattered approach to answering your posts - it's LATE where I am and I"m kinda rushing through things... :-)

  • HT5287 I want to borrow os x 10.6 from my friend to install it on my macbook which is running 10.5.8. Is this allowed by Apple?

    I want to borrow os x 10.6 from my friend to install it on my macbook which is running 10.5.8. Is this allowed by Apple?

    Apple install discs are machine specific meaning an install disc that came with one Mac cannot be used on another.
    Snow Leopard v10.6 is available for purchase from the Apple online store >  Mac OS X 10.6 Snow Leopard - Apple Store
    Make sure your Mac meets v10.6 Snow Leopard minimum requirements before purchasing.
    Mac OS X v10.6 Snow Leopard - Technical Specifications
    Mac computer with an Intel processor
    1GB of memory
    5GB of available disk space
    DVD drive for installation
    Some features require a compatible Internet service provider; fees may apply.

  • Need PL/SQL code for this

    Hi,
    I need a PL/SQL code for this one...
    Let me know if something is not clear...
    1) The table CLOB_CLOBJECT_CDA has the columns described below...
    Explaining only those fields which are important in this context
    -- CDA_STEP_ID : Basically a Sequence
    -- CLOBJECT_SOURCE1_ID : Every id has got a set of records
    -- CLOBJECT_SOURCE2_ID : Every id has got a set of records
    -- LVL : There are total 8 levels..
    This is the main aim :
    1) There are total 16 million rows..(limited to 10 rows here)
    2) We need to go through level by level (LVL column) & insert the intersection records (CLOBJECT_SOURCE1_ID intersect CLOBJECT_SOURCE2_ID)
    into another table...but this is how it goes..
    Level (LVL column) 3's basically have CLOBJECT_SOURCE1_ID as level (LVL column) 2 CDA_STEP_ID's..
    (consider the statement --** where CLOBJECT_SOURCE1_ID = 285 which is same as 1st insert statement step id)..
    The above process goes for next levels until 8..(so have to use loops)
    So for ex :
    We go through the first insert statement and insert the insertion records only when both CLOBJECT_SOURCE1_ID & CLOBJECT_SOURCE2_ID has got records ..
    If we don't find any records for both of them we should skip the corresponding step id when we go to the next levels...
    Let's go through the 1st insert statement...
    -- We have CDA_STEP_ID = 285 & two sources CLOBJECT_SOURCE1_ID as 19 & CLOBJECT_SOURCE2_ID as 74...
    -- We see the table CLOBJECT_COUNTS & check whether we have counts for both 19 & 74 ..(In fact we insert counts into this table only if they have records)
    -- If so, we insert the intersection records into CDA_MRN_RESULTS ( we do have counts for both of them..) with CDA_STEP_ID 285...
    -- Then we insert the step id which is 285 along with the count into CLOBJECT_COUNTS..
    Let's go through another insert statement...
    -- Consider CDA_STEP_ID = 288 which has two sources CLOBJECT_SOURCE1_ID as 19 & CLOBJECT_SOURCE2_ID as 92...
    -- We see the table CLOBJECT_COUNTS & check whether we have counts for both 19 & 92 ..(we have records for 19 but not for 92)
    -- So we should not proceed with this..& also skip all those records (future records with increasing levels..basically level 3's) which have got 288 as CLOBJECT_SOURCE1_ID..
    (As said earlier that the present CDA_STEP_ID will always be CLOBJECT_SOURCE1_ID in the next level)...
    I wrote the following code which is after the statement...
    Let me have the create & insert statements here..
    create table CLOB_CLOBJECT_CDA
        CDA_STEP_ID           NUMBER,
        CDA_ID                NUMBER,
        CDA_SEQ_NUMBER        NUMBER,
        CLOBJECT_SOURCE1_TYPE VARCHAR2(3000),
        CLOBJECT_SOURCE1_ID   NUMBER,
        CLOBJECT_OPERATOR     VARCHAR2(3000),
        CLOBJECT_SOURCE2_TYPE VARCHAR2(3000),
        CLOBJECT_SOURCE2_ID   NUMBER,
        LVL                   NUMBER
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (285, 285, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 74, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (286, 286, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 75, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (287, 287, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 91, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (288, 288, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 92, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4869, 4869, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 91, 3);  -- **
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4870, 4870, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 92, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4871, 4871, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 93, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4880, 4880, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 91, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4881, 4881, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 92, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4882, 4882, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 93, 3);
    create table CDA_MRN_RESULTS
       CDA_STEP_ID      NUMBER,
      MRN              NUMBER,
      INSERT_DATE_TIME DATE
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19, 1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19,  3, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  4, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  6, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (91,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (91,  3, to_date('19-10-2011', 'dd-mm-yyyy'));
    create table CLOBJECT_COUNTS
      CDA_STEP_ID    NUMBER,
      CLOBJECT_COUNT NUMBER,
      DATE_TIME      DATE
    Insert into CLOBJECT_COUNTS values (19,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (74,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (75,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (91,2, to_date('19-10-2011', 'dd-mm-yyyy'));The output goes into two tables...
    CDA_MRN_RESULTS : O/p of intersection records between source1 & source2 id
    CLOBJECT_COUNTS : Step id with counts ...(useful for skipping next level step id's if either of source id has "0" counts)
    Any help is appreciated..
    Thanks..

    I tried to code this..but looping takes a lot of time..I want to skip certain rows where source1_step_id & source_2_step_id are not in clobject_counts table as we proceed to the next levels..Not sure how to skip the rows..
    declare
    cursor c1 (p_level varchar2 ) is
      Select * from clob_clobject_cda
        where lvl = p_level    ;
       TYPE V_TT IS TABLE OF C1%ROWTYPE INDEX BY PLS_INTEGER;
        L_TT V_TT;
        v1 number;
        v2 number;
        v_step_id number;
        v_operator varchar2(100) := '';
    begin
    for i in 2..8 loop
      open c1(i);
      LOOP
           FETCH C1 BULK COLLECT INTO L_TT LIMIT 500;
            FOR indx IN 1 .. L_TT.COUNT
             LOOP
               v1 := L_TT(indx).clobject_source1_id;
               v2 := L_TT(indx).clobject_source2_id;
               v_step_id := L_TT(indx).cda_step_id;
               v_operator := L_TT(indx).clobject_operator;
      Execute Immediate ('Insert into cda_mrn_results Select --+ parallel (cm 128)
                                                      distinct ' || v_step_id || ', mrn, trunc(sysdate) dt from cda_mrn_results  cm
                        where cda_step_id = ' || v1 || '
                        and   cda_step_id in (Select cda_step_id from clobject_counts) ' ||
         v_operator ||
                    '  Select --+ parallel (cm 128)
                                                      distinct ' || v_step_id || ', mrn, trunc(sysdate) dt from cda_mrn_results  cm
                        where cda_step_id = ' || v2 || '
                        and   cda_step_id in (Select cda_step_id from clobject_counts)  ' );
    Insert --+ Append
           into clobject_counts Select cda_step_id, count(distinct mrn),
                       insert_date_time dt from cda_mrn_results  where cda_step_id =  v_step_id   group by cda_step_id,insert_date_time;
       COMMIT;                    
             END LOOP;
           EXIT WHEN L_TT.COUNT = 0;
         END LOOP;
      CLOSE C1;
    End Loop;    
    Commit;
    End;

  • Need pl/sql stmnts. for this simple logic

    Hi,
    I need PL/SQL program for this simple logic i am doing mistake somewhere unbale to trace
    out ..
    select * from GSR03_PO_DTL;
    PO_NUM
    L53177000 -- > no changes reqd (only one entry with new format)
    L00041677 --> to be updated to L41677000(only one entry with OLD format)
    L43677000 -- > no change reqd (exists one row with new format and old format like below)
    L00043677 -- > to be deleted this is old format (and new format like above already exists)
    EX:
    L00012345 --- old format
    L12345000 --- new format
    Hope question is clear. I written the following program.
    update is working fine but delete is not working.
    Please help.
    Thanks in Advance
    Devender
    declare
    Cursor c_test is
    (select po_num from GSR03_PO_DTL);
    BEGIN
    FOR r_test in c_Test
    LOOP
    dbms_output.put_line (r_test.po_num);
    IF ('L'||substr(r_test.po_num,5,5)) = ('L'||substr(r_test.po_num,2,5)) then
         dbms_output.put_line ('delete stmnt');
    END IF;     
    EXIT WHEN c_test%NOTFOUND;
    END LOOP;
    FOR r_test in c_Test
    LOOP
    IF r_test.po_num like 'L000%' then
    IF ('L'||substr(r_test.po_num,5,5)) is not NULL then
         update GSR03_PO_DTL set PO_NUM = 'L'||substr(po_num,5,5)||'000'
         where po_num like 'L000%' ;
         dbms_output.put_line ('update stmnt');
    END IF;     
    END IF;
    END LOOP;
    END;
    *********************

    No need for PL/SQL, man.
    SQL> SELECT po_no FROM po1
      2  /
    PO_NO
    L53177000
    L00041677
    L43677000
    L00043677
    SQL> UPDATE po1 y
      2  SET    y.po_no = 'L'||substr(y.po_no,5,5)||'000'
      3  WHERE  y.po_no LIKE 'L000%'
      4  AND    NOT EXISTS ( SELECT null FROM po1 x
      5                      WHERE x.po_no =  'L'||substr(y.po_no,5,5)||'000')
      6  /
    1 row updated.
    SQL> DELETE FROM po1 y
      2  WHERE  y.po_no LIKE 'L000%'
      3  AND    EXISTS ( SELECT null FROM po1 x
      4                  WHERE x.po_no =  'L'||substr(y.po_no,5,5)||'000')
      5  /
    1 row deleted.
    SQL> SELECT po_no FROM po1
      2  /
    PO_NO
    L53177000
    L41677000
    L43677000
    SQL> Cheers, APC

  • APP-ALR-04106: Please correct the user-defined SQL statement for this alert

    Hi All,
    I have created an alert for engineering module in R12. It got tested and was working fine. when the user testing it, while trigger the alert getting the error, "APP-ALR-04106: Please correct the user-defined SQL statement for this alert".
    when verified the alert, it got verified and ran also. It parsed the query successfully and when run it fetched few records.
    Need help in resolving the issue.
    Thanks in advance.
    Regards,
    sri
    Edited by: user10939296 on Jan 18, 2010 1:16 AM

    Hi Sri;
    I have already gone through the Note: 948037.1. But this note is related to 11i. The solution provided in the Note is for 11i.
    I am facing this issue in R12. Is this patch applicable to R12?I belive its not. But u can check Solution part 4 for your instance, at least it can give you idea. The other note in metalink related bug and all for R11 too.
    I belive its better way to rise Sr while waiting other forum user response to that thread
    Regard
    Helios

  • How transfer a download OS X Lion from wife's to my Mac? Also, is this allowed?

    How do I transfer and download OS X Lion from wife's Mac to my Mac? Also, is this allowed ( I believe one or more additional downloads are allowed in house?
    Should I just spend the $30 and have my own OS?
    Thank you,
    Fletcher

    If you and your wife are using the same App Store account, you should be able to re-download the Lion installer on your computer from the App Store.
    No need to buy it again.
    Matt

  • Where can I find a "Legacy JAVA SE 6" download? This allows me to use Harmony Remote software on my MAC.

    Where can I find a "Legacy JAVA SE 6" download? This allows me to use Harmony Remote software on my MAC.

    Java for OS X 2014-001
    For how to uninstall the current version and install 6
    http://www.youtube.com/watch?v=6g401fnOnro
    http://www.youtube.com/watch?v=ZNFu4Ewryf0

  • Dynamic Query using no PL/SQL . Is this Possible ??

    Hi Everyone,
    Based upon the innery query result , can we have a different outer query I want to know whether this is possible with out PL/SQL.
    Example:
    This is my inner query :
    with q1 as
    (select
    case when x>500 then 0
    else 1
    end value
    from
    table1 )
    Here is where I am stopped , I only want to run either of these queries depending upon the value,
    I know that i can do it using PL/SQL but I want to know whether we can do it with pure SQL
    Some thing like this to happen :
    when value=0 : run this query : select * from table2
    when value=1 : run this query : select * from table2 join table3 using (col1)
    Thanks.
    VK

    Sure. A little modified way ->
    satyaki>
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.82
    satyaki>
    satyaki>
    satyaki>select k.deptno,
      2         k.empno,
      3         k.ename,
      4         k.job,
      5         k.mgr,
      6         k.hiredate,
      7         k.sal,
      8         k.comm,
      9         null dname,
    10         null loc
    11  from emp k
    12  where &eid = 0
    13  union all
    14  select *
    15  from (
    16         select *
    17         from emp
    18         join dept
    19         using (deptno)
    20       )
    21  where &eid = 1;
    Enter value for eid: 0
    old  12: where &eid = 0
    new  12: where 0 = 0
    Enter value for eid: 0
    old  21: where &eid = 1
    new  21: where 0 = 1
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM DNAME          LOC
            10       9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455
            10       7777 SOURAV     SLS                  14-SEP-08      45000       3400
            30       7521 WARD       SALESMAN        7698 22-FEB-81       1250        500
            20       7566 JONES      MANAGER         7839 02-APR-81       2975
            30       7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400
            30       7698 BLAKE      MANAGER         7839 01-MAY-81       2850
            10       7782 CLARK      MANAGER         7839 09-JUN-81       4450
            20       7788 SCOTT      ANALYST         7566 19-APR-87       3000
            10       7839 KING       PRESIDENT            17-NOV-81       7000
            30       7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0
            20       7876 ADAMS      CLERK           7788 23-MAY-87       1100
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM DNAME          LOC
            30       7900 JAMES      CLERK           7698 03-DEC-81        950
            20       7902 FORD       ANALYST         7566 03-DEC-81       3000
    13 rows selected.
    Elapsed: 00:00:00.32
    satyaki>/
    Enter value for eid: 1
    old  12: where &eid = 0
    new  12: where 1 = 0
    Enter value for eid: 1
    old  21: where &eid = 1
    new  21: where 1 = 1
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM DNAME          LOC
            10       9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455 ACCOUNTING     NEW YORK
            10       7777 SOURAV     SLS                  14-SEP-08      45000       3400 ACCOUNTING     NEW YORK
            10       7782 CLARK      MANAGER         7839 09-JUN-81       4450            ACCOUNTING     NEW YORK
            10       7839 KING       PRESIDENT            17-NOV-81       7000            ACCOUNTING     NEW YORK
            20       7566 JONES      MANAGER         7839 02-APR-81       2975            RESEARCH       DALLAS
            20       7876 ADAMS      CLERK           7788 23-MAY-87       1100            RESEARCH       DALLAS
            20       7788 SCOTT      ANALYST         7566 19-APR-87       3000            RESEARCH       DALLAS
            20       7902 FORD       ANALYST         7566 03-DEC-81       3000            RESEARCH       DALLAS
            30       7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0 SALES          CHICAGO
            30       7521 WARD       SALESMAN        7698 22-FEB-81       1250        500 SALES          CHICAGO
            30       7698 BLAKE      MANAGER         7839 01-MAY-81       2850            SALES          CHICAGO
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM DNAME          LOC
            30       7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400 SALES          CHICAGO
            30       7900 JAMES      CLERK           7698 03-DEC-81        950            SALES          CHICAGO
    13 rows selected.
    Elapsed: 00:00:00.24
    satyaki>Regards.
    Satyaki De.

  • I want sql query for this output

    hi guys
    could u tell how can i write sql query for this out put
    i have one table like this
    ID ACCOUTID TAX
    1 1 A
    2 1 B
    3 2 C
    4 2 D
    5 3 E
    7 NULL F
    8 NULL G
    MY OUT PUT MUST BE LIKE THIS
    ID AID TAX
    2 1 A
    4 2 D
    7 NULL F
    8 NULL G
    HERE IN THIS OUTPUT I SHOULD HAVE
    MAXIMAM ID VALUE FOR A REPEATED AID VALUES
    AND
    THE ROWS AID VALUES IS NULL ALSO MUST PAPULATED IN THE OUTPUT.
    I KNOW ONE SOLUTION LIKE THIS
    SELECT MAX(ID),AID,TAX
    FROM TABLE T
    GROUP BY AID,TAX
    UNION ALL
    SELECT ID, AIC,TAX
    FROM TABLE T
    WHERE AID IS NULL;
    BUT I WANT SAME RESULT WITH OUT USING LOGICAL OPERATORS.
    COULD U PLZ TELL A SOL.

    Will this help:
    SQL> with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21  and (rn = 1 or ACCOUTID is null)
    22  /
            ID        AID T
             2          1 B
             4          2 D
             8            G
             7            F
    -- If I leave out the OR condition then you'll get this:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21* and rn = 1
    SQL> /
            ID        AID T
             2          1 B
             4          2 D
             8            G
    --which follows the description you've given, but not the output

Maybe you are looking for