Advertisement

08.19.2008 at 07:07PM PDT, ID: 23661807
[x]
Attachment Details

function is not updating

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6
Tags:

Postgres plpgsql

This is my first function in postgres.  It is supposed to do some simple updating.  I test it like this:

select mf_finalize_run(4293787,4329997,'mygroup',1100,51)

and it runs and returns 1.  But the fields that should be updated are not.

What am I missing in this function?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
-- Function: mf_finalize_run(integer, integer, character varying, integer, integer)
 
-- DROP FUNCTION mf_finalize_run(integer, integer, character varying, integer, integer);
 
CREATE OR REPLACE FUNCTION mf_finalize_run(integer, integer, character varying, integer, integer)
  RETURNS integer AS
'
declare
   ijob_id alias for $1;
   iset_id alias for $2;
   svgroup alias for $3;
   iotype alias for $4;
   iruntype_id alias for $5;
   
begin
   -- Check that we have valid arguments
   if (ijob_id is null) or (iset_id is null) or (svgroup is null) or (iotype is null) or (iruntype_id is null) then
      raise exception ''None of the arguments can be null'';
   end if;
 
   -- Make the run available
   update run_u set status = ''available''
      where vgroup = ''svgroup'' and job_id = ijob_id and runtype_id = iruntype_id;
 
   -- Link the runlink to the set
   update runlink_u set id_val = iset_id
      where tbl_otype = iotype and vgroup = ''svgroup'' and id in (
         select rl.id from run r
         inner join runlink rl on r.id=rl.run_id
         where rl.vgroup = ''svgroup'' and r.job_id = ijob_id and rl.tbl_otype = iotype
      );
 
   -- Time stamp the run
   update run_u set finish=now()
      where job_id = ijob_id and runtype_id = iruntype_id and job_vgroup = ''svgroup'';
 
   update run_u set failed=false
      where job_id = ijob_id and runtype_id = iruntype_id and job_vgroup = ''svgroup'';
	
   -- Mark run as finished
   update run_u set status = ''finished''
      where job_id = ijob_id and runtype_id = iruntype_id and job_vgroup = ''svgroup'';
 
   return 1;
end;
'
  LANGUAGE 'plpgsql' VOLATILE;
Answered By: Computer101
Expert Since: 04/07/2001
Accepted Solutions: 39510
Computer Expertise: Advanced
Computer101 has been an Expert for 7 years 9 months, during which he has posted 147804 comments and answered 39510 questions. Computer101 is just one of 236 experts in the PostgreSQL Database Zone. 2 experts collaborated on this answer, which was graded an "A" by the asker.
 
 
20081119-EE-VQP-47 / EE_QW_2_20070628