Forum OpenACS Development: Deleting service contract aliases

Collapse
Posted by Janine Ohmer on
Ok, I need a sanity check here.  I'm looking at some code that's not working for me, but if it was really bad I would have expected someone else to run into this before now.

Let's say my create script creates this alias:

        foo := acs_sc_impl.new_alias (
              'portal_datasource',
              'janines_portlet',
              'GetMyName',
              'janines_portlet::get_my_name',
              'TCL'
        );

The corresponding code in the drop script would be:

        foo := acs_sc_impl_alias.delete (
              'portal_datasource',
              'janines_portlet',
              'GetMyName'
        );

This is failing for me with this error:

ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "BP_DEV.ACS_SC_IMPL", line 37
ORA-06512: at "BP_DEV.ACS_SC_IMPL_ALIAS", line 45
ORA-06512: at "BP_DEV.ACS_SC_IMPL", line 112
ORA-06512: at line 6

I traced it to this line in acs_sc_impl_alias.delete():

v_impl_id := acs_sc_impl.get_id(impl_contract_name,impl_name);

This fails because it's looking for one row with contract_name of 'portal_datasource' and impl_name of 'janines_portlet', but there are multiple rows with that data - each alias is created with the same contract_name and impl_name, and varies only in the operation_name ('GetMyName' in the above example).

It seems to me that the select to get the impl_id, so it can be returned to the caller, should use the same where clause as the delete statement which follows it:

      delete from acs_sc_impl_aliases
      where impl_contract_name = acs_sc_impl_alias.delete.impl_contract_name
      and impl_name = acs_sc_impl_alias.delete.impl_name
      and impl_operation_name = acs_sc_impl_alias.delete.impl_operation_name;

Can someone knowledgeable about the service contract stuff please comment?

BTW, I know there is a Tcl API now but I was hoping to just get this script working without rewriting it, since it's not originally my code.

Thanks in advance!

Collapse
Posted by Janine Ohmer on
Hmm... I cleaned out the data by hand and now everything seems to be working ok.  I guess my gut instinct that this code has to be working was correct.  I must have had some cruft left over in the tables from previous errors.

Nevermind! :)