| |
182 |
182 |
returns integer as ' |
| |
183 |
183 |
declare |
| |
184 |
184 |
p_dimension_id alias for $1; |
| |
185 |
185 |
p_object_id alias for $2; |
| |
186 |
186 |
p_rating alias for $3; |
| |
187 |
187 |
p_title alias for $4; |
| |
188 |
188 |
p_package_id alias for $5; |
| |
189 |
189 |
p_date alias for $6; |
| |
190 |
190 |
p_user alias for $7; |
| |
191 |
191 |
p_ip alias for $8; |
| |
192 |
192 |
p_context_id alias for $9; |
| |
193 |
193 |
v_rating_id ratings.rating_id%TYPE; |
| |
194 |
194 |
begin |
| |
195 |
195 |
SELECT rating_id into v_rating_id |
| |
196 |
196 |
FROM ratings |
| |
197 |
197 |
WHERE dimension_id = p_dimension_id |
| |
198 |
198 |
and object_id = p_object_id |
| |
199 |
199 |
and owner_id = p_user; |
| |
200 |
200 |
|
| |
201 |
201 |
if v_rating_id is null then |
| |
202 |
|
PERFORM rating__new(null, p_dimension_id, p_object_id, p_rating, p_title, p_package_id, p_date, p_user, p_ip, p_context_id); |
| |
|
202 |
v_rating_id := rating__new(null, p_dimension_id, p_object_id, p_rating, p_title, p_package_id, p_date, p_user, p_ip, p_context_id); |
| |
203 |
203 |
else |
| |
204 |
204 |
UPDATE ratings |
| |
205 |
205 |
SET rating = p_rating |
| |
206 |
206 |
WHERE rating_id = v_rating_id; |
| |
207 |
207 |
|
| |
208 |
208 |
|
| |
209 |
209 |
UPDATE acs_objects |
| |
210 |
210 |
SET last_modified = coalesce(p_date,now()), modifying_user = p_user, modifying_ip = p_ip |
| |
211 |
211 |
WHERE object_id = v_rating_id; |
| |
212 |
212 |
end if; |
| |
213 |
213 |
|
| |
214 |
214 |
return v_rating_id; |
| |
215 |
215 |
end;' language 'plpgsql'; |
| |
216 |
216 |
|
| |
217 |
217 |
select define_function_args('rating__rate','dimension_id, object_id, rating, title, package_id, rated_on;now(), user_id, ip, context_id'); |