Incorrect SQL % RowCount value

Hello.

I created dblink of Oracle 11 g (11.2.0.4.3) for Sybase ASE database (15.5) using gateway of Oracle database for Sybase (11.2.0.4.3) on x 64 OEL (6.5).

When I make changes to a remote table with triggers and use the variable in the WHERE clause, SQL % RowCount value is miscalculated.
Found the antidote on the side of Sybase - the use of "set nocount on" within a trigger.
Is there a solution on the side of Oracle (database or gateway)?

Detailed description is given below:

Description table and relaxing 1) (Sybase)
create table test_TR)
identity of whole ID,
oper_id integer not null,
counter integer not null,
constraint XPKtest_TR primary key clustered (id))
go
insert into test_TR (oper_id, meter) values (1,10)
insert into test_TR (oper_id, meter) values (2.21)
insert into test_TR (oper_id, meter) values (2.36)
go

create trigger tUtest_TR on test_TR for UPDATE as
Start
declare @numrows int
Select @numrows = @@rowcount
return
error:
RAISERROR 31000 "UPDATE."
ROLLBACK transaction statement
end
go

(2) description gateway (gateway)
HS_FDS_CONNECT_INFO=xxx.xxx.xxx.xxx.xxx:XXXX/test
HS_FDS_RECOVERY_ACCOUNT = RECOVERY
HS_FDS_RECOVERY_PWD = *.
HS_FDS_TRANSACTION_MODEL = COMMIT_CONFIRM
HS_FDS_TRANSACTION_LOG = HS_TRANSACTION_LOG
HS_FDS_RESULTSET_SUPPORT = TRUE
HS_FDS_PROC_IS_FUNC = FALSE

(3) description Dblink (Oracle)
CREATE DATABASE LINK PUBLIC 'SYB_TEST' CONNECT TO ' * ' IDENTIFIED by ' * ' using 'SYB_TEST ';

(4) test query (Oracle)
declare per_id digital;
Start
Update "test_TR"@SYB_TEST "counter" value = "counter" + 1 where 'oper_id' = 0;
dbms_output.put_line ('0 rows =' |) SQL % number of lines);
PER_ID: = 0;
Update "test_TR"@SYB_TEST "counter" value = "counter" + 1 where 'oper_id' = per_id;
dbms_output.put_line ('0 rows =' |) SQL % number of lines);
Rollback;
end;
/

0 rows = 0
0 line = 1

Thanks in advance for any information!

filed Bug 19844303 - SQL % ROWCOUN RETURNS a VALUE INCORRECTE

Tags: Database

