Understanding Rowcount

I want to write a store procedure that will insert data into a table, it will automatically increment a ID number.
The first test is to check if the table is empty if it is the first ID is set to 100.
The problem is testing that no rows are returned.
In the following code even though the table is empty rowcount returns 1.
here is my code:
CREATE OR REPLACE procedure INSERTINTOEMPLOYEE(empName IN varchar2, rt IN NUMBER)
IS
BEGIN
     DECLARE
     emID NUMBER;
     cursor empcursor IS select max(EMPID)from RedKiteEMPLOYEE;
     BEGIN
     OPEN empcursor;
FETCH empcursor INTO emID;
          dbms_output.put_line('empcursor%ROWCOUNT '|| empcursor%ROWCOUNT);
          IF empcursor%ROWCOUNT= 0 THEN
               dbms_output.put_line('0 rows returned');
               INSERT INTO RedKiteEMPLOYEE values (100,empName,rt);
     ELSE
     dbms_output.put_line('1 row returned');
               emID := emID+1;
               INSERT INTO RedKiteEMPLOYEE values (emID,empName,rt);
     END IF;
     END;
END;
Thanks for any help I though rowcount returns 0 if no rows are returned.
Tony

You are doing things the hard way. The traditional method is to create a sequence then create a trigger that automatically inserts the next value of that sequence. You can then insert using a simple insert statement from SQL*Plus or using a simple procedure that does the insert. Please see the example below.
scott@ORA92> -- table:
scott@ORA92> CREATE TABLE RedKiteEmployee
  2    (empid     NUMBER,
  3       empname VARCHAR2(15),
  4       rt     NUMBER)
  5  /
Table created.
scott@ORA92> -- sequence starting with 100:
scott@ORA92> CREATE SEQUENCE RedKiteEmployee_empid_seq
  2  START WITH 100
  3  /
Sequence created.
scott@ORA92> -- trigger:
scott@ORA92> CREATE OR REPLACE TRIGGER RedKiteEmployee_empid_trigger
  2    BEFORE INSERT ON RedKiteEmployee
  3    FOR EACH ROW
  4  BEGIN
  5    SELECT RedKiteEmployee_empid_seq.NEXTVAL
  6    INTO   :NEW.empid
  7    FROM   DUAL;
  8  END RedKiteEmployee_empid_trigger;
  9  /
Trigger created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- procedure:
scott@ORA92> CREATE OR REPLACE procedure InsertIntoEmployee
  2    (p_empName IN RedKiteEmployee.empName%TYPE,
  3       p_rt       IN RedKiteEmployee.rt%TYPE)
  4  IS
  5  BEGIN
  6    INSERT INTO RedKiteEmployee (empname, rt)
  7    VALUES (p_empName, p_rt);
  8  END InsertIntoEmployee;
  9  /
Procedure created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- insert with procedure:
scott@ORA92> EXECUTE InsertIntoEmployee ('Tony', 1)
PL/SQL procedure successfully completed.
scott@ORA92> -- insert without procedure:
scott@ORA92> INSERT INTO RedKiteEmployee (empname, rt) VALUES ('Barbara', 2)
  2  /
1 row created.
scott@ORA92> -- results:
scott@ORA92> SELECT * FROM RedKiteEmployee
  2  /
     EMPID EMPNAME                 RT
       100 Tony                     1
       101 Barbara                  2

