Exception in two places of insert statment

Hi All,
I want to insert exception in two places in pl sql. I am getting the error.Is there a way to implement exception in two places in insert statement.
Thanks,
uday
Begin
Declare
V_Code Number;
V_Errm Varchar2(64);
V_Code1 Number;
V_Errm1 Varchar2(64);
INSERT INTO Raise
Select Employee_Id, Salary*1.1 From Employees
Where Commission_Pct > .2;
EXCEPTION
When Others Then
V_Code := Sqlcode;
V_Errm := Substr(Sqlerrm, 1, 64);
Dbms_Output.Put_Line ('Error code ' || V_Code || ': ' || V_Errm);
Insert Into Scap_Fact_Loading_Errors Values (V_Code, V_Errm, Systimestamp);
INSERT INTO Raise
Select Employee_Id, Salary*1.1 From Employees
Where Commission_Pct > .1;
EXCEPTION
When Others Then V_Code1 := Sqlcode;
V_Errm1 := Substr(Sqlerrm, 1, 64);
Dbms_Output.Put_Line ('Error code ' || V_Code1 || ': ' || V_Errm1);
INSERT INTO Scap_Fact_Loading_Errors VALUES (v_code1, v_errm1, SYSTIMESTAMP);
END;
Edited by: 929521 on Jan 7, 2013 10:15 AM

>
I want to insert exception in two places in pl sql. I am getting the error.Is there a way to implement exception in two places in insert statement.
>
Sure - use two different blocks. The code you posted doesn't have any BEGIN.
The proper structure is:
BEGIN
. . . put your first code here
EXCEPTION
. . . put your first exception handling here
END;
BEGIN
. . . put your second code here
EXCEPTION
. . . put your second exception handling here
END;If you need your code to quit after an exception in one of the blocks issue a RAISE in the exception handler for that block.
Depending on what each block does and what you want to save or rollback it is also common to use SAVEPOINTs for the blocks.
See SAVEPOINT in the SQL Language doc.
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10001.htm
>
savepoint
Specify the name of the savepoint to be created.
Savepoint names must be distinct within a given transaction. If you create a second savepoint with the same identifier as an earlier savepoint, then the earlier savepoint is erased. After a savepoint has been created, you can either continue processing, commit your work, roll back the entire transaction, or roll back to the savepoint.
Example
Creating Savepoints: Example To update the salary for Banda and Greene in the sample table hr.employees, check that the total department salary does not exceed 314,000, then reenter the salary for Greene:
UPDATE employees
SET salary = 7000
WHERE last_name = 'Banda';
SAVEPOINT banda_sal;
UPDATE employees
SET salary = 12000
WHERE last_name = 'Greene';
SAVEPOINT greene_sal;
SELECT SUM(salary) FROM employees;
ROLLBACK TO SAVEPOINT banda_sal;
UPDATE employees
SET salary = 11000
WHERE last_name = 'Greene';
COMMIT;
>
For your use case you could create a SAVEPOINT before each of the blocks and then in the exception handlers issue a ROLLBACK to the appropriate SAVEPOINT before you exit the procedure.