Similar Questions

  • % SQL rowcount returns 1, but he should return 2

    Oracle 10g

    Hi gurus

    I was reading one of the PL/SQL challenge site https://plsqlchallenge.oracle.com/pls/apex/f?p=10000:23:114157934581224:NOquestion: but can't get the exact idea.

    I appreciate if someone helps me to understand the code.

    Examples of data

    Set serveroutput on
    /
    drop table plch_stuff;
    /

    CREATE TABLE plch_stuff)
    ID INTEGER PRIMARY KEY,
    NM SINGLE VARCHAR2 (5))
    /

    create or replace procedure (plch_insert)
    insert_row_in IN BOOLEAN DEFAULT true)
    IS
    Start
    IF insert_row_in
    THEN
    INSERT INTO plch_stuff VALUES (1, 'Hat');
    END IF;
    END;
    /
    Start
    plch_insert;
    UPDATE plch_stuff SET nm = 'Hat ';
    dbms_output.put_line (' last count ='|) SQL % ROWCOUNT);
    END;

    Result

    Last Count = 1

    But according to my understanding, result = last count = 2 because a sql % rowcount for insert and then one to update. Please guide. Thank you

    Concerning

    Matt

    But according to my understanding, result = last count = 2 because a sql % rowcount for insert and then one to update. Please guide. Thank you

    Where did you got your "understanding"?

    When you have questions about the basic features Oracle, you must ALWAYS first check the documentation.

    A search on the web for "oracle 11g sql % rowcount" returns this as the first link

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/sql_cursor.htm

    % NUMBER OF LINES

    Returns the number of rows affected by a INSERT , UPDATE , or DELETE or returned by a statement SELECT INTO statement.

    The County refers to one, AND only ONE, statement - the last statement executed.

  • SQL ROWCOUNT %

    When I use SQL % ROWCOUNT, it returns the account = 1 if there is no record of the PRODUCT in the condition table

    SELECT count (*) from the PRODUCT v_count WHERE LOC = v_oldloc;

    dbms_output.put_line (' documents found in the PRODUCT table for column LOC with the value ' | v_oldloc |': ' |) SQL % ROWCOUNT);

    COMMIT;

    But, when I use the v_count to display the number of records, it returns ZERO (correct) as below

    SELECT count (*) from the PRODUCT v_count WHERE LOC = v_oldloc;

    dbms_output.put_line (' documents found in the PRODUCT table for column LOC with the value ' | v_oldloc |': ' | v_count);

    COMMIT;

    Please let me know if there is a problem with the code?

    Thanks in advance

    Hello

    % ROWCOUNT SQL returns you the number of lines that returns the query "SELECT count (*) in v_count PRODUCT WHERE LOC = v_oldloc;

    In fact, the query returns a row with the value 0. This is why SQL ROWCOUNT % gives you 1 as output.

    Of course v_count is 0 because it is what is the result of the query.

    Both are expected results in your case.

    Cheerz,

    Stako

  • SQLCODE and sql rowcount % in test conditions

    I'm translating a procedure of Ingres to oracle. I use the Oracle sql and sqlcode % rowcount
    variables instead of Ingres, iierrornumber and iirowcount.

    I replaced the names of ingres with the names of oracle and now wonder how how oracle uses these
    values.

    I use DBMS_OUTPUT. Put_line to display the content of rowcount % sqlcode and sql.

    What happens when I'm 'without selected lines. I have run the same query in the stand-alone command line
    and don't get any selected rows... "(and that's okay, because I do not have the corresponding data to)."

    But when I run it in the procedure, I don't get any value of sqlcode or sql % rowcount... the
    program just stops. The author used the ingres code to test if the data were there
    continue to do something else.

    If you get no rows returned, what it means, the sqlcode is 0? and the number of lines % sql is empty?
    That's why my DBMS_OUTPUT. Put_line does not display anything?

    my example...

    before this section in proceedings... after running another select statement that returns data...
    I use the DBMS to debug the values I spent...

    DBMS_OUTPUT. Put_line ('BEFORE sqlcode is' | sqlcode);
    DBMS_OUTPUT. Put_line ('until sqlrowcount is"| % rowcount sql);

    Select the table value
    WHERE condition = "Y"; > This selection will be made 'no return lines' and ignore the below DBMS_OUTPUTS - 2

    DBMS_OUTPUT. Put_line ('AFTER sqlcode is' | sqlcode);
    DBMS_OUTPUT. Put_line ("AFTER sqlrowcount is" | % rowcount sql);

    When I run the procedure... I get statements DBMS BEFORE and nothing after...
    BEFORE sqlcode is 0
    Sqlrowcount is 1 > > > > that's all that is displayed


    Given that I'm getting the 'no row returned. How oracle it round to the experience of someone?

    Thank you. I learn a lot from your comments and your information.

    Show us the full procedure please.

    I'm guessing that you have a generic WHEN catch of OTHER exception that swallows the NO_DATA_FOUND exception I expect to see (depending on what you posted).

  • Is it wrong to use SQL % ROWCOUNT = 0?

    Hello

    I have two tables, BILL and VALIDATIONS, have all two (LDAP_UID, TERM) as a composite key. I wrote a procedure to do the following:

    1. I use this composite key to extract some the key fields from the table of BILL, form a new row and insert it into the table VALIATIONS;
    2. prior to inserting into the table of VALIDATIONS, I use a SELECT statement to verify if the composite key already exists in the table of VALIDATION and not inserting at least that the composite key is not found.

    The procedure is the following:
    create or replace procedure save_transactions
       (i_ldap_uid IN varchar2, i_term IN varchar2)
    AS
       v_validated_ldap_uid validations.ldap_uid%type;
       v_student_id validations.student_id%type;
       v_first_name validations.first_name%type;
       v_last_name validations.last_name%type;
       v_term validations.term%type;
    BEGIN
       select ldap_uid
       into v_validated_ldap_uid
       from validations
       where ldap_uid = i_ldap_uid
       and term = i_term;
    
       if SQL%ROWCOUNT = 0 then
          select student_id, first_name, last_name
          into v_student_id, v_first_name, v_last_name
          from bill
          where ldap_uid = i_ldap_uid
          and term = i_term;
          insert into validations values (
          v_student_id, i_ldap_uid, v_first_name, v_last_name,
          i_term, sysdate, (to_char(sysdate, 'yymmdd'))||
          (select to_char(count(TRANSACTION_DATE)+1, 'fm0999') from VALIDATIONS where to_char(TRANSACTION_DATE) = to_char(sysdate))
          );
       end if;
    END;
    /
    The procedure is created and updated clean, without any error. But the error occurs when using it. If the line is already in table VALIDATIONS, the {color: blue} if SQL % ROWCOUNT = 0 {color} is fine and the insertion code block is bypassed. However, if the line is not found in the table of VALIDATION, I got the following error:
    SQL> execute save_transactions('john.brown', '200902')
    BEGIN save_transactions('john.brown', '200902'); END;
    
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at "ZBOV.SAVE_TRANSACTIONS", line 10
    ORA-06512: at line 1
    Well, for me, the whole use of SQL % ROWCOUNT is for testing. If he cannot test SQL ROWCOUNT = 0%, how else can test? However, I got the error and I must be wrong. But what is bad?

    Thanks a lot for your help!


    Newman

    Hello

    The "no data found" error is raised whenevde make you a select... IN the query and the query found no line.
    You can always include SELECT it... IN his own statement BEGIN block, with its own «EXCEPTION WHEN NO_DATA_FOUND» Manager... ", but often, there are easier ways to work around the problem.

    In this example, I can see two of these ways:

    (1) Say

    SELECT  COUNT (*)
    INTO    num_found
    FROM    transactions
    WHERE   ldap_uid = i_ldap_uid
    AND     term     = i_term;
    
       if num_found = 0 then
    ...
    

    "SELECT COUNT...". "without a GROUP BY will always return exactly one line, if you do not have to worry about the error"no data found ".

    (2) a better (but more difficult) solution: instead of making a "INSERT...". Statement of VALUES... ', using the results of the query on the Bill, make a

    INSERT  ...
    SELECT  ...
    FROM    bill
    WHERE   ...
    AND     NOT EXISTS
            (
            SELECT  1
            FROM    validations
            WHERE   ldap_uid = i_ldap_uid
            AND     term     = i_term
            );
    

    In fact, you have PL/SQL to do this (although there are good reasons to have a PL/SQL procedure that does nothing other than this INSERT statement).

  • The coldfusion.sql.QueryTable value cannot be converted to a number

    Hello

    I have two queries, in two different functions, who both return the SUM of a column based on the values of the arguments

    I need to subtract query from a query of 1 2.

    The arguments for the two motions are passed using the CreateObject function

    < cfset qry1 = createObject ("component", "components.adminobjects"). Func1(#argument1#,#argument2#) >

    < cfset qry2 = createObject ("component", "components.adminobjects"). Func1(#argument1#,#argument2#) >

    Queries executed accordingly and returns the results accordingly.

    The problem occurs when I try to calculate by subtracting the 2nd request form 1.

    So, to get the results I need, that's what I do:

    < cfset results = ' #qry1.sum # '-' #qry1.sum2 # ' >

    < cfoutput > #results # < / cfoutput >

    When I do this, it is said:

    The coldfusion.sql.QueryTable value cannot be converted to a number

    I don't understand, it is because when I exit #qry1.sum # or #qry1.sum2 # I get the numbers right and they are numbers, but when I do some math on them, I get the error.

    Any ideas?

    Thank you.

    Assuming that the qry1 object has a column named "sum1" and "sum2" try:

    Also note that the "sum" is a reserved word, try to change the column "sum" "sum1".

    http://help.Adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec173d0-7F ff.html

  • How to read the BIT of SQL Server value in CVI

    Hello

    I try to get a value of SQL Server 2005 (ture or false) bit in CVI (with SQL toolkit). I use the DBBindInt, but overall the return value is - 1.

    How can I get the real value of SQL?

    Thanks for your help

    Region

    Do you mean that you never receive the value FALSE, IE 0? Or you expect a TRUE value to be exactly 1? It is very common for TRUE to be represented as -1; If you are concerned just hide all the bits in the value returned with the exception of bit 0 - this will then give your alternative 0/1.

    JR

  • Display the Type SQL PL values

    Hello, team ,

    I use once in pl/sql table I want to know how to display the value of the type.

    DECLARE
    L_NUMBER PLCH_NUMBER_T := PLCH_NUMBER_T(1,2,5,6,0,2);
    BEGIN
    
      DBMS_OUTPUT.PUT_LINE('count='||L_NUMBER.COUNT);
      DBMS_OUTPUT.PUT_LINE('First='||L_NUMBER.FIRST);
      DBMS_OUTPUT.PUT_LINE('count='||L_NUMBER.LAST);
    end;
    

    Output as :-

    Count = 6

    First = 1

    Last = 6

    Number of() 3) := 5

    Number of() 6):= 2

    Can be...

    SQL > declare
    2 l_number plch_number_t: = plch_number_t (1,2,5,6,0,2);
    3. start
    4 because me in 1.l_number.count
    5 loop
    6 dbms_output.put_line ('number ('| to_char (i) |')-' | l_number (i));
    7 end of loop;
    8 end;
    9.
    Number (1) - 1
    Number (2) - 2
    Number (3)-5
    Number 4 - 6
    Number (5) - 0
    Number (6) - 2

    PL/SQL procedure successfully completed.

  • SQL HASH value?

    1. yesterday a request i run it took 1 min but today it is almost 5 minutes.

    could u please explain to me what is right.

    is it possible to run a query with the particular hash value, I want to say I can run this same query using the yesterdays hash value. ?

    > I mean I can run this same query using the yesterdays hash value

    No, you cannot use the HASH_VALUE or the SQL_ID of a SQL ' execute the SQL.  You must re-enter the SQL in the SQL (for example sqlplus or sqldeveloper or Toad) interpreter to run it.

    Hemant K Collette

  • SQL with parameter in SQL more value

    Hi the master Oracle,


    I have a request as described below that you run on SQL more.


    Select object_name, object_type from USER_OBJECTS WHERE last_ddl_time between trunc (sysdate)-1 and sysdate;


    I tried this script to be set, when I run it then SQL should ask two values.
    If I do not give any value then script should use by default as SYSDATE.

    Someone could please let me know how to do this?



    Kind regards
    Sandeep Sutar
    select object_name
          ,object_type
      from user_objects
    where trunc(last_ddl_time) between trunc(to_date(nvl(&1,sysdate))) -1 and to_date(nvl(&2,sysdate))
    
  • Change SQL in Valu Set

    Hello

    I need the SQL code in a value set to look at the MO: unit value at the level of responsibility for operation at the present time, it seems to be looking at the Site level. Could someone give me an example query please?

    Thank you

    SQL and PL/SQL FAQ

  • Result using Sql and value limits in the prompt 11.1.1.5 OBIEE

    Dear gurus,

    I invited hierarchy like this:
    Year
    Quarter
    Month

    Who use the value limit (quarter depends on the year, month depend on quarter), but I have question because null also appear in these guest
    I checked my database, display repository are not null.


    My question is, how to remove null in prompt when sql result cannot be used as well as the value limit, I don't know how to remove it by using the filter columns.
    NB: I already using presentation result variable sql in order to remove the null value and using the constraint, but it show nothing in fast mode unless press us the button apply.
    So I don't use this

    Help please, please enjoyed

    JOE

    Published by: JoeSSI on March 27, 2012 02:03

    Hello

    You can change your guest here you can find the show option, and then choose SQL result please change statement as below.

    SELECT the name of your column OF field where your name of the column is not null

    Go--> change your prompt--> Show--> Sql select result---> statement change as above.

    Second way.

    Go to the layer, and then double click on your column name here you can find * 'Nullable' * option please check.

    Go--> physical layer--> extract table--> select your name in the column--> double click on your name in the column--> here you can find option as Nullable, please check.

    Allocation of points, it is useful.

    Thank you
    Satya

  • Coil PL/SQL parameter value using shell script

    Hello

    I execute PL/SQL procedure using shell script. I want the value of parameter in a coil OUTPUT text file. to_msg is the IN OUT parameter in the script below. Is this possible?

    sqlplus test/***@db < < EOFSQL
    COIL Status.txt
    HEAD off SET
    SET SERVEROUTPUT ON
    declare
    to_msg varchar2 (8000): = 'status ';
    EXEC P_Status (to_msg);
    SPOOL off
    "exit";
    EOFSQL

    AravindhK wrote:
    Thanks for your reply. When I roll the result, sql statements is also copied to the text file. How can I eliminate the sql statements.

    What are the results when you do as below

    sqlplus-s

  • Guest column SQL limit values results filter

    I have a prompt Filter column showing values based on sql: SELECT task. "" Saw_0 task name ' OF THE 'Project - Cost' ORDER BY saw_0. This sql works and shows all tasks. However, I would like to have this prompt limits based on the prompt. As the option of limited values.

    Example: The user is prompted to select a project. The user has an lov and selects a project (s). Then, I would have the second guest with sql (SELECT task.) ("' Saw_0 name of the task" OF THE 'Project - Cost' ORDER BY saw_0) limit values selected on the first prompt. How do I would change sql to do this?

    Thank you

    If built correctly, you can check the checkbox 'Coercion' to the line of dashboard (you can not use a guest column for that!) and the task list would be forced by the selection of the prompt project.

    Otherwise, you must the guests of dashboard (with 2 'Go' buttons).

    The first prompt will have your projects you need to save a variable presentation, say pv_Project

    In the second line, you click the drop-down "Show" menu and change to "SQL results. Then, you need to add at the end of the SQL statement, which suite:

    WHERE the table. "Project = ' @{pv_Project}"

  • Find SQL hash value statements

    Oracle Database 10g
    Red Hat Linux

    One of our developers wants to recover the full 3 days sql statements. I have the hash value of statspack at this time.

    I get the following.

    Select SQL_FULLTEXT from v$ sqlarea where HASH_VALUE = 98832848;

    no selected line


    Is the statement that I used is the right? Is - this way? I get no return, does that mean that these SQL statements have aged?

    This database is only about 16 GB and SGA Total is only about 1.3 GB.

    If its 3 days it would be aged. Since you're on 10g, try mark dba_hist_sql_text who would be the oldest stored sqls provided your AWR retention period is in order.

    Aman...

Maybe you are looking for

  • Qosmio G40 - graphics card keeps overheating and crashing all at stake

    My nVidia 8600GT card in my laptop Qosmio G40 overheating guard and crashing when I m gaming. It works all the games that I put on it fine, but overheating then crashes and me kicks off the games I play m.Is it just because it s a laptop and it s inc

  • Pavillion zd7000: keyboard on zd7000

    I have tried everything with my zd7000, including a new keyboard but the keyboard still does not work. Finally I used it about 8 months ago and everything was fine. I put in the driver discs and no luck, then went to HP driver updates. I use a keyboa

  • Can we run traceroute of sourcefire defense center

    Hoe do run us a trace of the DC for the sensor, and vice versa. I'm going to DC 3500 and sensor series 1000 and 7000 and 8000 3d.

  • Error starting 11g XE

    Hi Experts,I installed 11g XE on Linux VM. When I tried the following:$ sqlplus / as sysdbaSQL * more: version 11.2.0.2.0 Production on my Sep 26 18:35:04 2014Copyright (c) 1982, 2011, Oracle.  All rights reserved.ERROR:ORA-01031: insufficient privil

  • Acrobat Standard DC is available on CC for teams?

    I currently have 6 users on CC for teams and a bunch of old licenses of Acrobat X autonomous.I have a new user who needs Acrobat Standard, and I want to put that on a subscription Acrobat DC.Is there a way I can do that as the COMPUTER administrator,