# 22. Virtuoso Functions Guide - set_row_count

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
__any_grants
close
collation_define
complete_table_name
delay
end_result
exec
exec_next
exec_result
exec_result_names
identity_value
name_part
registry_get
registry_get_all
registry_name_is_pro...
registry_remove
registry_set
result
result_names
row_count
sequence_get_all
sequence_next
sequence_remove
sequence_set
set_identity_column
set_row_count
set_user_id
signal
sinv_create_inverse
sinv_create_key_mapp...
sinv_drop_inverse
sys_stat_analyze
sys_stat_histogram
table_drop_policy
table_set_policy
username
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## set_row_count

sets the affected rows counter in the current context or in the context of the caller
integer set_row_count (in increment integer, [in what integer]);
Description

The function set_row_count () is used to set the affected rows counter in the current context or in the context of the caller. Therefore it can be used to set the affected rows counter (returned by row_count()) in places where an instead of trigger is used. If result of decrement of the affected rows counter is an negative integer it will be set to zero.

Parameters
increment – An integer to be added to the affected rors counter, can be negative also
what – The what have to be 0 or 1, 0 is the default. 0 - for update in current context the counter, 1 - to update the counter in context of the caller.
Return Types

The function returns new value of the affected rows , or -1 if action is not applicable.

Examples
Setting the affected rows counter in instead of trigger

The following SQL script will make two instead of triggers on atable "hid" and inside them will are called set_row_count to set the rows inserted or updated in the second table. Also there are two procedures which are used to demonstrate the return value of row_count.

    	  create table hid (id integer primary key, dt varchar);
    	  create table sho (id1 integer primary key, dt1 varchar);

    	  create trigger i_hid instead of insert on hid
    	  {
    	    insert into sho values (id, dt);
    	    set_row_count (row_count(), 1);
    	  };

    	  create trigger u_hid instead of update on hid
    	  {
    	    update sho set dt1 = dt where id1 = id;
    	    set_row_count (row_count(), 1);
    	  };

    	  create procedure test_ins ()
    	  {
    	    insert into hid select * from chid;
    	    return row_count();
    	  };

    	  create procedure test_upd ()
    	  {
    	    update hid set dt = '';
    	    return row_count ();
    	  };

See Also

row_count()