Similar Messages

  • Error in insert statment in pl/sql

    Hi all,
    How i Execute Insert statment in Pl/Sql
    SQL> DECLARE
    2 tablename varchar2(30);
    3 Begin
    4 begin
    5 select table_name into tablename from user_tables
    6 where table_name=upper('t_calling');
    7 EXCEPTION
    8 WHEN no_data_found then
    9 execute immediate 'create table t_calling(F_CODE number,
    10 F_CALLING varchar2(50))';
    11 INSERT INTO T_Calling VALUES (1, 'asd');
    12 end;
    13 -- --------------------------
    14 Commit;
    15 End;
    16 /
    INSERT INTO T_Calling VALUES (1, 'asd');
    ORA-06550:
    PLS-00201: identifier 'T_CALLING' must be declared
    ORA-06550:
    PL/SQL: SQL Statement ignored
    Thanks
    alaa

    You are creating this table with an execute immediate statement. Which suggests that it doesn't exist yet. Therefore your insert statement is referencing a non-existent table so naturally it won't compile.
    If you really want to do this you should put the insert into an execute immediate statement as well. However, I recommend that you don't do this - it is very bad practice to put this sort of processing in the exception handler. Why? Well, what happens if the table T_CALLING already exists? The exception's got no where to go, so your program fails with an Unhandled Exception error.
    HTH, APC

  • HT1386 I have synced the items from itunes to an iphone 4 without problem, except the two albums I just purchased did not sync.  They show up on the itunes on my desktop and on my ipod, but not on the new iphone.  What do I need to do?

    I have an itunes account and an ipod, and when I purchased 2 albums on the computer they synced straight to the ipod.  I bought an iphone and used the usb cord from the computer to it to sync the itunes albums to the new phone.  Everything transfered, and those were albums I had uploaded (not purchased from the itunes store), except the two albmus I just purchased from the itunes store.  They appear on my itunes on the computer and ipod, but not on the iphone.  What did I fail to do or did I do incorrectly?

    This might sound weird, but here's an idea which worked for me re music that was newly added to itunes and showed up in my ipod but wouldn't play - I simply played the tracks in itunes first, just a second of time or so will do it, not the whole track, then connect the ipod and sync again and this time they played - hope this helps.

  • Please help me to merge two places.sqlite to get my old and New history at the same time, every time i rename my two places.sqlite to see my old and new history

    every time i rename my new places.sqlite to see my old history and come back rename old places.sqlite to see my new history, i tired and i found No Way to merge two places.sqlite :( but it's must be found this way for The PPL to see their old and new history :(
    Thank You all in Advance

    You can't merge history otherwise then using Sync to store the history and bookmarks of one places.sqlite on the Sync server and then disconnect.<br />
    Copy the second places.sqlite file to your Firefox profile folder with Firefox closed.
    Then setup Sync once again using that account and merge the content on the Sync server with your computer.
    * Merge this device's data with my Sync data

  • I have .me and .mac email accounts on my iPhone 4. I thought I had successfully transitioned from MobileMe to iCloud, but something must be wrong. iCloud seems to work fine on my computer and, with the exception of two email accounts, seems to be fine on

    I have .me and .mac email accounts on my iPhone 4. I thought I had successfully transitioned from MobileMe to iCloud, but something must be wrong. iCloud seems to work fine on my computer and, with the exception of two email accounts, seems to be fine on my phone. Can/should I delete the accounts on my phone and start over? It is somewhat of a nuisance to have two email accounts and double the amount of emails. The only thing different about the two iCloud accounts is the email addresses. Thanks.

    Well, seems I managed to unscrew this...I deleted my iCloud mail account and reinstalled it on my phone. That got rid of the duplicate .me/.mac email accounts.

  • Need help in insert statment query

    Hi,
    I have a table T1 with values like
    col1
    1
    2
    3
    4
    I need to write insert statment for t2 as
    insert into t2(col1,col2) values ('AA',select col1 from t1);
    The output of T2 should be
    col1 col2
    AA 1
    AA 2
    AA 3
    AA 4
    Any help in modifying the query.
    Ashish

    What is wrong with this?
    INSERT INTO id_own_dw.id_t_dw_org_dq_tgt
           (cost_center_cod_vc_old,
            cost_center_cod_vc_new
         SELECT '3016052',<<<_-- this you can replace with your varibale in pl/sql block
                cost_center_cod_vc
           FROM id_own_dw.id_t_dw_msl_org_cctr2mkdiv
          WHERE busi_unit_cod_vc = '3016496'

  • NO internet in the network except for two computers after installing ASA 5505

    Hi Guys,,,
    I dont know if any of you guys had a problem like this... I installed a CISCO ASA5505 with 50 user license  to my network as the gateway firewall. So ASA is acting as the gaeway router which is connected to a fibre circuit and also it gives DHCP to the network. The strange thing is that except for two computers rest does not have internet. I also have an asterisk phone system which works fine..
    I tried everything.... static IP's DHCP, DNS nothing worked. But strange enough two computers works fine and have internet.. but are no special computers. One is Win XP and the other one is Win7. When I troubleshoot the problem in win 7 on one of the computers it says
    "The remote device or resource won't accept the connection"
    I have no idea now... any help would be great...
    Thanks in advance

    Hello Amal.
    I hope the gateway of the comupters are configured as ASA.. Are you able to ping your gateway from the PC where you dont have access to internet and also check whether the translation is happening on ASA when you are trying to access the internet ( show xlate  | i 'local ip'
    It would be great if you could share the ASA config as well
    regards
    Harish.

  • Using 'dbms_obfuscation_toolkit.md5' in my insert statment itself

    Hi all,
    I am trying to use 'dbms_obfuscation_toolkit.md5' in my insert statment itself as : insert into TEST_USERS values('username', dbms_obfuscation_toolkit.md5('password'));
    But i get this : ORA-06553: PLS-307: too many declarations of 'MD5' match
    Can you please help me on how can i insert a string (not raw) as MD5 hash to a table???
    The password column i have is 'varchar(20)'. I dont mind changing it to something else. I am also struggling to find this package definition/help, to check what db type this function returns :-)
    Thanks for the help.

    Hello,
    Try posting this to the General Database Discussions forum.
    This forum is for SQLJ & JDBC.

  • Finished DVD Momentarily Hangs In Two Places

    I have created a 33 minute slide show in Aperture 3. The show is very good quality but it hangs in two places on the burned DVD. Have dragged plist to trash, exported again, burned disk appromimately 7 times, and each time I get the same thing. It hung one time when I burned the movie using iMovie HD6. I assume from this that my problem is iDVD. Any suggestions? Has anybody else experienced these hangs in iDVD

    It's good to know that other's are having the same issue. I recently upgraded to the Quad Core iMac with Snow Leopard. Previously I was using a 24"iMac with just Leopard where I was not experiencing the issue.
    I have a similar work flow to creating motion DVD's. I create a 25 - 30 minute slideshow with audio tracks in fotomagico then export as Quicktime .MOV file then drag into iDVD to create menu and burn to DVD. When I play this disc back in DVD player connected to TV there is a pause around half way where the entire slideshow including audio stops for about 3 seconds, then another pause towards the end of the slide show. The same disc played back in the iMac plays perfectly.I have tried reducing burn speeds right down to 1x but this did not solve the issue. Oddly the pause location changed depending on which burn speed I used. I also have a Mac Book Pro with Leopard, (not Snow Leopard) which burns the same project file with no issues when played back on the non computer DVD player. This makes me think it is an operating system issue. I have spent quite a few hours on the phone to Apple and reinstalled operating system, tried burning through different users, tried different quicktime export options, all totalling around 20 different burns and viewings to look for rectifications or errors! That's a lot of my valuable time wasted! If you hear of a solution be sure to post it up! In the meantime I am having to burn my work on the laptop which is not so practical but the only solution I can reliably count on.

  • Exception has occurred during data insertion ... Wrong number of parameters

    I am using an ADO dataflow source and an ADO dataflow destination to move data from a table on an IBM iSeries DB2 database to another IBM iSeries DB2 database on another machine.  The connection managers for source and destination both use .Net Providers\Odbc
    Data Provider with the Data Source Specification being ODBC connections specified on the Windows Server 2008 r2 machine hosting bids.  All the test connections work...so far so good.
    Issue is when I execute the control flow task the rows get picked up from the source DB2 database no problem but it fails on the insert to the destination DB2 table...The progress tab specifies the exceptions...
    [ADO NET Destination [601]] Error: An exception has occurred during data insertion, the message returned from the provider is: ERROR [07002] [IBM][System i Access ODBC Driver]Wrong number of parameters.
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "ADO NET Destination" (601) failed with error code 0xC020844B while processing input "ADO NET Destination Input" (604). The identified
    component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the
    failure.
    I put a data viewer on the data flow connection and the records I expect are  getting picked up and look ok. I checked to make sure the source and destination tables have the same number of columns in their record layout and identical data
    types and they look fine.
    Could someone kindly tell me whats going wrong?  Does the error message indicate that some of the columns are getting dropped from the dataset before the insert?
    Thanks much in advance for any help, Roscoe

    Hi Roscoe,
    Glad to hear that you have found the root cause. So, the issue occurs because numeric values with no decimal cannot be inserted into the Decimal data type column in the DB2 table. In SSIS, data type Decimal of DB2 database is mapped to data type DT_NUMERIC.
    To address the issue, you can do a data conversion for the column in question to define its precision and scale such as DT_NUMERIC(9,2) by using the Data Conversion Transformation before the ADO NET Destination.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • How to use my logic sessions and ilok at two places

    Hi there,
    I am wondering if I can use my Logic sessions and even my ilok plugins at two places, two countries?
    - but still keeping my ilok at one place.
    Is there any way via internet? perhaps using some kind of network server for my sessions
    - iDisk perhaps?
    what is the best solution?
    Thanks
    Message was edited by: Olavur
    Message was edited by: Olavur

    Buy a second iLok, and licenses for your software

  • Round decimal number to two places

    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.
    -tried using math.round but it only rounds to nearest integer
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to double
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?
    any advice is appreciated:)

    coynerm wrote:
    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.Agree.
    -tried using math.round but it only rounds to nearest integerI advise against rounding in most newbie situations. Usually it's the display of the variable you want to change.
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to doubleOf course cast won't allow you to convert back. If you wanted to do that you'd use Double.parseDouble(stringVar); But we don't know why you are doing all this converting in the first place.
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?Advice: Forgetting all this fooha with rounding, what in essence are you trying to achieve? Why all of this number manipulation in the first place? It will affect what should be the best answer.

  • Two places to input encryption key alias in WS Security proxy wizard?

    Hi,
    When you secure a Web Service Proxy in JDeveloper you can input encryption key alias in the Encrypt tab and in the Keystore Path tab. I don't understand why there are two places for this. Anybody know why?
    Screen dumps:
    http://i16.tinypic.com/63tp2pw.jpg
    http://i10.tinypic.com/4tpmc0h.jpg
    Regards Pete
    Message was edited by:
    the heat
    Message was edited by:
    the heat
    Message was edited by:
    the heat

    Hi,
    check http://www.oracle.com/technology/products/jdev/howtos/1013/wssecure/10gwssecurity_howto.html
    this should have some answers for you
    Frank

  • Why two places for videos? (N95 8gb)

    Why do i have two places for videos?
    If I bluetooth myself a video and save it it goes into gallery. What if I want it in My Videos instead how do I move it? And i only want to see the video in My Videos and not in the gallery as well?
    Also when I do a memory search it doesnt show the videos in My Videos up..
    P.S what does the little sheild mean next to some videos?

    07-Jan-2008 04:07 PM
    liam182 wrote:
    Why do i have two places for videos?
    If I bluetooth myself a video and save it it goes into gallery. What if I want it in My Videos instead how do I move it? And i only want to see the video in My Videos and not in the gallery as well?
    Also when I do a memory search it doesnt show the videos in My Videos up..
    P.S what does the little sheild mean next to some videos?
    There's a program called "File Manager" that lets you move/copy and delete files from your device. It's usually under Tools.
    If you put videos in "My Videos" folder I think they don't show up in the Gallery. Also files in "Videos" don't show up in Video Center but they do in the Gallery.
    What do you mean "memory search"?,
    About the little shield, I have no idea what it means. I guess it's about the DRM protection, but I'm not 100% sure.
    640K Should be enough for everybody
    El_Loco Nokia Video Blog

  • Getting the JAXB exception like "Two classes have the same XML type name-"

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

Maybe you are looking for

  • How to load a client file in a clob using sqlcl

    How to load a client file in a clob using sqlcl

  • Which monitor to buy for the ATI Radeon 9800 Pro w/256MB?

    Has anyone successfully hooked an LCD through the DVI port at a resolution other than the 1920x1200 max resolution stated on the ATI box? Would a native resolution of 1680x1050 work with this card? I was thinking about getting the Gateway FPD2185W mo

  • No BB logo

    There is no Blackberry logo beside 3G on my Blackberry Q5 when I am connected with my data plan, but when I connect to Wi-Fi BB logo appears. I have a data connection (3G is uppercase).

  • Moving event final cut pro X

    Hi, Does anyobody know how to event and projects to another computer in FCP X. I've tried to copy all of my media files, events and projects directory to an external harddrive and use it in another computer. But when I opened it in another computer,

  • Problem in adding custom metada properties

    Hi All, I want to add some custom properties while creating a document in KM repository. I am getting problem while adding the custom group in the property structure "all_groups"... This is waht i have done so far, 1) I created the custom metadata pr