Similar Messages

  • Hello, World - trying to understand the steps

    Hello, Experts!
    I am pretty new to Flash Development, so I am trying to understand how to implement the following steps using Flash environment
    http://pdfdevjunkie.host.adobe.com/00_helloWorld.shtml         
    Step 1: Create the top level object. Use a "Module" rather than an "Application" and implement the "acrobat.collection.INavigator" interface. The INavigator interface enables the initial hand shake with the Acrobat ActionScript API. Its only member is the set host function, which your application implements. During the initialize cycle, the Acrobat ActionScript API invokes your set host function. Your set host function then initializes itself, can add event listeners, and performs other setup tasks.Your code might look something like this.
    <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" implements="acrobat.collection.INavigator" height="100%" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    Step 2: Create your user interface elements. In this example, I'm using a "DataGrid" which is overkill for a simple list but I'm going to expand on this example in the future. Also notice that I'm using "fileName" in the dataField. The "fileName" is a property of an item in the PDF Portfolio "items" collection. Later when we set the dataProvider of the DataGrid, the grid will fill with the fileNames of the files in the Portfolio.
    <mx:DataGrid id="itemList" initialize="onInitialize()" width="350" rowCount="12"> <mx:columns> <mx:DataGridColumn dataField="fileName" headerText="Name"/> </mx:columns> </mx:DataGrid>
    Step 3: Respond to the "initialize" event during the creation of your interface components. This is important because there is no coordination of the Flash Player's initialization of your UI components and the set host(), so these two important milestone events in your Navigator's startup phase could occur in either order. The gist of a good way to handler this race condition is to have both your INavigator.set host() implementation and your initialize() or creationComplete() handler both funnel into a common function that starts interacting with the collection only after you have a non-null host and an initialized UI. You'll see in the code samples below and in step 4, both events funnel into the "startEverything()" function. I'll duscuss that function in the 5th step.
                   private function onInitialize():void { _listInitialized = true; startEverything(); }

    Hello, Experts!
    I am pretty new to Flash Development, so I am trying to understand how to implement the following steps using Flash environment
    http://pdfdevjunkie.host.adobe.com/00_helloWorld.shtml         
    Step 1: Create the top level object. Use a "Module" rather than an "Application" and implement the "acrobat.collection.INavigator" interface. The INavigator interface enables the initial hand shake with the Acrobat ActionScript API. Its only member is the set host function, which your application implements. During the initialize cycle, the Acrobat ActionScript API invokes your set host function. Your set host function then initializes itself, can add event listeners, and performs other setup tasks.Your code might look something like this.
    <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" implements="acrobat.collection.INavigator" height="100%" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    Step 2: Create your user interface elements. In this example, I'm using a "DataGrid" which is overkill for a simple list but I'm going to expand on this example in the future. Also notice that I'm using "fileName" in the dataField. The "fileName" is a property of an item in the PDF Portfolio "items" collection. Later when we set the dataProvider of the DataGrid, the grid will fill with the fileNames of the files in the Portfolio.
    <mx:DataGrid id="itemList" initialize="onInitialize()" width="350" rowCount="12"> <mx:columns> <mx:DataGridColumn dataField="fileName" headerText="Name"/> </mx:columns> </mx:DataGrid>
    Step 3: Respond to the "initialize" event during the creation of your interface components. This is important because there is no coordination of the Flash Player's initialization of your UI components and the set host(), so these two important milestone events in your Navigator's startup phase could occur in either order. The gist of a good way to handler this race condition is to have both your INavigator.set host() implementation and your initialize() or creationComplete() handler both funnel into a common function that starts interacting with the collection only after you have a non-null host and an initialized UI. You'll see in the code samples below and in step 4, both events funnel into the "startEverything()" function. I'll duscuss that function in the 5th step.
                   private function onInitialize():void { _listInitialized = true; startEverything(); }

  • Urgent help required to make variableRowHeight & rowCount work hand in hand for a Datagrid

    HI,
    I am using variableRowHeight property on a datagrid to wrap the text and this works perfectly.
    At the same time, I have to assign rowCount dynamically. My logic for caluculating rowCount is rowcount = sampleData.length > 5 ? 5:sampleData.length; where sampleData is my ArrayCollection. The caluculation happens correctly.
    The issue here is rows of the datagrid do not show correctly.
    From the post http://forums.adobe.com/message/2350643#2350643 I understood that both variableRowHeight & rowCount do not work hand in hand.
    So, I tried removing variableRowHeight and it works fine. The solution says using measureHeightOfItems and viewMetrics to calculate the height may solve the issue. I did not understand it very clearly.
    Can anyone let me know the solution with example.
    Thnaks
    Code
    =========
    <?xml version="1.0"?><mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" xmlns:itemren="
    com.itemren.*">
     <mx:Script>
    <![CDATA[
     import mx.rpc.events.FaultEvent; 
    import mx.rpc.events.ResultEvent; 
    import com.vo.HeaderVO; 
    import com.vo.DataVO; 
    import mx.utils.ObjectUtil; 
    import mx.collections.IViewCursor; 
    import mx.controls.Alert; 
    import mx.collections.ArrayCollection; 
    Bindable] 
    public static var sampleData:ArrayCollection = new ArrayCollection (); 
    Bindable] 
    public var rowcount:int; 
    public function init():void { 
    sampleData.addItem( { AssetNo :
    "234567890", AssetName : "Asset Name 1", Amount : "10000.02" } );sampleData.addItem( { AssetNo :
    "234567891", AssetName : "Asset Name 2", Amount :"2.04" } );sampleData.addItem( { AssetNo :
    "234567892", AssetName : "Asset Name 3", Amount : "4578.00" } );sampleData.addItem( { AssetNo :
    "234567893", AssetName : "Asset Name 4", Amount : "384.00" } );sampleData.addItem( { AssetNo :
    "234567894", AssetName : "Asset Name 5", Amount : "21454.20" } );sampleData.addItem( { AssetNo :
    "234567890", AssetName : "Asset Name 1", Amount : "10000.02" } );sampleData.addItem( { AssetNo :
    "234567891", AssetName : "Asset Name 2", Amount :"2.04" } );sampleData.addItem( { AssetNo :
    "234567892", AssetName : "Asset Name 3", Amount : "4578.00" } ); 
    trace ("sampleData.length ========= "+sampleData.length); 
    rowcount = sampleData.length > 5 ? 5:sampleData.length;
    trace("count is ==== "+rowcount); 
    dg.rowCount=rowcount;
    trace("dg.rowCount is === "+ObjectUtil.toString(dg.rowCount)); 
    dg.dataProvider=sampleData;
    ]]>
    </mx:Script>
     <mx:Panel title="POC for dynamic rowCount of datagrid" height="100%" width="100%" paddingTop="
    10" paddingLeft="10" paddingRight="10"> 
    <mx:DataGrid id="dg" width="50%" wordWrap="true" variableRowHeight="
    true">
     <mx:columns>
     <mx:DataGridColumn dataField="AssetNo" headerText="Asset No" paddingLeft="20" />
     <mx:DataGridColumn dataField="AssetName" headerText="Asset Name" paddingLeft="20"/>
     <mx:DataGridColumn dataField="Amount" headerText="Amount" paddingLeft="20"/>  
    </mx:columns>
     </mx:DataGrid>
     </mx:Panel>
     </mx:Application>

    Hi,
    have you checked your bindings not only for the WF --> Method, also for the Method --> WF?
    Christoph
    Of course I mean the bindings between Task and Method / Method and Task
    Edited by: Christoph Schle on Dec 21, 2007 11:05 AM

  • Can not understand why it is not working, plz help.

    I am a student trying to understand flex builder 3, but it is very hard and when something is going wrong I think that I will never undersand how is it working.
    Hete is my program and do not see a problem. Maybe someone could help me?
    MAIN APLICATION :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="left"
    xmlns:omp="components.*" themeColor="#444444"
    backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#686868, #111111]"
    initialize="klaseServ.send(),mokinysServ.send()"
    xmlns:comp="components.*">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable] private var klaseArray:ArrayCollection;
    [Bindable] private var mokinysArray:ArrayCollection;
    // PRIVATE -------------------------------------------------------------------------
    private function resultKl(event:ResultEvent):void{
    klaseArray=event.result.ROWSET.ROW;
    private function resultMo(event:ResultEvent):void{
    mokinysArray=event.result.ROWSET.ROW;
    // PUBLIC ---------------------------------------------------------------
    ]]>
    </mx:Script>
    <mx:HTTPService id="klaseServ"
    url="data/vkklase.xml"
    result="resultKl(event)" />
    <mx:HTTPService id="mokinysServ"
    url="data/vkmokinys.xml"
    result="resultMo(event)" />
    <mx:VBox x="0" y="0" width="100%" verticalGap="0">
    <mx:Canvas height="70" width="100%">
    <mx:Panel title="{horizontalList.selectedItem.PAVADINIMAS}"
    height="70" width="100%" layout="horizontal">
    <mx:HorizontalList id="horizontalList"
                        labelField="PAVADINIMAS"
                        dataProvider="{klaseArray}"
                        itemRenderer="icon"
                        columnCount="10"
                        columnWidth="30"
                        rowCount="1"
                        rowHeight="30"
                        horizontalScrollPolicy="on" />
    </mx:Panel>
    </mx:Canvas>
    <mx:VBox height="90" width="100%">
    <mx:Panel height="90" layout="horizontal" title="Asmuo" width="100%" backgroundAlpha="1.0">
    <mx:HorizontalList height="50" width="100%" dataProvider="mokinysArray"/>
    </mx:Panel>
    </mx:VBox>
    <mx:HBox height="15" color="#FFFFFF" width="100%" backgroundColor="#636161">
    <mx:Label id="vardasLab" text="Vardas" />
    <mx:Label id="pavardeLab" text="Pavardė" />
    <mx:Label id="amziusLab" text="Amžius" />
    </mx:HBox>
    <mx:HBox>
    <mx:VBox width="60" verticalGap="0">
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    <mx:Image source="icons/photoIco.jpg" height="60" width="60"/>
    </mx:VBox>
    <mx:Canvas>
    </mx:Canvas>
    </mx:HBox>
    </mx:VBox>
    </mx:Application>
    ICON.MXML
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2008/02/15/creating-a-simple-image-gallery-with-the-flex-hori zontallist-control/ -->
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
            horizontalAlign="center"
            verticalAlign="middle">
        <mx:Label text="{data.PAVADINIMAS}" />
        <mx:Label text="{data.KIEKMOKINIU}" />
    </mx:VBox>
    data/vkklase.xml
    <?xml  version="1.0" ?>
    - <ROWSET>
    - <ROW>
    <ID>2</ID>
    <PAVADINIMAS>7B</PAVADINIMAS>
    <KIEKMOKINIU>1</KIEKMOKINIU>
    </ROW>
    - <ROW>
    <ID>1</ID>
    <PAVADINIMAS>1A</PAVADINIMAS>
    <KIEKMOKINIU>2</KIEKMOKINIU>
    </ROW>
    - <ROW>
    <ID>3</ID>
    <PAVADINIMAS>7C</PAVADINIMAS>
    <KIEKMOKINIU>3</KIEKMOKINIU>
    </ROW>
    </ROWSET>
    data/vkmokinys.xml
    <?xml  version="1.0" ?>
    - <ROWSET>
    - <ROW>
    <ID>2</ID>
    <KLASE>1A</KLASE>
    <VARDAS>Paulius</VARDAS>
    <PAVARDE>Paulauskas</PAVARDE>
    <GIMMETAI>2002</GIMMETAI>
    <GIMMEN>12</GIMMEN>
    <GIMDIEN>20</GIMDIEN>
    </ROW>
    - <ROW>
    <ID>3</ID>
    <KLASE>1A</KLASE>
    <VARDAS>Saulius</VARDAS>
    <PAVARDE>Saulenas</PAVARDE>
    <GIMMETAI>2003</GIMMETAI>
    <GIMMEN>1</GIMMEN>
    <GIMDIEN>12</GIMDIEN>
    </ROW>
    - <ROW>
    <ID>1</ID>
    <KLASE>7B</KLASE>
    <VARDAS>Antanas</VARDAS>
    <PAVARDE>Antanavicius</PAVARDE>
    <GIMMETAI>1997</GIMMETAI>
    <GIMMEN>2</GIMMEN>
    <GIMDIEN>1</GIMDIEN>
    </ROW>
    - <ROW>
    <ID>5</ID>
    <KLASE>7C</KLASE>
    <VARDAS>Stasys</VARDAS>
    <PAVARDE>Stasevicius</PAVARDE>
    <GIMMETAI>1997</GIMMETAI>
    <GIMMEN>3</GIMMEN>
    <GIMDIEN>18</GIMDIEN>
    </ROW>
    - <ROW>
    <ID>6</ID>
    <KLASE>7C</KLASE>
    <VARDAS>Bronius</VARDAS>
    <PAVARDE>Broniavicius</PAVARDE>
    <GIMMETAI>1996</GIMMETAI>
    <GIMMEN>12</GIMMEN>
    <GIMDIEN>30</GIMDIEN>
    </ROW>
    - <ROW>
    <ID>4</ID>
    <KLASE>7C</KLASE>
    <VARDAS>Mantas</VARDAS>
    <PAVARDE>Mantavicius</PAVARDE>
    <GIMMETAI>1996</GIMMETAI>
    <GIMMEN>11</GIMMEN>
    <GIMDIEN>3</GIMDIEN>
    </ROW>
    </ROWSET>

    Something wrong with ITEMRENDERER.... I dont know what is wrong, but it is just isnt working when i try to compile.. =(

  • Cursor%ROWCOUNT

    I understand I can use cursor%ROWCOUNT to count the number of rows in a cursor. How do I have a loop that loop all the way till the cursor's rowcount is at its last row?

    for tha use cursor%NOTFOUND.
    Once you fetch you can check
    IF cursor%NOTFOUND THEN
    EXIT;
    END IF;
    rowcount cant be used to find the last record as it just a count that has how many records fetched till now from a cursor
    SQL> declare
      2     cursor c is select * from dual connect by level <= 5;
      3     l varchar2(1);
      4  begin
      5     open c;
      6     loop
      7             fetch c into l;
      8             dbms_output.put_line(c%rowcount);
      9             exit when c%notfound;
    10     end loop;
    11     close c;
    12  end;
    13  /
    1
    2
    3
    4
    5
    5
    PL/SQL procedure successfully completed.Thanks,
    Karthick.
    Edited by: Karthick_Arp on Sep 4, 2008 5:07 AM

  • REF Cursor Rowcount

    I need to get the rowcount for the refcursor before fetching the data itself.
    Please let me know how to get the same.
    Example:
    Open X FOR Query
    var:= x%rowcount
    Once this executed i am getting the value var is 0 but it's retriving some rows to java environment.

    PL/SQL 101 : Understanding Ref Cursors

  • Some code I don't understand

    Ok I know that the code below is a sql statement that is created as a string in a java program. What I don't understand is what the bolded portion is doing. I know that the + stands for concat in most case but I don't understand its purpose below. These items are declared as private strings what does that have to do with it?
    String sql = "select stddev_samp(enteredvalue) as stddev from (" +
    " select enteredvalue, " +
    " row_number() over (order by m1.u_calc_no desc) AS rowcount " +
    " from sdidataitem sd, s_sample s1, s_sample s2, u_melt m1, u_melt m2 "+
    " where s1.s_sampleid=sd.keyid1 " +
    " and sd.sdcid='Sample' " +
    " and s1.sampletypeid='" + sampletype + "' " +
    " and s1.samplestatus in ('Approved','Reported','Completed') " +
    " and sd.paramid='" + strIParamid + "' " +
    " and sd.paramtype='" + paramtype + "' " +
    " and sd.enteredvalue is not null " +
    " and s1.s_sampleid <> s2.s_sampleid " +
    " and s2.s_sampleid = '" + sampleid + "' " +
    " and s1.u_meltid = m1.u_meltid " +
    " and s2.u_meltid = m2.u_meltid " +
    " and m1.u_alloy_codeid = m2.u_alloy_codeid " +
    " and m1.u_calc_no < m2.u_calc_no " +
    " ) where rowcount<=50";+
    Message was edited by:
    Egyptgirl18

    If you were to rewrite the sql with proper indentation as shown below,
    what the sql statement is doing will be clearer for you.
    String sql =
    "select "+
    "stddev_samp(enteredvalue) as stddev "+
    "from ( " +
    "select "+
    "enteredvalue, " +
    "row_number() over (order by m1.u_calc_no desc) AS
    rowcount " +
    "from "+
    "sdidataitem sd, "+
    "s_sample s1, "+
    "s_sample s2, "+
    "u_melt m1, "+
    "u_melt m2 "+
    "where "+
    "s1.s_sampleid=sd.keyid1 and " +
    "sd.sdcid='Sample' and " +
    "s1.sampletypeid=" +"'" + sampletype +"'"+ " and " +
    "s1.samplestatus in ('Approved','Reported','Completed') and " +
    "sd.paramid='" + strIParamid + "' and " +
    "sd.paramtype='" + paramtype + "' and " +
    "sd.enteredvalue is not null and" +
    "s1.s_sampleid <> s2.s_sampleid and " +
    "s2.s_sampleid =" + "'" + sampleid + "'" + " and " +
    "s1.u_meltid = m1.u_meltid and " +
    "s2.u_meltid = m2.u_meltid and " +
    "m1.u_alloy_codeid = m2.u_alloy_codeid and " +
    "m1.u_calc_no < m2.u_calc_no " +
    ") "+
    "where "+
    "rowcount<=50 ";

  • Howto get RowCount of ResultSet

    Hello,
    is there an intelligent way of getting the rowcount of an resultset?
    For now I execute 2 SQLQueries, where the second is just executed to get the amount of rows in this selection, which is a lot of sumb overhead:
    ResultSet rs = db.getStatement().executeQuery("SELECT * FROM BOOKS WHERE LOWER(titel) like '%" + searchStr + "%' OR LOWER(autor) like '%" + searchStr + "%' OR LOWER(instrument) like '%" + searchStr + "%' ORDER BY " + orderTableName + ";");
                   ResultSet countSet = db.st2.executeQuery("SELECT COUNT(*) FROM BOOKS WHERE LOWER(titel) like '%" + searchStr + "%' OR LOWER(autor) like '%" + searchStr + "%' OR LOWER(instrument) like '%" + searchStr + "%';");
    Any ideas howto do this in a better way?
    Thank you in advance, lg Clemens

    [Standard pre-packaged copy&pasted rant follows]
    The really really best way to know the number of rows in a ResultSet: write your application so that you don't need to know it.
    To get the number of rows in a ResultSet, loop over the result set with while(res.next()). Read each row into an object. Add each object into e.g. a LinkedList. At the end, you will have the rows nicely converted to objects (which you usually should do anyway). And list.size() will give the number of objects.
    There are other ways to get the number of objects, but list.size() is the easy and reliable way. If you don't need the rows converted to objects ...why did you select them in the first place?
    Tricks with last()/getRow() sort of work. They read the entire result set into memory (in a memory-inefficient way: the storage that scrollable result sets take is almost certainly more than "real" objects). But you'll need to write the while(res.next()) loop anyway. No point in having the computer do the same thing twice. So last()/getRow() is inefficient and just plain extra silly work.
    Still thinking of using last()/getRow()? Bad idea. When you execute a select, the database server doesn't necessarily even know the number of rows you selected (the cursor "materializes" as it is being read). The server will hand rows to the JDBC driver, without being able to tell in advance how many there will be. So the only way getRow() can know how many rows there are is by reading in all of the rows. This consumes time and memory. And you STILL have to write the while(res.next()) loop, so the computer is doing the same work twice and you are writing extra code.
    "select count(*) from ..." is another way, but it has a few problems: (1) The query gets executed twice, so it is almost twice as slow. (2) The number of rows can change between the two queries. (3) You'll need to write the while(res.next()) loop anyway, so you'll be doing silly useless extra coding work.
    Best Practice: stop needing the number of rows.
    Second Best Practice: while(res.next()), create objects, put into a LinkedList, use list.size().
    Silly Extra Work And Slowness: last()/getRow() or select count(*).
    There may be situations where last()/lastRow() may be reasonable. You need to know how your database implements them and understand the performance implications. Don't even try if you can at all use the better ways.
    There is a related question: how do I page database results. That may require "select count(*)" or something, depending on how you want to do it. There is no really perfect universal solution for that question using plain SQL.

  • %ROWCOUNT problem

    Dear SQL Experts,
    I have below PL/SQL procedure to update a table, here I see %ROWCOUNT returning 0 rows in all cases and not displaying actual number of rows updated.
    When I run the update statement directly, it updates correct number of rows? Is there a limitation around %rowcount? How to overcome this problem?
    Edited by: Ora DBA on Dec 11, 2012 12:49 AM

    Hi All, am facing same problem with SQL%ROWCOUNT returning 0, as well another issue with SELECT.
    SET serveroutput on;
    DECLARE
       TYPE date_array IS TABLE OF VARCHAR2 (12);
       v_date             date_array;
       v_cnt_before_upd   PLS_INTEGER;
       v_cnt_after_upd    PLS_INTEGER;
       PROCEDURE update_table_desc (ip_char IN CHAR)
       IS
          v_desc_from   VARCHAR2 (30);
          v_desc_to     VARCHAR2 (30);
       BEGIN
          IF ip_char = 'C'
          THEN
             v_desc_from := 'From Desc 1';
             v_desc_to := 'To Desc 1';
          ELSIF ip_char = 'S'
          THEN
             v_desc_from := 'From Desc 2';
             v_desc_to := 'To Desc 2';
          END IF;
          SELECT COUNT (*)
            INTO v_cnt_before_upd
            FROM table1
           WHERE col1_desc = v_desc_from;
          UPDATE table1
             SET col1_desc = v_desc_to
           WHERE col1_desc = v_desc_from;
          DBMS_OUTPUT.put_line ('sql%rowcount:..... ' || SQL%ROWCOUNT);
          SELECT COUNT (*)
            INTO v_cnt_after_upd
            FROM table1
           WHERE col1_desc = v_desc_to;
          DBMS_OUTPUT.put_line (   'To be updated: '
                                || v_cnt_before_upd
                                || '......Updated: '
                                || v_cnt_after_upd
          IF v_cnt_after_upd = v_cnt_before_upd
          THEN
             DBMS_OUTPUT.put_line (   v_desc_from
                                   || ' updated successfully to '
                                   || v_desc_to
             COMMIT;
          ELSE
             DBMS_OUTPUT.put_line (v_desc_from || ' update failed');
             ROLLBACK;
          END IF;
       EXCEPTION
          WHEN OTHERS
          THEN
             RAISE;
       END;
    BEGIN
       SELECT reporting_date
       BULK COLLECT INTO v_date
         FROM table2
        WHERE TRUNC (reporting_date) >= '31-Mar-2011'
          AND TRUNC (reporting_date) <= TRUNC (SYSDATE);
       FOR i IN v_date.FIRST .. v_date.LAST
       LOOP
          pack_context.context_open (v_date (i));
          DBMS_OUTPUT.put_line ('..............');
          DBMS_OUTPUT.put_line ('Context: ' || v_date (i));
          update_table_desc ('C');
          update_table_desc ('S');
          pack_context.context_disable;
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack ());
    END;
    OUTPUT:
    ..............          (LOOP 1)
    Context: 26-OCT-12
    sql%rowcount:..... 0
    To be updated: 0......Updated: 573
    From Desc 1 update failed
    sql%rowcount:..... 0
    To be updated: 0......Updated: 127
    From Desc 2 update failed
    ..............          (LOOP 2)
    Context: 02-NOV-12
    sql%rowcount:..... 0
    To be updated: 0......Updated: 573
    From Desc 1 update failed
    sql%rowcount:..... 0
    To be updated: 0......Updated: 127
    From Desc 2 update failed
    ..............          (LOOP 3)
    Context: 31-AUG-12
    sql%rowcount:..... 0
    To be updated: 571......Updated: 573
    From Desc 1 update failed
    sql%rowcount:..... 0
    To be updated: 127......Updated: 127
    From Desc 2 updated successfully to To Desc 2
    PL/SQL procedure successfully completed.As you can see, SQL%ROWCOUNT returns 0 even when there is an update in (LOOP 3).
    Also note the counts returned before and after update. They're different in LOOP 3. But
    when I run the update stmt alone, am getting only the 571 records updated which is what
    available there. Don't understand from where the select stmt get 573 from. Please help me
    understand the possibilities of getting wrong counts.
    FYI: I didnt faced this issue in Oracle 11.2.0.3, am facing it in 11.2.0.1

  • How to get rowcount from a Clob

    Hi,
    Is it possible to get a rowcount from a clob, without writing a loop to iterate/count each row?
    I'm working on a CSV extract procedure, which has been passed a Clob parameter and I just need to extract its rowcount.
    I was expecting a useful function to exist, but it seems not?
    Thanks in advance

    PD81 wrote:
    Okay, if you want to be pedantic about wording:
    How do I get a “Line Count” from a clob?
    I don’t understand the obsession on this forum of responding to criticise a question , whilst adding no value towards an answer, when it’s plainly clear what the question is aiming to achieve.
    I'm not being critical or pedantic.
    The same applies, there's no such things as "lines" in a clob.  A clob is just a series of characters.  As I said it doesn't contain rows, lines or any such structure.
    If you want to search a clob for certain things, you need to be looking at the characters within it.
    So, now you say you want "lines" rather than rows, but what constitutes a "line"?  Is it a chr(10) character?  Is it a chr(13)||chr(10) pair of characters?  Is it some other character such as a ";" or whatever.
    The point is, if you want to get a specific answer, you have to be specific about the requirements.
    A CSV file is just a "Character Seperated Values" file, so what consitutes a row or line in that file (in a clob or physical file) is likewise just as ambiguous.
    How can people supply you with an coded answer to something when the requirements are ambiguous?
    You stated "I was expecting a useful function to exist", and the point is, that why should a function exist to count rows or lines or whatever, when a CLOB, by it's very nature is not a structured data type.  The functions that do exist for CLOB's such as INSTR, SUBSTR, REPLACE etc. are the functions appropriate to a clob, so you have to use those.

  • Understanding problem with threads

    Hi,
    yesterday (at least i think it was yesterday) I posted a question in this forum, I needed help with writing a multithreaded server. The answer was simple and I wrote my program. It kinda works, but there is one thing I don't understand:
    I have a class, which handles the clientconnections and one that listens for incoming conections. I pass the socket returned by ServerSocket.accept() to the clientconnection object.
    There is only ONE clientconnection-object. The listener just passes the socket and calls the start() method of the clientconnection object.
    The clientconnection just writes some text to the client. Connecting more than one client at the same time works too. Everything works fine. And that's what I don't get. If I have only O N E clientconnection the texttransfer shouldn't work after i connect the second client, right?
    But it does, is there a mistake in my logic or am I losing my sanity? :)

    Hi again Danbas,
    Maybe you are losing your sanity... but that's ok. :)
    public void startlistening(){
    while(true){
    try{
    clientconn cc = new clientconn(ssock.accept());
    }catch(IOException ie){}
    //The Constructor in clientconn would look like this:
    public clientconn(Socket sock){
    //No idea what to do here
    Every time you perform "new", you create a new object. And you are calling new every time you accept a new socket connection. So you are creating a new clientconn object each time.

  • Thoroughly Disappointed By your lack of understanding!!

    Dear Sirs, 
    On September 4th this year my Partner, Anastasia and I went to your Champaign, IL Store on Prospect Ave and we specifically asked for a Color Laser Printer that had Duplex facility, we were sold an HP Laser Jet Pro 200, which does not have Duplex but was Color. 
    This is after the sales assistant tried to sell us a big clunky all in one printer that was Ink Jet, not Laser Jet! 
    We phoned up the store this last weekend as we had been out of the country for nearly three months, and returned to set up our home office, only to find what we had been sold couldn't do what was requested of it. The Manager Brian said to bring it back and they would replace it for something more in line with what we requested. 
    I went back to the Store this past Monday Dec. 9th and took the printer to customer services, which took nearly 45 minutes to sort out what I wanted, The girl refused several times to contact Brian, the manager to verify that I was allowed to do what I had asked to do, return the printer and exchange it for one that was Color, Laser and Duplex! Not very good customer service I'm afraid!! 
    I was Sold a Brother HL-6180DW Printer, telling me yes it was Duplex/Color and had a large paper tray (Not something I'd requested) and printed quickly (Again not a specific request), and it was not available in store so could not be demonstrated! She set up a shipping order for it, it arrived yesterday, very quick delivery! 
    BUT WE HAVE A MAJOR PROBLEM HERE! 
    The Printer is Duplex, a Specific Request, BUT IS NOT COLOR!! 
    I am contacting YOU, Customer Support as I can no longer deal with your store. It took me a Cab ride and $20 to get the printer there last time, I will not return this one the same way! 
    I have returned the Second Printer the Brother HL-6810DW 
    Tracking Number: {removed per forum guidelines} 
    At the request of Anastasia {removed per forum guidelines} , this notice alerts you of the status of the shipment listed below.
    Tracking Detail
    Your package has been delivered.
    Tracking Number:
    {removed per forum guidelines}
    Type:
    Package
    Status:
    Delivered
    Rescheduled Delivery:
    12/19/2013
    Signed By:
    KELBLY
    Location:
    Dock
    Delivered To:
    FINDLAY,OH,US
    Reference Number(s):
    {removed per forum guidelines}
    Service:
    UPS Ground
    Weight:
    32.20 Lbs
    Shipment Progress
    Location
    Date
    Local Time
    Activity
    Findlay,
    OH, United States
    12/18/2013
     2:48 A.M.
    Out For Delivery
    12/18/2013
     2:03 A.M.
    Arrival Scan
    12/18/2013
     1:43 A.M.
    Delivered
    Columbus,
    OH, United States
    12/18/2013
     12:01 A.M.
    Departure Scan
    Columbus,
    OH, United States
    12/17/2013
     1:22 P.M.
    Arrival Scan
    Indianapolis,
    IN, United States
    12/17/2013
     10:22 A.M.
    Departure Scan
    12/17/2013
     12:49 A.M.
    Arrival Scan
    Urbana,
    IL, United States
    12/16/2013
     9:07 P.M.
    Departure Scan
    12/16/2013
     5:30 P.M.
    Pickup Scan
    United States
    12/14/2013
     8:01 P.M.
    Order Processed: Ready for UPS
    Tracking results provided by UPS: 12/19/2013 1:49 P.M. Eastern Time
    As you can see it has been returned to you
    But I have only received a partial repayment to my bank account
    in the sum of $108-
    this still leaves a balance of $217.46 from the first printer.
    Your Customer Services lady at the Champaign Store when I returned the first printer, swiped a yellow tag through the Cash Terminal and I assume that was Store Credit?
    As that is what came up on the receipt, but she never mentioned to me what she was doing.
    I feel very cheated by your company, as you are still withholding $217.46 of my money
    Which I would like returned. Please!!
    I spent nearly 4 hours on the phone to various departments within your company on December 23rd trying to sort this out, (I charge $150 an hour for my time as a Consultant to Hotels and Restaurants) all to no avail, as nobody had the decency to actually listen to what I said. Yes I got Irate at your staff, because they were just not listening!!
    I expect to receive my $217.46 in cash deposited to my account, please
    I will accept store credit if it is absolutely necessary, but please be assured I have no wish to deal with your company any more than is necessary as i do not think that you or your staff listen to their customers!!
    You as a company have failed me on three occasions now,
    First) The HP Laser Jet Pro, was not what I was sold or asked for
    Second) The Brother HL-6810DW was not what I asked for either
    Third) You are Holding on to my hard earned money, which could be construed as theft
    Please be aware I will be contacting my legal representative as soon as possible to discuss this matter with him!
    I urge you to make this right.
    It is a pretty simple request really, WE WANTED A DUPLEX COLOR LASER PRINTER for our Business! WHAT IS DIFFCULT ABOUT THAT?? 
    The First Printer was Color but not Duplex 
    The Second Printer is Duplex but not Color 
    Both Printers are under the delivery name: 
    {removed per forum guidelines}
    I wonder if your staff Know what a customer asks for? 
    I WOULD request that I get my Money Back, including the $20 for the Cab fare 
    And at least $200 in compensation for all this grief and the fact I cannot Print out my Catalogs for my products, which I wanted to have out for Christmas 
    I printed three with The HP Laserjet and it printed blue dots all along the page which ruined the catalog also. 
    I look forward to your reply!
    I had to Call Customer Relations to get anywhere with this, But I'm still no further forward, as I was told I had to wait 7-10 Days for delivery of my Gift Card.  Then I got this:
    BestBuy.com Customer Care
    Jan 17 (12 days ago)
    to me
    Dear Sir:
    Just a follow up.
    I note your concerns are being handled and the $217. plus chg. is being issued.
    on your order #{removed per forum guidelines}.
    I want to thank you for speaking up and helping us improve our service. I do apologize that this was not taken care of earlier. Please refer to case # {removed per forum guidelines} should you need to contact us again - but from all I see this is being addressed. 
    Thank you,
    Jerry
    Best Buy Customer Care Team
    To Which I replied on January 28th
    Case  # {removed per forum guidelines}
    When I contacted you originally, I never received a reply to my original email although it states 3 DAYS in your standard reply email. 
    In reply to the below Email I had to call your Customer Relations Team to get anywhere, and that was to get my Money Refunded. Which has STILL NOT ARRIVED, even though I was told it would take 7-10 days!
    You'll notice I have now waited 11 days, since you replied! So in effect I've waited nearly 21 days to receive my refund!
    This is now beyond ridiculous!
    If I DO NOT have my Money within two days from todays date January 28th, 2014, I will be seeing my lawyer and I will be taking your company to court for misappropriation of my funds.
    I will not deal with your 3 days, I want answers and I would like them now!!
    I am still waiting for the Gift Card with my $217.46 on it
    I suggest you get this sent out Signed For Delivery and have it expedited on a Next Day Delivery also!
    I still cannot run my business efficiently as I have NO PRINTER, which will not be the case until your company refunds my money.
    Personally I have no wish to buy anything else from you, I would like my $217.46 refunded to my Debit Card, I do not want a Gift Card, I never did, I wanted the freedom to shop at another store and not give your company anymore of my money!!
    Can you please Return my money!!
    Their Reply was:
    Hi Mr. {removed per forum guidelines} 
    My sincerest apologies that you have not received your refund bas yet.  Our gift card dept has been backed up and has had some techinical difficulty with process orders. I have researched this and found
    that a gift card is being processed for $217.49.  You should be receiving it shortly. Thank you for your patients.
    Thank You
    Mildred C
    It is now January 29th I still have NO GIFT CARD!!
    All I want is My Money Returned
    This has been going on Since December 2013
    Nearly Two Months Now
    If I do Not get action I will See My Lawyer and I also want Compensation for lost Revenue and Lost Hours at Work because of this!!
    The Two Printers:
    I could not add them through your site so I found them on Amazon.com
    {Removed per Forum Guidelines}
    As you can see neither do What I had originally requested

    Good afternoon TheScotsman61,
    After attempting to buy two different printers and not receiving one that meets your needs for your business, I can fully understand why you would be so frustrated. Not to mention, if you didn't receive the card the store credit was applied to back, you wouldn't have access to the funds returned to it once you returned the Brother printer.
    I apologize for any inconvenience this experience may have caused you. Presently, I see we have reissued you the store credit to the address listed on the order. As it finished processing on 1/30/14, it should be in the mail and on its way to you. I also see that you spoke with Andrew from our Executive Resolutions team in regards to your experience, who offered a final resolution to this issue, and you accepted. I’m glad we were able to assist you with this experience!
    In regards to your continued lack of a printer, it seems that hydrogenwv and the HP representative both provided you a few options for printers that may work for you that are within your price range.  Please let me know if you have any questions or further concerns!
    Regards, 
    Tasha|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Error Posting IDOC: need help in understanding the following error

    Hi ALL
    Can you please, help me understand the following error encountered while the message was trying to post a IDOC.
    where SAP_050 is the RFC destination created to post IDOCs
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Call Adapter
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIAdapter</SAP:Category>
      <SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_IDOC_RUNTIME</SAP:Code>
      <SAP:P1>FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:P1>
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Error: FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Your help is greatly appreciated.............Thank you!

    Hi Patrick,
      Check the authorizations assigned to the user which you used in the RFC destinations, If there is no enough authorizations then it is not possible to post the idocs.
    Also Refer this Note 747322
    Regards,
    Prakash

  • Tcode:File ,Tcode:sf01  understanding

    pls help me in understanding these tcode
    to create logical path,pls provide me the step by
    step to create a logical path

    Hi,
    Pls check threads like
    Application Server -File Upload
    How to create logical file name
    Eddy

  • Understanding the way to connect a MDD to BlackMagic Decklink Extreme card

    Hi,
    I require some help in the following:
    I recently bought myself a Blackmagic DeckLink Extreme™ with 10bit SDI/analog video and audio capture card.
    Looking at the specs, http://www.blackmagic-design.com/products/sd/specs/, can someone give me directions as to the best setup I can do from the following sources and what other equipment I may require to achieve it.
    - mono stereo audio VHS -> has 1 video/audio in and 1 video/audio out (composite connections)
    - stereo audio video camera -> has 1 8 pin S-Video out port to composite connections (Hi8 tape type)
    - DVD player -> has composite 2 x 2ch stereo audio out, 1 x 5.1ch stereo audio out, 2 x video out, 1x component video out, 2 x S-video out, 2 x digital audio out; 1 x RCA/OPT
    - 2 x 23" monitors connected by ADC and DVI connections to a Apple MDD G4, may relay to 60" Plasma for video monitoring from video card prior to creating DVD final piece for playback.
    Basically, I wanted to have multiple source inputs and outputs, but I'm having difficulty in understanding the setup. Please refer to http://www.blackmagic-design.com/downloads/connections/decklinkdiagram.pdf page 5/6.
    I purchased the following from JayCar
    - 6 x PA3655 ADPT PLG RCA:
    https://secure4.vivid-design.com.au/jaycar2005/productView.asp?ID=PA3655&CATID=& keywords=PA3655&SPECIAL=&form=KEYWORD&ProdCodeOnly=&Keyword1=&Keyword2=&pageNumb er=&priceMin=&priceMax=&SUBCATID=
    - 1 x AC1668 SWITCH AV 3WAY:
    https://secure4.vivid-design.com.au/jaycar2005/productView.asp?ID=AC1668&CATID=& keywords=AC1668&SPECIAL=&form=KEYWORD&ProdCodeOnly=&Keyword1=&Keyword2=&pageNumb er=&priceMin=&priceMax=&SUBCATID=
    What other devices do I need to set up the equipment in the following way:
    <pre>
    Computer ------- Video In + Stereo In -----------> 3WAY SWITCH BOARD
    | | ^ ^ ^
    | | | | |
    Bigpond |---- OUT ---> TV --------|-----|-----|
    (Satellite Internet) | | | |
    FOXTEL DVD VCR V/CAM
    (Satellite TV)
    </pre>
    Currently I have not succeeded.
    I have just done a simple test like so:
    <pre>
    Computer ------- Video In + Stereo In ---------> DVD (*)
    |
    Bigpond
    </pre>
    (*) Tested using the following:
    <pre>
    From Decklink -- Y IN (from deck) --> DVD Y port
    -- B-Y IN (from deck) --> DVD Pb port
    -- R-Y IN (from deck) --> DVD Pr port
    -- SDI IN (from deck) ---> DVD Digital audio out
    ASWELL AS
    From Decklink -- Y OUT (from deck) --> DVD Y port
    -- B-Y OUT (from deck) --> DVD Pb port
    -- R-Y OUT (from deck) --> DVD Pr port
    -- SDI OUT (from deck) ---> DVD Digital audio out
    </pre>
    Not one has seemed to work. What am I missing here?
    Thanks
    Tiberius
    PPC MDD Dual Boot/Dual 1.25GHz   Mac OS 9.2.x   2 x 23" Apple HD Display, 2GB RAM, 2x150GB + 1x1TB HD

    pomme4moi wrote:
    I want to buy a hard disk (not a NAS device) and plug it into my Airport Extreme in order to share data between two Mac computers, and to stream iTunes content to my Apple TV.
    One option is to purchase a hard drive (say, a 2TB Hitachi G-Technology drive) and connect it to the USB port on the back of the Apple Extreme. The other option is to purchase a drive with an ethernet connection (say, a 2TB Lacie drive) and connect it to an ethernet port on the Apple Extreme.
    In the second case what you'd have actually is a NAS. Apple's AirPort routers aren't known for fast file sharing. The NAS option might be faster.
    Is either option better for streaming movies from the hard drive to my Apple TV?
    I could be wrong, but an AppleTV may not be able to access content directly from a network drive. It may require that a Mac serve as an intermediary.

Maybe you are looking for

  • While making vendor clearing through F-44, service tax is also coming

    Hi Expert, I have an issue related to vendor clearing, 1.  I have make an advance payment following transaction took place : 29  Vishal Ltd                     10000 40  Service tax input               100 40  Excess on service tax        20 40  HSec

  • Problems with Digital Signatures

    I have a pdf with multiple signature fields. When somebody signs it in  9.x everything is fine, but when somebody signs it in a version earlier  than 9.0 it does not work. The signature fields do not even show up.  Somebody signed the pdf in 8.x and

  • "change all" unavailable to change default application

    I've been irritated that Preview constantly wants to open all of my image and PDF files. I've had to manually change the default application for each individual file (not fun when I have hundreds, possibly thousands of these files). I did a search to

  • Failover for Single ASA

    Hi All, I want to know what all fail-over I can build for single ASA. I am planning to connect as per the attached. Please let me know  all configuration that i can build. Do i need to assign 2 ip's for that 2 interfaces connected to inside,dmz and o

  • Upgrading iMac to Snow Leopard

    I have an Intel based iMac. The OSX is at 10.5.8. Ran all updates. When installing the Snow Leopard CD, the CD\DVD player acts like it is reading the Snow Leopard CD and then ejects it. I tried to install a another DVD into it and it reads it fine an