The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-24-2009
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 453
strange behavior of PSQL user defined function

Segregated the problematic portion, and showing for your view here.,

1. Following is the function definition,

Code:
create or replace function new_del(id integer) returns void as $$
begin
    raise info 'dollar :%',$1;
    delete from testing  where id=$1;
    end ;
$$
language 'plpgsql';
2. following is the table "testing" contains,
Code:
SELECT * from testing ;
 id
-----
 101
 102
 103
(3 rows)

3. When i call the function as
Code:
SELECT new_del('101');
INFO:  dollar :101
 new_del
---------

(1 row)
It deletes all the rows ! Why it is doing like this !

4. But when i change the name of the argument then the function behaves normally.

I changed the argument name "id" to id_field it behaved normally and deletes only the specified row.


Any help is appreciated.