Update returning # of rows?

Could some one explain to me a way to get the number of rows an update statement changes when performing an update. See example below;
declare
rowcnt NUMBER(3);
begin
update emp
set deptno = 20
where deptno = 10
returning XXX in rowcnt;
end;
BTW TIA!

I used the update statement in a procedure with in a FOR ..LOOP
here is the specific statement
UPDATE contract_info_2003
                              SET solicitation_num = rec.solicitation_no
                              ,audit_c_dte = rec.auditc_dt
                              ,act_sol_issued_dte = rec.soliss_dt
                              ,act_prop_dte = rec.prop_dt
                              ,arp_dte = rec.pwdpdp_dt
                              ,rev_arp_dte = rec.arpcpl_dt
                              ,start_dte = rec.startdt_dt
          WHERE p_key = rec.p_key
RETURNING XXX into rowcnt;
XXX-->'sql%rowcount'

Similar Messages

  • Select for update returns no rows even though there is no locking thread

    I'm using Ibatis library over oracle sql for my query. The select for update statement returns no rows. This happens intermittently. When this was happening last time, I executed the select statement on sqldeveloper (but without the 'for update') and got rows. This situation is not easily reproducible so I've not yet been able to ascertain whether rows are returned on sqldeveloper with the 'for update' clause. But I know for sure that there was no other thread locking the rows. How could this be happening?

    The select for update statement returns no rowsWhy do you think that a select for update will always return rows?
    the for update clause if there not to garantee the presence of rows but to lock the row when it is present
    sql> select * from t;
             A          B C
             1          1 step1
             2          2 step2
             3          3 step3Then session 1 issues the following select
    SELECT     *
          FROM t
         WHERE a = 1
    FOR UPDATE NOWAIT;If session 2 issues the same select before session 1 commits or rolls back
    SELECT     *
          FROM t
         WHERE a = 1
    FOR UPDATE NOWAIT;It will get the following error
    ERROR at line 1:
    ORA-00054: resource busy and acquire with NOWAIT specifiedBut if session 2 issue such a kind of select
    sql> SELECT     *
      2        FROM t
      3       WHERE a = 99
      4  FOR UPDATE NOWAIT;
    no rows selectedYou see then that a select for update can return no rows
    Best Regards
    Mohamed Houri

  • Select for update that doesn't return any rows

    Are there any odd side-effects that may occur if a select for update that returns no results is never committed? I wouldn't think there are, but I'm not sure if there would be some kind of overhead or unforeseen consequences. This isn't a terribly important question, but it's come up in some coding I've done and I've not been able to find any documentation addressing it.

    A select for update only locks rows that meet the predicate specified in the where clause. So, if the query returns no rows, no rows are locked.
    session1> SELECT * FROM t;
            ID DESCR
             1 Un
             5 One
             2 THIS IS WA
    session1> SELECT * FROM t
      2  WHERE id = 11 FOR UPDATE;
    no rows selectedA second session can update rows in the table
    session2> UPDATE t
      2  SET descr = 'One'
      3  WHERE id = 1;
    1 row updated.John
    Edited by: John Spencer on Jan 7, 2009 1:36 PM
    I just realized that, although you can do updates on the table after the select fo update that returns no rows, you cannot do DDL operations liike a truncate. Unless the session that does the select for update either ends the transaction (i.e. commit or rollback) or ends the session DDL operations will fail.

  • Cannot add or update this document; rows are missing [Return - Freight ]

    Hello Experts,
    I am using 8.8 PL15 I have implement Approval Procedure on every Return Document.After approval when I tried to add document using Logistic user it creates following error message.
    Cannot add or update this document; rows are missing [Return - Freight - Freight Code][line: 0]  [Message 131-198]
    There is no any additional freight on Return & Delivery.There is no freight on base document also.
    When i add same document through manager then it add successfully to system.
    Regards,
    Chetan

    hi,
    There may be two reason for this...
    1. Freight accounts are not mapped . Doesn't matter you are using or not these in document .
    2. Check items are not in negative ?
    regards
    Deepak Tyagi

  • Query executed within a plug-in script returns 0 rows, although data exists

    I created a plug-in script for algorithm entity: Service Quantity Rule.
    The script calls a business service that I created using query zones. The query returns the values of the bill segment (ci.bseg.bseg_id and ci_bseg.closing_bseg_sw) that is created while running a bill manually. The zone receives the bseg_id as a parameter.
    The problem is that when I execute the business service within the plug-in script the business services returns 0 rows even though the data is actually being stored in the database.
    The script calculates some SQI values and saves it to the bill segment based on a response that is received from MDM (I'm using the usage request object).
    Steps:
    1.- Create Bill. The bill segment is created in error as it is waiting for the bill determinants to be sent from the MDM. If I test the zone with the bseg_id (as a parameter) of the newly created bill segment it works fine.
    2.- We send a message from the MDM to CC&B. The message is received and processed and it gets to a point when the usage updates the bill segment.
    3.- After the bill segment has been updated with the values from the usage request object it starts executing the plug-in script.
    4.- I obtain the bseg_id from the usage request and use the business service (passing the bseg_id as a parameter) and it returns no result.
    5.- The process finishes and if test the zone with the bseg_id (as a paramter) of the billing segment it works fine.
    So apparently during the execution of the script after the billing determinants are received from MDM I can't have access to the Bill segment that was created, even if the physically the record exists in the database (CI_BSEG).
    I also tried instantiating an object related with the bill segment and got the same result.
    Any idea or clue of what is happening?

    Could you be more explicit.
    What CC&B version?
    What MDM version?
    More details are required for:
    2.- We send a message from the MDM to CC&B. The message is received and processed and it gets to a point when the usage updates the bill segment.
    3.- After the bill segment has been updated with the values from the usage request object it starts executing the plug-in script.
    4.- I obtain the bseg_id from the usage request and use the business service (passing the bseg_id as a parameter) and it returns no result.

  • SQL Update a Single Row Multiple Times Using 2 Data Sets

    I'm working in tsql and have an issue where I need to do multiple updates to a single row based on multiple conditions. 
    By Rank_
    If the column is NULL I need it to update no matter what the Rank is.
    If the Ranks are the same I need it to update in order of T2_ID.
    And I need it to use the last updated output.
    I've tried using the update statement below but it only does the first update and the rest are ignored. Here is an example of the data sets i'm working w/ and the Desired results. Thanks in advance!
    update a
    set Middle = case when a.Rank_> b.Rank_ OR a.Middle IS NULL then ISNULL(b.Middle,a.Middle) end,
    LName = case when a.Rank_> b.Rank_ OR a.Lname IS NULL then ISNULL(b.LName,a.LName) end,
    Rank_ = case when a.Rank_> b.Rank_ then b.Rank_ end
    from #temp1 a
    inner join #temp2 b on a.fname = b.fname
    where b.T2_ID in (select top 100% T2_ID from #temp2 order by T2_ID asc)

    The Merge clause actually errors because it attempt to update the same record.  I think this CTE statement is the closest I've come but I'm still working through it as I'm not too familiar w/ them.  It returns multiple rows which I will have to
    insert into a temp table to update since the resulting row I need is the last in the table.
    ;WITH cteRowNumber
    AS(
    Select DISTINCT
    Row_Number() OVER(PARTITION BY a.LName ORDER BY a.LName ASC, a.Rank_ DESC,b.T2ID ASC) AS RowNumber
    ,a.FName
    ,a.LName
    ,b.LName as xLname
    ,a.MName
    ,b.MName AS xMName
    ,a.Rank_
    ,b.Rank_ AS xRank
    ,b.T2ID
    FROM #temp1 a
    inner join #temp2 b
    ON a.fname = b.fname
    ), cteCursor
    AS(
    Select a.RowNumber,
    a.Fname
    ,a.LName
    ,a.xLname
    ,a.MName
    ,a.xMName
    ,a.xRank
    ,a.T2ID
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xRank,a.Rank_) else ISNULL(a.Rank_,a.xRank) end AS Alt_Rank_
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xMName,a.MName) else ISNULL(a.MName,a.xMName) end AS Alt_MName
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xLName,a.lname) else ISNULL(a.LName,a.xlname) end as Alt_Lname
    FROM cteRowNumber a
    where a.RowNumber = 1
    UNION ALL
    Select crt.RowNumber
    ,crt.FName
    ,crt.LName
    ,crt.xLname
    ,crt.MName
    ,crt.xMName
    ,crt.xRank
    ,crt.T2ID
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xRank,Prev.Alt_Rank_) else ISNULL(Prev.Alt_Rank_,crt.xRank) end AS Alt_Rank
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xMName,Prev.Alt_MName) else ISNULL(Prev.Alt_MName,crt.xMName) end AS Alt_MName
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xLName,Prev.Alt_Lname) else ISNULL(Prev.Alt_Lname,crt.xLName) end as Alt_Lname
    FROM cteCursor prev
    inner join cteRowNumber crt
    on prev.fname = crt.fname and prev.RowNumber + 1 = crt.RowNumber
    SELECT cte.*
    FROM cteCursor cte

  • ExecuteWithParams is not returning the rows from cache

    Hi,
    We have two VO's based on same entity ,whenever new row is inserted in one VO and we do executeWithParams on another VO ,It is not returning the rows which are uncommitted.
    I replaced the executeWithParams with a custom method in AM in which I am executing the query after applying the view criteria and setting query mode.Its returning rows which are uncommitted.
    Jdev Version which I am using is 11.1.1.7.0
    ExecuteWithParams used to work with uncommitted data in 11.1.1.6.0 .
    Do we need to raise a bug on framework or Am I missing something?
    Edited by: sharavnkumar_malla on Oct 18, 2012 1:02 AM

    Still the same answer, even after you updated the question. We (the public) don't have 11.1.1.7, know nothing about 11.1.1.7, and cannot help you with 11.1.1.7. Questions about internal builds belong on internal forums.

  • SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row

    I have a region with the following type:
    SQL Query (PL/SQL Function Body returning SQL query).
    In a search screen the users can enter different numbers, separated by an ENTER.
    I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
    It's something like this:
    If (:P30_POD Is Not Null) Then
    v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
    v_condition := ' AND ';
    End If;
    But the query doesn't return any rows.
    I tried to reproduce it in Toad:
    select * from asx_worklistitem
    where
    POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    ==> This is the query that does't return any rows
    select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    from dual;
    ==> This returns '541449200000171813','541449206006341366'
    select * from asx_worklistitem
    where pod in ('541449200000171813','541449206006341366');
    ==> and when I copy/paste this in the above query, it does return my rows.
    So why does my first query doesn't work?
    Doe anyone have any idea?
    Kind regards,
    Geert
    Message was edited by:
    Zorry

    Thanks for the help.
    I made it work, but via the following code:
    If (:P30_POD Is Not Null) Then
    v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
    v_where := v_where || v_condition || 'POD IN (';
    v_counter := 1;
    WHILE (v_counter < LENGTH(v_pods)) LOOP
    v_pod := SUBSTR(v_pods, v_counter, 18);
    IF (v_counter <> 1) THEN
    v_where := v_where || ',';
    END IF;
    v_where := v_where || '''' || v_pod || '''';
    v_counter := v_counter + 18;
    END LOOP;
    v_where := v_where || ')';
    v_condition := ' AND ';
    End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
    For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
    Because I think this will have a lot of overhead.
    I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible?

  • Sql server if the row exist it update if the row new won't update

    I am
    working with Asp.net and C# and using SQl Server, I insert a row in one plase and works fine but when I try to update the same row it woudn't do anything, I
    try to update an existing row it works with the same code but not if I just
    insert new row.
    my code as
    below:
    String companyName = txCompany.Text.ToString();
    SqlConnection con =
    new
    SqlConnection(conString);
    SqlCommand cmd =
    new
    SqlCommand("INSERT
    INTO DocUp (CompanyName)VALUES (@CompanyName)", con);
    cmd.Parameters.AddWithValue("@CompanyName", companyName);
    try
    con.Open();
    cmd.ExecuteNonQuery();
    catch (Exception
    er)
    Response.Write("<script language='javascript'>alert('Connection Problem On Insert');</script>");
    finally
    con.Close();
    string strQuery =
    "UPDATE DocUp SET 
    QuoteFileName=@QuoteFileName, ContentType=@ContentType, QuoteFileData=@Data WHERE CompanyName=@Company";
    SqlCommand cmd =
    new
    SqlCommand(strQuery);
    cmd.Parameters.Add("@QuoteFileName",
    SqlDbType.VarChar).Value = filename;
    cmd.Parameters.Add("@ContentType",
    SqlDbType.VarChar).Value =
    "application/pdf";
    cmd.Parameters.Add("@Data",
    SqlDbType.Binary).Value = bytes;
    cmd.Parameters.Add("@Company",
    SqlDbType.VarChar).Value = companyName;
    InsertUpdateData(cmd);
    private
    Boolean InsertUpdateData(SqlCommand
    cmd)
    String strConnString = System.Configuration.ConfigurationManager
    .ConnectionStrings["S7V001_11022014ConnectionString1"].ConnectionString;
      SqlConnection con =
    new
    SqlConnection(strConnString);
    cmd.CommandType = CommandType.Text;
    cmd.Connection = con;
    try
    con.Open();
    cmd.ExecuteNonQuery();
    return
    true;
          catch (Exception
    ex)
    Response.Write(ex.Message);
    return
    false;
    finally
    con.Close();
    con.Dispose();

    Please use the  "Insert code block" button to insert *readable* code blocks 
    try{
    con.Open();
    cmd.ExecuteNonQuery();
    return true;
    You have not shared what query/functions that you are using to insert data. Please share. 
    Also it looks like more like a .Net related questions, (and if you agree,  ) I would recommend posting the question in .Net forum
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral
    Also I would recommend you to read "How to ask questions in Technical Forums" from the below link
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Why does view WWSBR_USER_FOLDERS return no rows to public ?

    Hi,
    I want to show a user dependent list of folders in a portal
    report application component, but the view
    portal30.wwsbr_user_folders does not show public folders to a
    public (not logged in) user. The view does not return any rows. I
    tested this by creating a portal report on the view, put the
    report as a portlet on page. Logout and navigate to the page. The
    report portlet shows "No Rows Returned". I would expect to see
    the public folders in the report portlet. Am I doing something
    wrong ? Is view portal30.wwsbr_user_folders the right view for
    this kind of query ?
    Environment:
    9iAS version 1.0.2.2
    Portal patch 3.0.9.8.1
    RDBMS version 8.1.7.1.1
    regards,
    Willem-Pieter van der Lugt
    Oracle Consulting NL.

    This is a bug. As a workaround, create two new views as follows:
    create or replace view wwsbr_user_corners2 as
    SELECT "ID","SITEID","LANGUAGE","PARENTID","NAME","TITLE","SETTIN
    GSSETID","SETTINGSSETSITEID",
    "ISPUBLIC","IMAGE","ROLLOVERIMAGE","TITLEIMAGE","LEADER","DESCRIP
    TION",
    "PRODUCTION","FRONTPAGE","CREATEDATE","CREATOR","UPDATEDATE","UPD
    ATOR","SEQ",
    "PUBLISHDATE","DISPLAYLEVEL","DISPLAYSUBCORNERS","ICON","LIFETIME
    HITS","CTXTXT",
    "NAVIGATIONCORNERID","ISTEMPLATE","ISPROJECT","HAVEITEMSECURITY",
    "ITEMVERSIONING",
    "DISPLAYINPARENT","TOPICID","TOPIC_SITEID","VALUE","NAVBARSITEID"
    ,"TYPE","TYPE_SITEID",
    "BASE_TYPE","FOLDER_PATH_DISPLAY","MAILTO_LINK_DISPLAY","IS_CACHE
    _VALID",
    "IS_PORTLET","IS_CACHING_ON","QUOTA","TYPE_DISPLAY_FULL","SITECHA
    RID","SYSPRIV_NAME",
    "PLSQL_EXECUTOR","SUBSCRIBER_ID"
    FROM WWV_CORNERS C
    WHERE
    -- Next line needed to select public folders
    ISPUBLIC = 1
    -- portal admin
    OR EXISTS
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$
    WHERE OBJECT_TYPE_NAME = 'ANY_SITE'
    AND NAME = 'ALL_OBJECTS'
    AND OWNER = wwctx_api.get_product_schema
    AND GRANTEE_TYPE = 'USER'
    AND GRANTEE_USER_ID = wwctx_api.get_user_id
    AND GRANTEE_GROUP_ID = 0
    AND PRIVILEGE_CODE = 500 -- ADMIN
    UNION ALL
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$ P, WWSEC_FLAT$ F
    WHERE P.OBJECT_TYPE_NAME = 'ANY_SITE'
    AND P.NAME = 'ALL_OBJECTS'
    AND P.OWNER = wwctx_api.get_product_schema
    AND P.GRANTEE_TYPE = 'GROUP'
    AND P.GRANTEE_USER_ID = 0
    AND P.GRANTEE_GROUP_ID = F.GROUP_ID
    AND P.PRIVILEGE_CODE = 500 -- ADMIN
    AND F.PERSON_ID = wwctx_api.get_user_id
    -- site admin
    OR EXISTS
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$
    WHERE OBJECT_TYPE_NAME = 'SITE'
    AND NAME = C.SITECHARID
    AND OWNER = wwctx_api.get_product_schema
    AND GRANTEE_TYPE = 'USER'
    AND GRANTEE_USER_ID = wwctx_api.get_user_id
    AND GRANTEE_GROUP_ID = 0
    AND PRIVILEGE_CODE = 300 -- ADMIN
    UNION ALL
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$ P, WWSEC_FLAT$ F
    WHERE P.OBJECT_TYPE_NAME = 'SITE'
    AND P.NAME = C.SITECHARID
    AND P.OWNER = wwctx_api.get_product_schema
    AND P.GRANTEE_TYPE = 'GROUP'
    AND P.GRANTEE_USER_ID = 0
    AND P.GRANTEE_GROUP_ID = F.GROUP_ID
    AND P.PRIVILEGE_CODE = 300 -- ADMIN
    AND F.PERSON_ID = wwctx_api.get_user_id
    -- owned; check the special groups too
    OR EXISTS
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$
    WHERE OBJECT_TYPE_NAME = 'FOLDER'
    AND NAME = C.SYSPRIV_NAME
    AND OWNER = wwctx_api.get_product_schema
    AND GRANTEE_TYPE = 'USER'
    AND GRANTEE_USER_ID in (wwctx_api.get_user_id, 2)
    AND GRANTEE_GROUP_ID = 0
    AND PRIVILEGE_CODE = 700
    OR EXISTS -- group grant to a specific group
    SELECT 'x'
    FROM WWSEC_SYS_PRIV$ P, WWSEC_FLAT$ F
    WHERE P.OBJECT_TYPE_NAME = 'FOLDER'
    AND P.NAME = C.SYSPRIV_NAME
    AND P.OWNER = wwctx_api.get_product_schema
    AND P.GRANTEE_TYPE = 'GROUP'
    AND P.GRANTEE_USER_ID = 0
    AND P.GRANTEE_GROUP_ID = F.GROUP_ID
    AND F.PERSON_ID = wwctx_api.get_user_id
    AND PRIVILEGE_CODE = 700
    create or replace view wwsbr_user_folders2 as
    SELECT c.id,
    c.siteid caid,
    c.language language,
    c.name name,
    c.title display_name,
    c.topicid category_id,
    c.topic_siteid category_caid,
    c.description ,
    c.type type_id,
    c.type_siteid type_caid,
    c.base_type base_type_id,
    c.is_portlet is_portlet,
    c.is_caching_on is_caching_on,
    c.seq sub_folder_sequence,
    c.displayinparent display_in_parent_folder,
    c.itemversioning,
    c.settingssetid style_id,
    c.settingssetsiteid style_caid,
    u.url url_value,
    decode(c.base_type,3,c.value,null) search_value,
    decode(c.base_type,4,c.value,null) plsql_value,
    c.image title_image_name,
    c.rolloverimage rollover_image_name,
    c.titleimage banner_image_name ,
    c.navigationcornerid navigation_bar_id,
    c.navbarsiteid navigation_bar_caid,
    c.ispublic is_public,
    c.haveitemsecurity item_level_security,
    c.type_display_full display_full_screen,
    c.plsql_executor plsql_folder_executor,
    c.createdate,
    c.creator,
    c.updatedate,
    c.updator
    FROM WWSBR_USER_CORNERS2 C,
    WWSBR_URL$ U
    WHERE c.value = u.url(+) and
    c.siteid = u.object_siteid(+)
    The first view adds the condition (WHERE ISPUBLIC=1) to show any
    public folder.
    Don't change the original view definitions, and be sure you
    grant access on WWSBR_USER_FOLDERS2 (or whatever you choose to
    call it) to PORTAL30_PUBLIC (or whatever your public portal
    schema is called).
    Regards,
    Jerry

  • Stored Procedure fails to return all rows of data.

    Our HR database uses a procedure to build a list of employee IDs (ie. 1,3,14,...1210,1215) then calls a procedure to with a variable to extract details per employee. Unfortunately the list is 947 ids, however only 887 rows are returned.
    As a test I split the list in two and called the procedure. If I add the data rows together I get 947, hence I know the employees are valid. Can anyone suggest why a long list of Ids should fail? Is there a limit a stored procedure can return?
    The procedure (simplified down a bit) is:
    ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
     @EmpIds varchar(4000)
    AS
    SELECT    E.empid as EmpId ,E.Surname
        FROM    Employee E
        WHERE  (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
    I can run the procedure as:
    "exec sp_Employee_CreateTable @EmpIds=N'1,3,14.....999'" which returns (say) 700 rows  and  "exec sp_Employee_CreateTable @EmpIds=N'1001,.....1215'" which returns 247 rows. (ie. 700+247 = 947 which is correct.
    But exec sp_Employee_CreateTable @EmpIds=N'1,3,14......1215' only returns 887 rows.
    I have looked at the length of the data passed to the procedure (1,3,...1215) which equals 4126 chars, therefore I bumped the varchar space from 4,000 to 6,000 which is still within limits, however the number of rows returned was still 887.
    Any help would be gratefully received.

    Hi Scott. I run the script you suggested (thank you), the var EmpIds was set to a string with over 930 ids. The returned data set started with 0 but only had 888 rows. As mentioned above I refer the 930+ list as full list, and the 888 as the short list.
    The difference (around 47) were the last values in the full list.
    Although EmpIds was set to 6K it definately seems like it gets to around 4K chars then ignores any other values.
    Re "since you pass....". Absolutely. I have modified the Employee_CreateTable with the var update to 6K/
    ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
     @EmpIds varchar(6000),
     @IncludeLeavers Bit
    AS
        SELECT    E.empid as EmpId ,E.Surname, E.Firstname as Forename,E.PayrollID, E.intextno as Extension, EJ.position as Position, [dbo].[GetEmployeeDepartment](E.empid) as Department, [dbo].[GetEmployeeLocation](E.empid) as Location,
    E.title as Title, EJ.ReportsTo,
                CoEmail,E.[left]
        FROM    Employee E INNER JOIN EmployeeJobs EJ
        ON        E.empid = EJ.empid
        WHERE  (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
                AND (E.[left]=0 or E.[left]=@IncludeLeavers)
        ORDER BY E.Surname, E.Firstname, E.empid

  • How to Create a record if vo.executequery does not return any rows

    I would like to update a single record on adf form. However if the record does not exist would like to create a row and save it in the table.
    The user does not want to add a "create" button on the screen. Hence would need to add the create code if vo.execute does not return any rows...
    How to add this and where to add?

    you can have a TF router for for exists and does not exist and based on that execute transient VO and other VO.
    Add a method call activity like below to create a row in transient VO
    public Row createRow()
    ViewObjectImpl tVO = (ViewObjectImpl)getTVO();
    tVO.executeEmptyRowSet();
    Row newRow = tVO.createRow();
    tVO.setCurrentRow(newRow);
    tVO.insertRow(newRow);
    return newRow;
    }

  • Update Statement Updating Too Many Rows

    Hiya,
    I am trying to run this update statement:
    UPDATE PROCEDURE_PRICE p
    SET p.term_date = (SELECT t.tdate
                        FROM PROCEDURE_PRICE_TMP t
                        WHERE p.seq_proc_price = t.zzz_nullterm_seq_proc_price
                        AND p.procedure_code = t.procedure_code
                        AND p.price_schedule = t.price_schedule)
    And it is updating all 600000+ records in the PROCEDURE_PRICE table.
    I am only expecting it to update 60 records, because that is what I find when running this query:
    select p.term_date,
         t.tdate,
         p.seq_proc_price,
         t.zzz_nullterm_seq_proc_price,
         p.procedure_code,
         t.procedure_code,
         p.price_schedule,
         t.price_schedule
    from procedure_price p, procedure_price_tmp t
    WHERE p.seq_proc_price = t.zzz_nullterm_seq_proc_price
    AND p.procedure_code = t.procedure_code
    AND p.price_schedule = t.price_schedule;
    Can't seem to figure out what is wrong, and I know it is something simple.
    Thanks in advance :).

    You probably want something like
    UPDATE PROCEDURE_PRICE p
       SET p.term_date = (SELECT t.tdate
                            FROM PROCEDURE_PRICE_TMP t
                           WHERE p.seq_proc_price = t.zzz_nullterm_seq_proc_price
                             AND p.procedure_code = t.procedure_code
                             AND p.price_schedule = t.price_schedule)
    WHERE EXISTS (SELECT 1
                     FROM PROCEDURE_PRICE_TMP t
                    WHERE p.seq_proc_price = t.zzz_nullterm_seq_proc_price
                      AND p.procedure_code = t.procedure_code
                      AND p.price_schedule = t.price_schedule)Basically, you want to slap a WHERE EXISTS clause on the UPDATE that ensures that your inner query returns a row.
    Justin

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • Query to return ALL rows even those with zero counts

    Hi,
    The following query will return only those rows that have a non zero count value:
    select c.id, a.name, count(*) as XYZ from CON c, CUST a
    where c.help !='1' and (c.id = a.id) group by c.id, a.name order by c.id;
    The results are:
    1 ME 3
    3 YOU 4
    What i want is to return all rows in CUST and the count, XYZ, that correspond to each row in CUST that matches the whare condition above, even if the count is zero.
    ie
    1 ME 3
    2 WE 0
    3 YOU 4
    Can this be done?

    You may want to get the counts then do the outer join. If you simply count with an outer join you will get 1 for 'WE' because there is a row in the cust table with 'WE'. This may work for you;
    with
      cust as (
       select 1 id, 'ME' name from dual union all
       select 2 id, 'YOU' name from dual union all
       select 3 id, 'WE' name from dual),
      con as (
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual)
    -- end of test data 
    select a.id, a.name, nvl(c.cnt,0) xyz
    from cust a, 
       (select id, help, count(*) cnt
       from con
       where help !='1'
       group by id, help) c
    where a.id = c.id(+)

Maybe you are looking for

  • How to process a form created in a pl/sql region

    Hi: I have a form that is generated using pl/sql and this form is displayed on a page in a 'pl/sql' region. The form displays a 'Submit' button which upon being clicked should return the user to the same page but with the contents of the form updated

  • 5081: XEngine error - Invalid guideline

    When a custome interchange.ecs file is used in the business protocol do you also have to register a custom group.ecs file or will it use the default group.ecs file? I'm getting an error message that says: 2008.01.18 at 11:31:05:968: Thread-15: B2B -

  • Mm related year ending

    send me the financial year ending process regarding material management customisation in detail.

  • Images in PDFs are too dark - wrong color, brightness, contrast

    I use my IPAD mainly for viewing medical books, e.g. radiological atlases. Most come in PDF format and most don't look much different on the IPAD than they do on PC. But it is very frustrating to find that the most important book I need looks incredi

  • How do you set Zen sleek drive space through softwa

    OK, So I have a Zen sleek and I accidentally cracked the screen. No problem, used a wire remote and still good. Except the jack on the Zen broke and it doesn't respond now. So I figure I'll use this as a glorified portable hard dri've, except the man