ExecuteNonQuery doesnt return number of rows affected when used with PL/SQL

ExecuteNonQuery doesn't return number of rows affected when used with PL/SQL but returns -1. The documentation says ExecuteNonQuery method of OracleCommand returns the number of raws affected but when used with PL/SQL, it returns -1 even the update statement successfully executes and affects multiple records with no exeptions thrown.
However, if ExecuteNonQuery is used with update sql statement in the asp.net code it returns number of rows affected correctly. Does anybody know why ExecuteNonQuery behaves like this?
I am using ODP.NET that comes with Oracle Client 11g. The version is 2.111.6.20 of ODP.NET, Oracle database server is 10g.
Marat

You can get the rowcount in the stored procedure via SQL%ROWCOUNT and then pass it out as a parameter.
For example:
SQL> create or replace procedure updatesal(v_deptno in number, v_rowsaff out number) as
  2  begin
  3  update emp set sal = sal * 5 where deptno = v_deptno;
  4  v_rowsaff := SQL%ROWCOUNT;
  5  end;
  6  /
Procedure created.Cheers

Similar Messages

  • Get the number of rows affected by update statement

    Hi
    I'm working on an application that uses OCI as interface against an Oracle database.
    I'm trying to find out how i can get the number of rows affected by a query executed with OCIStmtExecute. it is not a select query.
    Best regards,
    Benny Tordrup

    If I run a bulk UPDATE query using OCIBindArrayOfStruct, is there a way I can tell which+ rows successfully updated?
    I have a file of records of which 75% of PKs are already in the table and will be updated, the other 25% aren't and should be inserted later. I want to attempt an UPDATE statement using OCIBindArrayOfStruct to execute in bulk and then check which entries in my bulk array successfully updated. If an array entry isn't successfully updated then I will assume it should be inserted and will store it for a Direct Path load later.
    Many thanks for any advice you can give as I've been trawling through the docs trying to find a solution for ages now.

  • Wrong number of parameters exception when using PreparedStatement

    Hi,
    I'm getting Wrong number of parameters exception when using a prepared statement. It's very weird. The code is:
    sqlstmt="update blah1 set blah2=? where blah3=?";
    myps = Conn.prepareStatement(sqlstmt);
    myps.setString(1, p1);
    myps.setInt(2, p2);
    myps.executeUpdate(sqlstmt);
    The error is:
    SQLException: [IBM][CLI Driver] CLI0100E Wrong number of parameters. SQLSTATE=07001:07001
    Could someone please help? Thanks
    Mahdad

    Hi and thanks for the reply.
    Actually this is the try block...
    The variable's defintions are correct.
    PreparedStatement myps;
    try {
    sqlstmt="update blah1 set blah2=? where blah3=?";
    myps = Conn.prepareStatement(sqlstmt);
    myps.setString(1, blah4);
    myps.setInt(2, blah5);
    myps.executeUpdate(sqlstmt);
    catch (SQLException e) {
    System.out.println("SQLException: " + e.getMessage() + ":" + e.getSQLState());
    blah6++;

  • I have created a PDF with mp3 audio clips, the file works on PC's with audio playback (WIndows 7, 8 ) however the audio does not play when hosted on a website or an ipad/tablet computer or smart phone when used with PDF reader

    I have created a PDF with mp3 audio clips, the file works on PC's with audio playback (WIndows 7, 8 ) however the audio does not play when hosted on a website or an ipad/tablet computer or smart phone when used with PDF reader

    adobe42135678 wrote:
    the audio does not play when hosted on a website...
    When viewing in what browser?

  • How to hide system tables when using the Oracle SQL Developer?

    Hi,
    I would like to know how can I show only the tables that I created under the Tables tree? I didnt find a way to create a separate database using the Oracle Sql Developer. I see all the tables together, and would like to differentiate between different databases.
    Can anyone explain to me how to do these things?
    Thanks,

    Hi,
    I would like to know how can I show only the tables that I created under the Tables tree? Your posting is not clear,again tell something more on tables tree,what u want to achieve with it.
    How to hide system tables when using the Oracle SQL Developer? if u connected with sys, system or user with dba role then u have a privilege to see these tables,so revoke the privilege/role from ur user to view this tables if ur connected other then sys,system,
    I didnt find a way to create a separate database using the Oracle Sql Developer. DBCA is a tool for creating the new database.
    Kuljeet

  • Test runner freezing when used with Dynamics CRM (and other apps) - Both applications freeze and never come back...

    We are trying to use test runner with dynamics CRM.
    MS Dynamics CRM will freeze and will not respond (even after 10 - 15 minutes). When this happens, the test manager will either freeze or a message will apear saying "waiting for application under test".
    We are not recording action recordings...This makes using test manager impossible. It happens consistently, starting with slowing the PC down (mouse moving slowly, slow to load in new screens, drop downs etc) eventually leading to the app freezing.
    Tried on windows xp, windows 7 etc on various specs of pcs.

    I am experiencing this same issue with
    Test runner freezing when used with Dynamics CRM. I notice this was first posted in June of 2010 and so far no
    resolution? I was wondering if it could be related to memory issues? Do you have any troubleshooting ideas? The
    issue for me seems to be sporadic and I can't
    reproduce it every time.
    The message I get is "waiting on application under test".
    DLM

  • Quicktime Player with the magic mouse, when used with a bug -

    On 10.7 Lion, Quicktime Player with the magic mouse, when used with a bug …
    Quicktime Player will not respond, but use the USB mouse with no problem

    Message was edited by: b j t

  • Correct Way to use Bind variables when using an MS SQL server backend

    Hey,
    I'm having some trouble figuring out how to use bind variables in a view when using an MS SQL server backend. For some reason when I'm using an ApplicationModule that has a MS SQL Server JDBC library loaded and I attempt to click OK when editing the following query:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = :1
    I get an error stating that "SQL Query Error Message Incorrect Syntax near ':'". Is JDeveloper compatible with SQL server for bind variables because this query runs just fine if I replace the :1 with a say "Testing testing".
    Thanks in advance
    Edited by: NullCheck on Dec 15, 2010 2:06 PM

    Gotcha. I had tried %1% %0% ?0 and ?1 and various other permutations none of which worked. Got it working by setting the query to:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = ?
    ORDER BY kit_status
    And then adding a bind variable with "Bind position" set to 0.
    Thanks again Shay!

  • Msi x99 gaming 9 ack does not detect capture card when using with xsplit

    msi x99 gaming 9 ack does not detect capture card when using with xsplit
    i install every but still it does not work.

    Hi
    It wasn't hard to find your motherboard version:
    http://www.msi.com/support/mb/Z68AGD80_B3.html#down-bios
    Since your BIOS is v20.1, it couldn't be G3 
    Apart from checking BIOS, you can only check motherboard or moth...

  • Camera is hanging when using with flash

    Hi Lenovo Team,
    In lenovo vibe x2, camera is hanging when using with flash.Getting "Lenovo snapit isnt responding" error and screen hanged for sometime.after that when tried to open camera "Cannt cannot to camera " error is coming till when restart the phone.
    Even tried Factory reset and software update.
    Please provide the solution for the above issue.
    Thanks,

    Hi vijayprabhu,
    I just tested the X2 however am not having the issue. I set flash to always on then took a picture using SnapIt however its fine.
    Please check if you have the latest firmware S125.
    Check out the Community Knowledge Base for hints and tips.
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"!
    X240 | 8GB RAM | 512GB Samsung SSD

  • Need to retrieve number of rows affected by SQL query

    Hi,
    I am executing some update queries in SQL in a xMII transaction. Iam using a SQL Query template for the same and I need to find out how many records were affected by the last executed statement. I have tried doing SELECT @@ROWCOUNT in a second SQL template that executes after the UPDATE SQL Query Template. However, the results are intermittent, sometimes it returns 1 row affected as expected but sometimes returns 0 rows. Can anyone help on this.
    Thanks

    Anamika,
    1) As per sql best practices use of trigger is not recommend unless you don't have any other option because usually triggers consume more resources and IO since it involves internal monitoring.
    2) @@ROWCOUNT should go in same SQL session where you are performing update to identify rows affected else as you said earlier your results will not be accurate
    3) The other alternative is to create a Stored Procedure but it again boils down to your authorization issue. This would be easier and better if you have authorization to create SP's. But nevertheless give it a try.
    4) Lets forget about SP say that you have an Update Statement like
    Update Table1 set column2 = 'abc' where Column2 = 'xyz'
    In this case it is evident that you know what you are passing into the Where clause and to what table hence its obvious that you also know how many rows will be affected by using query,
    Select count(*) from Table1 where Column2 = 'abc'
    The @@ROWCOUNT is powerful within t-sql with SP, cursors etc..
    Hope this helps!!
    Regards,
    Adarsh

  • How to return the correct row of data using diffferent conditions?

    I am having some problems with an sql query and I hope someone can help please?
    The data I am using is customers with multiple transactions. If a customer contains one transaction where the transaction type = 'W' then I need to set the output value to be transaction.ValueA. If the customer does not contain any transactions where the transaction type is 'W' then I need to set the output value to be
    the most recent transaction.ValueB where transaction.transaction_date <= customer.cust_mod_date.
    Here is an example of the data. For each test customer 10 and 20 I have put a star against the value I want to return
    CUSTOMER_ID CUST_MOD_DATE TX_DATE      TX_TYPE TX_VALUEA TX_VALUEB
    10          15/07/2009 16/07/2009     A     110      95
    10          15/07/2009 14/07/2009     A     100      90(*)          
    10          15/07/2009 13/07/2009     A     90          10
    10          15/07/2009 12/07/2009     A     80          5
    20          15/07/2009 15/07/2009     A     60          10
    20          15/07/2009 14/07/2009     W     50(*)     20
    20          15/07/2009 13/07/2009     A     40          30
    ie
    CREATE TABLE
    TMP_CUSTOMER (CUSTOMER_ID NUMBER, CUST_MOD_DATE DATE);
    insert into tmp_customer
    values(10, to_date('15/07/2009','dd/mm/yyyy'));
    insert into tmp_customer
    values(20, to_date('15/07/2009','dd/mm/yyyy'));
    CREATE TABLE
    TMP_TRANSACTION (TX_ID NUMBER, CUSTOMER_ID NUMBER, TX_DATE DATE, TX_TYPE VARCHAR2(1), TX_VALUEA NUMBER, TX_VALUEB NUMBER);
    INSERT INTO TMP_TRANSACTION
    VALUES (1,10, to_date('16/07/2009','dd/mm/yyyy'),'A',110,95);
    INSERT INTO TMP_TRANSACTION
    VALUES (2,10, to_date('14/07/2009','dd/mm/yyyy'),'A',100,90);
    INSERT INTO TMP_TRANSACTION
    VALUES (3,10, to_date('13/07/2009','dd/mm/yyyy'),'A',90,10);
    INSERT INTO TMP_TRANSACTION
    VALUES (4,10, to_date('12/07/2009','dd/mm/yyyy'),'A',80,5);
    INSERT INTO TMP_TRANSACTION
    VALUES (5,20, to_date('15/07/2009','dd/mm/yyyy'),'A',60,10);
    INSERT INTO TMP_TRANSACTION
    VALUES (6,20, to_date('14/07/2009','dd/mm/yyyy'),'W',50,20);
    INSERT INTO TMP_TRANSACTION
    VALUES (7,20, to_date('13/07/2009','dd/mm/yyyy'),'A',40,30);
    The query I have so far is
    (SELECT CUSTOMER_ID, CUST_MOD_DATE, TX_DATE, TYPE_FLAG, TX_VALUEA, TX_VALUEB, RN
    FROM (SELECT CUST.CUSTOMER_ID, CUST.CUST_MOD_DATE,TRANS.TX_DATE, TRANS.TYPE_FLAG, TRANS.TX_VALUEA,TRANS.TX_VALUEB,
    ROW_NUMBER() OVER (partition BY TRANS.CUSTOMER_ID ORDER BY TRANS.TX_DATE DESC) RN
    FROM TMP_CUSTOMER CUST,
    --- Return all transactions creating a type_flag field where Y = type W, else N ---
    SELECT CUST.CUSTOMER_ID, TX.TX_DATE, TX.TX_VALUEA, TX.TX_VALUEB, CUST.CUST_MOD_DATE, TX.TX_TYPE,
    CASE WHEN NVL(TX.TX_TYPE,'0') <> 'W' THEN 'N'
    WHEN NVL(TX.TX_TYPE,'0') = 'W' THEN 'Y'
    ELSE 'N'
    END AS TYPE_FLAG
    FROM TMP_TRANSACTION TX, TMP_CUSTOMER CUST
    WHERE TX.CUSTOMER_ID = CUST.CUSTOMER_ID
    AND CUST.CUSTOMER_ID in
    '10','20'
    ) TRANS
    WHERE CUST.CUSTOMER_ID = TRANS.CUSTOMER_ID
    --AND   TRANS.TX_DATE <= CUST.CUST_MOD_DATE
    AND CUST.CUSTOMER_ID in
    ('10','20'
    Can anyone please help with how I extract the record I am looking for
    ie customer 10 has amount 90
    customer 20 has amount 50.
    Thanks :-)
    GB

    SQL> select c_id
      2  ,      cust_mod_date
      3  ,      tx_date
      4  ,      tx_type
      5  ,      tx_valuea
      6  ,      tx_valueb
      7  from ( select c.customer_id c_id
      8         ,      c.cust_mod_date
      9         ,      t.tx_date
    10         ,      t.tx_type
    11         ,      t.tx_valuea
    12         ,      t.tx_valueb
    13         ,      row_number() over (partition by c.customer_id order by t.customer_id, t.tx_date desc) rn
    14         from   tmp_customer c
    15         ,      tmp_transaction t
    16         where  t.customer_id = c.customer_id     
    17         and    t.tx_date <= c.cust_mod_date
    18       )
    19  where case
    20          when tx_type = 'W' then 1
    21          when rn = 1
    22          and  not exists ( select null
    23                            from   tmp_transaction t2
    24                            where  t2.customer_id = c_id
    25                            and    t2.tx_type = 'W'
    26                          )
    27          then 1
    28        end = 1;
          C_ID CUST_MOD_ TX_DATE   T  TX_VALUEA  TX_VALUEB
            10 15-JUL-09 14-JUL-09 A        100         90
            20 15-JUL-09 14-JUL-09 W         50         20
    2 rows selected.

  • Cannot return data in Discoverer report when using specific AR tables/views

    When using any of the following tables (logged in as Administrator responsibility), I get no data returned...
    AR_RECEIVABLE_APPLICATIONS
    AR_PAYMENT_SCHEDULES
    RA_CUSTOMER_TRX
    RA_CUSTOMER_TRX_ALL
    When running in TOAD or SQL Plus, I have to set my Org ID to return data. It was my assumption that the security calls would automatically do that in Discoverer when setup as an APPS mode EUL. Discoverer 10g is the version.
    Pulling anything from any of those tables results in no rows returned in Discoverer. Is there a special security call I must make in the SQL?

    Also you should try another thing.
    If you brose data only from AR.RA_CUSTOMER_TRX_ALL do you get any data?
    From the 4 "tables" you mentioned this is the only TABLE while all other are views with security mechanism in it.
    In the finance the system administrator is not defined so that it will see the whole data, you need to log in using a proper responsibility.
    If you already have the sys admin then open the application and add to yourself AR responsibilities such as "%AR Manager", "%AR Superuser" .
    After that you can log in with those responsibilities and you'll get the data.

  • Can we get row counts when using dbms_datapump?

    When using dbms_datapump, is there a way to get the rows loaded for each table, similar to the log files when using the command line? I can't seem to find anything. I'm trying to import. Database is 10g r2.

    if you don't have to use DBMS_DATAPUMP and can use external tables for the import (both work exactly same way), then you can use ROWCOUNT
    INSERT INTO MYTABLE SELECT * FROM EXTERNALTABLE;
    v_number_of_rows := SQL%ROWCOUNT ;
    COMMIT;
    if you have to use DBMS_DATAPUMP then look at "worker status types" in this document
    http://www.stanford.edu/dept/itss/docs/oracle/10gR2/appdev.102/b14258/d_datpmp.htm#i997417

  • How can I change the default number for a contact when using Siri

    My husband has one mobile for work, one for home, both are in my favorites. When i'd ask Siri to dial his number, it would always ask me which one to use. Recently when calling him Siri asked if I would like to use his work number as the default and I mistakenly agreed. Now Siri never asks which number to dial and always dials the work number. How can I change that? I would like to make the default the home number.

    Thanks all for your responses.
    I tried to "order" Siri to change my husband's default number and whatever syntax I used for my request Siri responded with a web search on how to set favorites.
    So I ended up deleting the work number from my husband's contact information and I used Siri to call him a couple of times. After 24 hours (random time frame) I added his work mobile back to his contact information, but not in the favorites.
    SIri now dials his home number because it's the only one in the favorites.
    I'll add it to the favorites in due course.

Maybe you are looking for

  • Do I need my Airport Extreme with my Comcast router?

    Hi all, I have an Airport Extreme - it's about four years old. I also have Comcast Xfinity, but will likely switch to the business service - 75mb down, 15mb up. I just bought a Mini to use as a server for our home and business use.  Here's my questio

  • How do i upload a photo from iPhoto to twitter?

    hi peeps, wonder if anyone can help...i have been trying to upload a pic from iphoto to twitter and it wont let me, the twitter icon is not able to be selected. I have tried deleting my twitter info from preferences and re inputting it but that didnt

  • Freecraft - Installation problem

    Hello, I am trying to install freecraft (a game available on debian). Therefore, I downloaded the source (from the debian site, freecraft and fcmp packages) and make a "./setup", answer some questions and compilation starts. The problem is that it ge

  • MacBook Pro: 512MB enough?

    Greetings! I'm about to place my order for my MacBook Pro. I decided I wanted the base MBP because it's cheaper, and that gives me some room to buy an SSD and some RAM to upgrade it. My question is: Will the NVIDIA 650M 512MB be enough for everyday t

  • Sorting problem PLZ Hellp Me

    hi all i had a problem to be solved but i am unable to get any idea on it my problem is i had some directiories with names as MONYEAR i.e JAN2004,SEP2004,AUG2004 ,JUL2004 etc............. these dirs are created programetically for storing that pertic