-------------------------------------------------------------------------------
--
--  @Copyright (c) 2002, Oracle Corporation. All rights reserved.
--  @headcom
--
--  Register the database services provider
--
--  This script registers the database services provider in the portal.
--  
--  Note:  This script must be run only after the script
--  services_install.sql has successfully been run.  The
--  register_provider api performs a validation check to
--  ensure that the provider implementation package exist
--  in the provider schema.
--
--  @param 1 The Portal schema
--  @param 2 The Provider schema
--
--  @usage   sqlplus <portal>/<portal>@mydb @services_register 
--           <portal_schema> <provider_schema>
--
--  @scope   Public
--
-------------------------------------------------------------------------------

set serveroutput on size 1000000
set define on

declare
    l_prov_rec     wwpro_api_provider_registry.provider_record;
    l_prov_id      integer;
begin

    l_prov_rec.name                 := 'DatabaseServicesProvider';
    l_prov_rec.display_name         := 'Database Services Provider';
    l_prov_rec.timeout              := 10;
    l_prov_rec.timeout_msg          := 'The Database Services Provider timed out';
    l_prov_rec.implementation_style := wwpro_api_provider_registry.DATABASE_IMPL;
    l_prov_rec.implementation_owner := '&&2';
    l_prov_rec.implementation_name  := 'services_provider';
    l_prov_rec.language             := wwctx_api.get_nls_language;
    l_prov_rec.login_frequency      := wwpro_api_provider_registry.LOGIN_FREQUENCY_NEVER;
    l_prov_rec.created_on           := sysdate;
    l_prov_rec.created_by           := '&&1';
    l_prov_rec.last_updated_on      := sysdate;
    l_prov_rec.last_updated_by      := '&&1';

    l_prov_id := wwpro_api_provider_registry.register_provider(l_prov_rec);
    commit;
    
    dbms_output.put_line('Database Services Provider successfully registered');

exception
    when others then
        dbms_output.put_line('ERROR: Could not register Database Services Provider');
        dbms_output.put_line('SQLERRM: ' || SQLERRM);
        rollback;
end;
/
