Forum OpenACS Development: help cursor+decode+ places package
apologies for the inexperienced question, there are a couple of things I am not sure how to do here:
- this package address-book depends on places. As far as I can see it is only used in this piece of code and a few times in the www dir. I read in the status document that we were looking to dump 'places', how do I do in this cases?
cursor address_is_orphan_p_cursor (address_id in pl_addresses.address_id%TYPE) is select decode(count(*),0,''t'',''f'') from place_element_map where place_id = address_is_orphan_p_cursor.address_id; v_address_is_orphan_p char(1); cursor subplace_rel_cursor (address_id in pl_addresses.address_id%TYPE) is select sr.rel_id from subplace_rels sr, acs_rels ar where ar.rel_id = sr.rel_id and ar.object_id_two = subplace_rel_cursor.address_id; v_rel_id subplace_rels.rel_id%TYPE;
few months ago. I don't have any of the code in front of me, but as I
recall, the Addressbook package either used an Address object type
provided by the Places package, or it provided it's own. I seem
remember that it used one provided by Places, in which case you're
going to have to gut that out and put somethin simpler of your own
If that cursor address_is_orphan_p_cursor really is just checking for
"orphan" address places in the Places tree, then you probably don't
need it at all!
-- Check if the address is an orphan open address_is_orphan_p_cursor(address_id => v_addresses_located_row.address_id); fetch address_is_orphan_p_cursor into v_address_is_orphan_p; close address_is_orphan_p_cursor; if v_address_is_orphan_p = 't' then -- Delete the address's subplace_relation open subplace_rel_cursor(address_id => v_addresses_located_row.address_id); fetch subplace_rel_cursor into v_rel_id; if not subplace_rel_cursor%NOTFOUND then subplace_rel.delete(v_rel_id); end if; close subplace_rel_cursor; -- Delete the address itself pl_address.delete(v_addresses_located_row.address_id); end if;
Can be replaced with:
select count(*) = 0 into v_address_is_orphan_p from place_element_map where place_id = v_addresses_located_row.address_id; if v_address_is_orphan_p then select sr.rel_id into v_rel_id from subplace_rels sr, acs_rels ar where ar.rel_id = sr.rel_id and ar.object_id_two = v_addresses_located_row.address_id; if FOUND then PERFORM subplace_rel__delete(v_rel_id); end if; PERFORM pl_address__delete(v_addresses_located_row.address_id); end if;
In addition, v_address_is_orphan_p needs to change from char(1) to boolean. Notice that the decode(... statement was replaced with select count(*) = 0. This evaluates to either 't' or 'f' depending on the value of count(*). This is a short-cut for converting decodes that evaluate to a simple boolean values. For more complex decodes, you need to use a case statement to port a decode statement. Something like:
select case when count(*) = 0 then 't' when count(*) = 3 then 't' else 'f' end into v_foo ...The above case statement returns true values for counts of 0 and 3 and it is equivalent to decode(count(*),0,'t',3,'t','f').
It is deprecated and not going to be ported. Address book needs to be re-written to support acs-reference which is available by cvs.
places was a monstsrosity that should be forgotten.
Jon's got his acs-references package "95% complete" or something like that (Jon?) and we want to start using that. It's certainly far enough along for you to do so even though it's not 100% done. I'm sure he'll be more than willing to answer questions via e-mail, etc.
I have almost all the data model ported. This was the last function and I will try to replace the calls to places with acs-references (that I haven't looked at).