set doc off

/*****************************************************************************
*
* Filename         - $Workfile:   $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - ULTRATRAK (Oracle Database)
*
* Source Code
* Identifier       - 
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema Stored Procedure
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2003
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   $  $Revision:   $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   $
*
****************************************************************************/

PROMPT create or replace procedure pm_store 

create or replace procedure pm_store (
        p_scanner_id  in  char,
        p_scan_time   in  char
)

as

        v_kit_id    kit.id%type;
        v_user_id   tagtrak_users.user_id%type;

begin

        begin

                select  id, user_id
                into    v_kit_id, v_user_id
                from    kit
                where   scanner_id = p_scanner_id;

        exception
                when NO_DATA_FOUND then
                        -- Return INVALID_PARAMETER to caller (see db_com.h)
                        raise_application_error(-20035,'Invalid parameter - scanner_id');

        end;

        insert into pm_results
        (
                pmr_id,
                pmr_kit_id,
                pmr_user_id,
                pmr_time,
                pmr_timestamp
        ) values
        (
                pmr_id_s.nextval,
                v_kit_id,
                v_user_id,
                to_number(p_scan_time),
                sysdate
        );
 
end pm_store;
/
