-- ==================================================================
-- SP__insert_ac_id 
-- adds an ari collection to the database
-- Parameters:
-- in 
-- 		p_num_entries int(10) unsigned - number of entries in the ac
-- 		p_use_desc varchar - human readable description
-- OUT 
-- 		r_ac_id int(10) unsigned- id of the ac
-- ==================================================================
SP__insert_ac_id(IN p_num_entries int(10) unsigned, p_use_desc varchar,  OUT r_ac_id int(10) unsigned)



-- ==================================================================
-- SP__insert_ac_formal_entry 
-- adds a formal ari entry into the database. 
-- stops if the order_num is > the number of entries for the target ac
-- Parameters:
-- in 
-- 		p_ac_id int(10) unsigned - id of the ari collection this entry belongs to
-- 		p_definition_id int(10) unsigned - id of the definition   
-- 		p_order_num int(10) unsigned - order number
-- OUT 
-- 		r_ac_entry_id int(10) unsigned - entry id 
-- ==================================================================
SP__insert_ac_formal_entry(IN p_ac_id int(10) unsigned, p_definition_id int(10) unsigned,  p_order_num int(10) unsigned, OUT r_ac_entry_id int(10) unsigned)

-- ==================================================================
-- SP__insert_ac_actual_entry 
-- adds a actual ari entry into the database. 
-- stops if the order_num is > the number of entries for the target ac
-- Parameters:
-- in 
-- 		p_ac_id int(10) unsigned - id of the ari collection this entry belongs to
-- 		p_definition_id int(10) unsigned - id of the definition   
-- 		p_order_num int(10) unsigned - order number
-- OUT 
-- 		r_ac_entry_id int(10) unsigned - entry id 
-- ==================================================================
SP__insert_ac_actual_entry(IN p_ac_id int(10) unsigned, p_definition_id int(10) unsigned, p_order_num int(10) unsigned, 
OUT r_ac_entry_id int(10) unsigned)


-- ==================================================================
-- SP__insert_actual_parmspec
--  inserting an actual parmspec into db
-- IN 
-- 		p_fp_spec_id int(10) unsigned - the id of the formal parm spec for this actual parmspec
-- 		p_num_parms int(10) unsigned - number of parms 
-- 		p_use_desc varchar - human readable description
-- OUT 
-- 		r_ap_spec_id int(10) unsigned - id of the parmspec in the db 
-- ==================================================================
SP__insert_actual_parmspec(IN p_fp_spec_id int(10) unsigned, p_num_parms int(10) unsigned, p_use_desc varchar, OUT r_ap_spec_id int(10) unsigned)


-- ==================================================================
-- SP__insert_actual_parms_object
--  inserting an actual parm object into spec
-- IN 
-- 		p_ap_spec_id int(10) unsigned -  id of the spec this object is being added 
-- 		p_order_num int(10) unsigned -  order number
-- 		p_data_type_id int(10) unsigned - the id of the datatype in the data type table
-- 		p_obj_actual_definition int(10) unsigned - id of the object for the parm
-- ==================================================================
SP__insert_actual_parms_object(IN p_ap_spec_id INT(10) unsigned, p_order_num int(10) unsigned, p_data_type_id varchar , p_obj_actual_definition INT(10) UNSIGNED)



-- ==================================================================
-- SP__insert_actual_parms_names
--  inserting an actual parm reference by name into spec. This parm gets it value from the object that defines this parm spec 
-- IN 
-- 		p_ap_spec_id int(10) unsigned -  id of the spec this object is being added 
-- 		p_order_num int(10) unsigned -  order number
-- 		p_data_type_id int(10) unsigned - the id of the datatype in the data type table
-- 		p_fp_id int(10) unsigned - id of the formal parm this parm reference
-- ==================================================================
SP__insert_actual_parms_names(IN p_ap_spec_id INT(10) unsigned, p_order_num int(10) unsigned, p_data_type_id varchar, p_fp_id INT(10) UNSIGNED)


-- ==================================================================
-- SP__insert_actual_parms_tnvc
--  inserting an actual parm tnvc into spec.
-- IN 
-- 		p_ap_spec_id int(10) unsigned -  id of the spec this object is being added 
-- 		p_order_num int(10) unsigned -  order number
-- 		p_data_type_id int(10) unsigned - the id of the datatype in the data type table
-- 		p_tnvc_id int(10) unsigned - id of the type name value collection
-- ==================================================================
SP__insert_actual_parms_tnvc(IN p_ap_spec_id INT(10) unsigned, p_order_num int(10) unsigned, p_tnvc_id INT(10) UNSIGNED)

-- ==================================================================
-- sp for inserting a single entry into a tnvc 
-- SP__insert_tnvc_entry
-- IN 
-- 		p_tnvc_id int(10) unsigned - id of tnvc this entry belongs to 
-- 		p_order_num int(10) unsigned - order number of this entry 
-- 		p_data_type_name varchar -  data type name 
-- 		p_data_name varchar - name of the tnvc 
-- 		p_definition_id int(10) unsigned - definition of the object could be literal
-- OUT 
-- 		r_tnvc_entry_id int(10) unsigned - id of this entrty
-- ==================================================================
SP__insert_tnvc_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned, p_data_type_name varchar, p_data_name varchar, 
p_definition_id int(10) unsigned, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_obj_entry
--  insert a new tnvc entry that is an ADM object
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   int(10) unsigned - id for this actual object
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
--      
-- ================================================================== 
SP__insert_tnvc_obj_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value int(10) unsigned, OUT r_tnvc_entry_id int(10) unsigned)


-- ==================================================================
--  SP__insert_tnvc_int_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   int(10)- value for this int_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_int_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value int(10, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_uint_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   int(10) unsigned - value for this uint_entry
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
--      
-- ================================================================== 
SP__insert_tnvc_uint_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value int(10) unsigned, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_vast_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   bigint - value for this vast_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_vast_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value bigint, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_uvast_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   bigint unsigned - value for this uvast_entry
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
--      
-- ================================================================== 
SP__insert_tnvc_uvast_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value bigint unsigned, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_real32_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   float- value for this real32_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_real32_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value floa, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_real64_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   double- value for this real64_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_real64_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value doubl, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_string_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   varchar- value for this string_entry
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
--      
-- ================================================================== 
SP__insert_tnvc_string_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value varchar(255, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_bool_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   bool- value for this bool_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_bool_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value boo, OUT r_tnvc_entry_id int(10) unsigned)

-- ==================================================================
--  SP__insert_tnvc_byte_entry
--  insert a new tnvc entry for the specific primitive data type
--  in
--      p_tnvc_entry_id int unsigned - the id for this tnvc this entry belongs to
--      p_order_num int unsiged - the order number of the entry 
--      p_data_name varchar - optional name of this tnv
--      p_entry_value   tinyint- value for this byte_entry
--      
--  out 
--      r_tnvc_entry_id int unsigned - id of this entry
-- ================================================================== 
SP__insert_tnvc_byte_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned,  p_data_name varchar, p_entry_value tinyin, OUT r_tnvc_entry_id int(10) unsigned)


-- ==================================================================
-- SP__insert_actual_parms_ac
--  inserting an actual parm ac into spec.
-- IN 
-- 		p_ap_spec_id int(10) unsigned -  id of the spec this object is being added 
-- 		p_order_num int(10) unsigned -  order number
-- 		p_data_type_id int(10) unsigned - the id of the datatype in the data type table
-- 		p_ac_id int(10) unsigned - id of the ari collection
-- ==================================================================
SP__insert_actual_parms_ac(IN p_ap_spec_id INT(10) unsigned, p_order_num int(10) unsigned, p_ac_id INT(10) UNSIGNED)


-- ==================================================================
-- SP__insert_agent
--  inserting a new agent into the system
-- IN 
-- 		p_agent_id_string- name of the agent to insert 
-- OUT
-- 		r_registered_agents_id - teh id of the agent in the db
-- ==================================================================
SP__insert_agent(IN p_agent_id_string varchar, OUT r_registered_agents_id INT(10) unsigned)



-- ==================================================================
-- SP__insert_const_actual_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the constant 
-- 		p_data_type varchar -  name of the data type for the constant 
--  	p_data_value_string varchar - blob conating the encoded value of the constant 
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
SP__insert_const_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_data_type varchar, p_data_value_string varchar, OUT r_actual_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_const_actual_definition
-- cna us either hte name or the id of the constant to delete 
-- Parameters:
-- in 
--  	p_obj_id int unsigned -  id of the constan to delete 
-- 		p_obj_name varchar -   name of the constant to delete
-- ==================================================================
SP__delete_const_actual_definition(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_control_formal_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the constant 
-- 		p_data_type varchar -  name of the data type for the constant 
--  	p_data_value_string varchar - blob conating the encoded value of the constant 
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
SP__insert_control_formal_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_fp_spec_id int(10) unsigned, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_control_formal_definition;
-- Parameters:
-- in 
--     p_obj_id  - id of the control to delete
--     p_obj_name - name of the control to delete 
-- ==================================================================
SP__delete_control_formal_definition(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_const_actual_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the constant 
-- 		p_data_type varchar -  name of the data type for the constant 
--  	p_data_value_string varchar - blob conating the encoded value of the constant 
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
SP__insert_control_actual_definition(IN p_obj_definition_id int(10) unsigned, p_ap_spec_id int(10) unsigned, p_use_desc varchar, OUT r_instance_id int(10) unsigned)


-- ==================================================================
-- SP__delete_control_actual_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - actual_definiton id of the control that is to be deleted
--     p_obj_name varchar- name of the control to delete, this allows to delete all the actual definitons 
-- ==================================================================
SP__delete_control_actual_definition(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_edd_formal_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the edd 
-- 		p_data_type varchar -  name of the data type for the edd 
--  	p_data_value_string varchar - blob conating the encoded value of the edd
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
SP__insert_edd_formal_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_fp_spec_id int(10) unsigned, p_external_data_type varchar, OUT r_formal_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_edd_actual_definition;
-- Parameters:
-- in 
--      p_obj_id int unsigned - id for the edd to delete 
-- 		p_obj_name varchar -  name of the edd  to delete 
--
-- ==================================================================
SP__delete_edd_formal_defintion(IN p_obj_id int(10) unsigned, p_obj_name varchar)



-- ==================================================================
-- SP__insert_edd_actual_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the constant 
-- 		p_data_type varchar -  name of the data type for the constant 
--  	p_data_value_string varchar - blob conating the encoded value of the constant 
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
SP__insert_edd_actual_definition(IN p_obj_definition_id int(10) unsigned, p_use_desc varchar, p_ap_spec_id int(10) unsigned,  OUT r_actual_definition_id int(10) unsigned)


-- ==================================================================
-- SP__insert_edd_actual_definition;
-- Parameters:
-- in 
--     p_obj_id int unsigned - id for the object metadata
--      p_use_desc varchar - humanreadable description of the constant 
-- 		p_data_type varchar -  name of the data type for the constant 
--  	p_data_value_string varchar - blob conating the encoded value of the constant 
-- out
-- 		r_actual_definition_id int(10) unsigned id of the actual defintion entry 
-- ==================================================================
-- for instance can supply the definiton name to remove all the instances of that definition or can remove 
SP__delete_edd_actual_definition(IN p_actual_definition_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_expression 
-- adds an expression to the database
-- Parameters:
-- in 
-- 		p_out_type int(10) unsigned - data type id for the return type of the expression  
-- 		p_num_operators int(10) unsigned - number of operators   
-- 		p_postfix_ids_list varchar(1000) - id of the ac that lists the equation in postfix notation
-- OUT 
-- 		r_expr_id int(10) unsigned - id of the expr in the database
-- =================================================================
SP__insert_expression(IN p_out_type INT(10) UNSIGNED, p_postfix_operations INT(10) UNSIGNED, OUT r_expr_id INT(10) UNSIGNED)


-- ==================================================================
-- SP__delete_expression 
-- Delete an expression from the database
-- Parameters:
-- in 
-- 		p_expr_id int(10) unsigned - id of the expr in the database to delete
-- ==================================================================
SP__delete_expression(IN p_expr_id INT(10) UNSIGNED)



-- ==================================================================
-- SP__insert_formal_parmspec
-- inserts a new formal parmspec in the db
-- IN 
-- 		p_num_parms int(10) unsigned - number if parms in the spec
-- 		p_use_desc varchar - human readable p
-- OUT 
-- 		r_fp_spec_id int(10) unsigned -  the id of the spec 
-- ==================================================================
SP__insert_formal_parmspec(IN p_num_parms int(10) unsigned, p_use_desc varchar,  OUT r_fp_spec_id int(10) unsigned)



-- ==================================================================
-- SP__insert_formal_parmspec_entry
-- insert a single entry into a formal parm
-- IN 
--      p_fp_spec_id int(10) unsigned - id of the formal parmspec for this entry    
--      p_order_num int(10) unsigned - order of the entry in the parmspec
--      p_parm_name varchar - name of the parm used for parm by name 
--      p_data_type varchar - data type of the parm
--      p_obj_definition_id int(10) unsigned -  optional default value of this parm
-- OUT 
--      r_fp_id int(10) unsigned
-- ==================================================================
SP__insert_formal_parmspec_entry(IN p_fp_spec_id int(10) unsigned,  p_order_num int(10) unsigned, p_parm_name varchar, p_data_type varchar, p_obj_definition_id int(10) unsigned, OUT r_fp_id int(10) unsigned)


-- ==================================================================
-- SP__insert_literal_actual_definition 
-- IN 
-- 		p_obj_id int(10) unsigned - id of the metadata info 
-- 		p_use_desc varchar - human readable p
-- 		p_data_type varchar - primitive data type of the literal
-- 		p_data_value_string varchar - calue of the literal encoded as a string 
-- OUT 
-- 		r_definition_id int(10) unsigned - id of the literal
-- ==================================================================
SP__insert_literal_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_data_type varchar, p_data_value_string varchar, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_literal_actual_definition 
-- IN 
--      p_obj_id int(10) unsigned - id of the lit to be deleted
-- ==================================================================
SP__delete_literal_actual_definition(IN p_obj_id int(10) unsigned)


-- ==================================================================
-- SP__insert_macro_formal_definition
-- IN
-- 		p_obj_id int(10) unsigned - id of the metadata info 
-- 		p_use_desc varchar - human readable p
--      p_fp_spec_id int(10) unsigned - formal parmspec of the macro
--      p_max_call_depth int(10) unsigned - max call depth of the macro
--      p_definition_ac int(10) unsigned - ari collection definining the macro
-- OUT
-- 		r_definition_id int(10) unsigned - id of the new formal definition	 
-- ==================================================================
SP__insert_macro_formal_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_fp_spec_id int(10) unsigned, p_max_call_depth int(10) unsigned, p_definition_ac int(10) unsigned, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_mac_formal_defintion
-- IN 
--      p_obj_id int(10) unsigned - id of the macro to be deleted
-- 	 	p_obj_name varchar - name of the macro to delete
-- ==================================================================
SP__delete_mac_formal_defintion(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_macro_actual_definition
-- -- IN
-- 		p_obj_id int(10) unsigned - id of the metadata info 
--      p_ap_spec_id int(10) unsigned - actual parmspec id
--      p_actual_ac int(10) unsigned - ari collection containg all actual ARI for this macro
--      p_use_desc varchar - human readable description
-- OUT
-- 		r_actual_id int(10) unsigned - id of the new actual definition	
-- ==================================================================
SP__insert_macro_actual_definition(IN p_obj_definition_id int(10) unsigned, p_ap_spec_id int(10) unsigned, p_actual_ac int(10) unsigned, p_use_desc varchar, OUT r_actual_id int(10) unsigned)



-- ==================================================================
-- SP__delete_mac_actual_definition
-- IN 
--      p_obj_id int(10) unsigned - id of the macro to be deleted
-- 	 	p_obj_name varchar - name of the macro to delete
-- ==================================================================
-- for actual can supply the definiton name to remove all the actuals of that definition or can remove 
SP__delete_mac_actual_definition(IN p_inst_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_outgoing_message_set
-- IN 
-- 		p_created_ts int(10) unsigned - created timestamp
-- 		p_modified_ts int(10) unsigned - modified timestamp
-- 		p_state int(10) unsigned - state of the message set 
-- 		p_agent_id int(10) unsigned - agent of this message 
-- OUT 
-- 		r_set_id int(10) unsigned - id of the set
-- ==================================================================
SP__insert_outgoing_message_set(IN p_created_ts int(10) unsigned, p_modified_ts int(10) unsigned, p_state int(10) unsigned, p_agent_id int(10) unsigned, OUT r_set_id int(10) unsigned)


-- ==================================================================
-- SP__insert_outgoing_message_entry
-- IN 
-- 		p_set_id int(10) unsigned - id of the outgoing message set this entry belongs to
--      p_message_order int(10) unsigned - order of this message in the set
--      p_start_ts int(10) unsigned - start time 
--      p_ac_id int(10) unsigned - ac of this message 
-- OUT 
--      r_message_id int(10) unsigned - id of this message
-- ==================================================================
SP__insert_outgoing_message_entry(IN p_set_id int(10) unsigned, p_message_order int(10) unsigned, p_start_ts int(10) unsigned, p_ac_id int(10) unsigned, OUT r_message_id int(10) unsigned)


-- ==================================================================
-- SP__insert_incoming_message_set
-- IN 
-- 		p_created_ts int(10) unsigned - created timestamp
-- 		p_modified_ts int(10) unsigned - modified timestamp
-- 		p_state int(10) unsigned - state of the message set 
-- 		p_agent_id int(10) unsigned - agent of this message 
-- OUT 
-- 		r_set_id int(10) unsigned - id of the set
-- ==================================================================
SP__insert_incoming_message_set(IN p_created_ts int(10) unsigned,
p_modified_ts int(10) unsigned, p_state int(10) unsigned, p_agent_id int(10) unsigned, OUT r_set_id int(10) unsigned)


-- ==================================================================
-- SP__insert_incoming_message_entry
-- IN 
-- 		p_set_id int(10) unsigned - id of the outgoing message set this entry belongs to
--      p_message_order int(10) unsigned - order of this message in the set
--      p_start_ts int(10) unsigned - start time 
--      p_ac_id int(10) unsigned - ac of this message 
-- OUT 
--      r_message_id int(10) unsigned - id of this message
-- ==================================================================
SP__insert_incoming_message_entry(IN p_set_id int(10) unsigned, p_message_order int(10) unsigned, p_start_ts int(10) unsigned, p_ac_id int(10) unsigned, OUT r_message_id int(10) unsigned)


-- ==================================================================
-- SP__insert_namespace
--    insert a new namespace into the db
-- Parameters:
-- in 
--      p_namespace_type varchar - type of the namespace
-- 		p_issuing_org varchar - name of the issuing organization for this ADM.
-- 		p_name_string varchar- his is the human-readable name of the ADM that should appear
--           in message logs, user-interfaces, and other human-facing
--           applications
-- 		p_version varchar -This is a string representation of the version of the ADM.
--           ADM version representations are formated at the discretion of
--           the publishing organization.
-- out 
-- 		r_namespace_id int(10) unsigned - id of the namespace in the database 
-- ==================================================================
SP__insert_namespace(IN p_namespace_type varchar, p_issuing_org varchar, p_name_string 
varchar, p_version varchar, OUT r_namespace_id int(10) unsigned)


-- ==================================================================
-- SP__insert_network_defined_namespace
--    insert a new network defined adm into the db
-- Parameters:
-- in 
-- 		p_issuing_org varchar - name of the issuing organization for this ADM.
-- 		p_name_string varchar- this is the human-readable name of the ADM that should appear
--           in message logs, user-interfaces, and other human-facing
--           applications
-- 		p_version varchar -This is a string representation of the version of the ADM.
--           ADM version representations are formated at the discretion of
--           the publishing organization.
-- 		p_issuer_binary_string varchar - any string that identifies the organization that is
-- 			  defining an AMM object
-- 	    p_tag varchar - any string used to disambiguate AMM Objects for an Issuer
-- out 
-- 		r_namespace_id int(10) unsigned - id of the namespace in the database 
-- ==================================================================
SP__insert_network_defined_namespace(IN p_issuing_org varchar, p_name_string varchar, 
p_version varchar, p_issuer_binary_string varchar, p_tag varchar, OUT r_namespace_id int(10) unsigned)



-- ==================================================================
-- SP__insert_network_defined_namespace
--    insert a new moderated adm into the db
-- Parameters:
-- in 
-- 		p_issuing_org varchar - name of the issuing organization for this ADM.
-- 		p_name_string varchar- this is the human-readable name of the ADM that should appear
--           in message logs, user-interfaces, and other human-facing
--           applications
-- 		p_version varchar - This is a string representation of the version of the ADM.
--           ADM version representations are formated at the discretion of
--           the publishing organization.
-- 		p_adm_name_string varchar -  this is the human-readable name of the ADM that should appear
--           in message logs, user-interfaces, and other human-facing
--           applications
-- 		p_adm_enum int(10) unsigned - an unsigned integer in the range of 0 to
-- 			 (2^64)/20
-- 		p_adm_enum_label varchar - labeled based on the number of bytes
-- 			of the Nickname as a function of the size of the ADM enumeration
-- 		p_use_desc varchar - human readable use description
-- out
-- 		r_namespace_id int(10) unsigned - id of the namespace in the database 
-- ==================================================================
SP__insert_adm_defined_namespace(IN p_issuing_org varchar, p_namespace_string varchar, 
p_version varchar, p_adm_name_string varchar, p_adm_enum int(10) unsigned, p_adm_enum_label varchar, 
p_use_desc varchar, OUT r_namespace_id int(10) unsigned) 



-- ==================================================================
-- Parameters:
-- in 
-- 		p_obj_type varchar - object of the type
--      p_obj_name varchar -  human readable name of the new object
--      p_namespace_id int unsigned - namespace this object belongs to
-- out 
-- 		r_obj_id int(10) unsigned - id of the new object in the database
-- ==================================================================
SP__insert_obj_metadata(IN p_obj_type varchar, p_obj_name varchar, p_namespace_id int(10) unsigned, OUT r_obj_id int(10) unsigned)



-- ==================================================================
-- SP__delete_obj_metadata
-- Parameters:
-- in 
-- 		p_obj_id INT UNSIGNED - id of the metadata to delete 
-- ==================================================================
SP__delete_obj_metadata(IN p_obj_id INT UNSIGNED)



The formal and actual object stored procedures are usually called by other stored procedures and not standalone
-- ==================================================================
-- Parameters:
-- in  
-- 		p_obj_metadata_id int unsigned - 
-- 		p_use_desc varchar - 
-- out 
-- 		r_formal_id int unsigned - 
-- ==================================================================
SP__insert_obj_formal_definition(IN p_obj_metadata_id int(10) unsigned, p_use_desc varchar, OUT r_formal_id int(10) unsigned)


-- ==================================================================
-- Parameters:
-- IN 
--      p_obj_metadata_id int(10) unsigned - 
--      p_use_desc varchar - 
-- OUT 
--      r_actual_id int(10) unsigned - 
--
-- out 
-- ==================================================================
SP__insert_obj_actual_definition(IN p_obj_metadata_id int(10) unsigned, p_use_desc varchar, OUT r_actual_id int(10) unsigned)



-- ==================================================================
-- can use name or id for to delete 
-- Parameters:
-- in 
-- 		p_obj_id int(10) unsigned - Id of the specific obj to delete 
-- 		p_obj_name varchar - name of the obj to delete 
-- ==================================================================
SP__delete_obj_formal_definition(p_obj_id int(10) unsigned, p_obj_name varchar )


-- ==================================================================
-- Parameters:
-- in 
-- 		p_act_id int UNSIGNED
--  	p_obj_name varchar
-- 		p_namespace_id int UNSIGNED 
-- ==================================================================
-- for just removing the obj instance 
-- two options for removal if you want to remove a specific instance you can specify the instance id, 
-- or if you want to remove all the instances of a specific definition you can supply the definition name
-- TODO: can add another option of adding a number and only removes up to that number of entries.
-- maybe too overloaded
SP__delete_obj_actual_definition(p_act_id int(10) UNSIGNED, p_obj_name varchar )  


-- ==================================================================
-- create a report template formal def
-- SP__insert_report_template_metadata_format 
-- IN 
-- 		p_obj_id int(10) unsigned - metadata id for this report
-- 		p_use_desc varchar - human readable use description
-- 		p_formal_parmspec_id int(10) unsigned - formal parameter spec id 
-- 		p_ac_id int(10) unsigned - ac for the report definition
-- 		 
-- OUT 
-- 		r_definition_id int(10) unsigned - id of this formal report 
-- ==================================================================
SP__insert_report_template_formal_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_formal_parmspec_id int(10) unsigned, p_ac_id int(10) unsigned, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__insert_operator_actual_definition
-- IN 
-- 		p_obj_id int(10) unsigned - metadata id for this report
-- 		p_use_desc varchar - human readable use description
-- 		p_use_desc varchar - human readable use description
-- 		p_result_type varchar - data type of the result 
-- 		p_num_inputs int(10) unsigned - number of inputs for the operator 
-- 		p_tnvc_id int(10) unsigned -  
-- OUT 
-- 		r_definition_id int(10) unsigned - actual id of this operator
-- ==================================================================
SP__insert_operator_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, 
p_result_type varchar, p_num_inputs int(10) unsigned, p_tnvc_id int(10) unsigned,  OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_oper_actual_defintion
-- IN 
-- 		p_obj_id int(10) unsigned - id of this op to delete,  
-- 		p_obj_name varchar - name of this op to delete 
-- ==================================================================
SP__delete_oper_actual_defintion(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- for adding state based rules into the database 
-- SP__insert_sbr_actual_definition 
-- IN 
-- 		p_obj_id int(10) unsigned - metadata id of this SBR
-- 		p_use_desc varchar- human readable description
-- 		p_expr_id int(10) UNSIGNED, - id of the expresion for this rule
-- 		p_ac_id int(10) UNSIGNED, - id of the ari collection that defines the action of this rule 
-- 		p_start_time time - whem this rule starts 
-- OUT 
-- 		r_definition_id int(10) unsigned - id of the start 
-- ==================================================================
SP__insert_sbr_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar,  p_expr_id int(10) UNSIGNED, p_ac_id int(10) UNSIGNED, p_start_time time , OUT r_definition_id int(10) unsigned)



-- ==================================================================
-- SP__delete_sbr_actual_definition;
-- Parameters:
-- in 
--      p_obj_id int unsigned - id for the sbr to delete 
-- 		p_obj_name varchar -  name of the sbr to delete --
-- ==================================================================
SP__delete_sbr_actual_definition(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_table_template_actual_definition
-- IN
-- 		p_obj_id int(10) unsigned - obj_metadata id
-- 		p_use_desc varchar - human readble use desc
-- 		p_num_columns int(10) unsigned -  number of columns in the table
-- 		p_column_names_list varchar(10000) -  list of column names 
-- 		p_column_types_list varchar(10000) - list of column type
-- OUT 
-- 		r_definition_id int(10) unsigned - id of the the new table
-- ==================================================================
SP__insert_table_template_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, p_columns_id int(10) unsigned, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__insert_table_template_actual_definition 
-- IN 
-- 		p_obj_id int(10) unsigned - id of the table to delete 
-- 		p_obj_name varchar -- name of the object to delete 
-- ==================================================================
SP__delete_table_template_actual_definition(IN p_obj_id int(10) unsigned)


-- ===============================================================
-- SP__insert_tbr_actual_definition 
-- IN
-- 		p_obj_id int(10) unsigned - metadata id
-- 		p_use_desc varchar - human readable descriptionb
-- 		p_wait_per time  - how long to wait before starting 
-- 		p_run_count bigint unsigned - number of times to run 
-- 		p_start_time time - when to start 
-- 		p_ac_id int(10) UNSIGNED - ac of the actions for this rules 
-- OUT 
-- 		r_definition_id int(10) unsigned - id of this tbr
-- ===============================================================
SP__insert_tbr_actual_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, 
p_wait_per time, p_run_count bigint unsigned, p_start_time time, p_ac_id int(10) UNSIGNED, OUT r_definition_id int(10) unsigned)


-- ==================================================================
-- SP__delete_tbr_actual_definition;
-- Parameters:
-- in 
--      p_obj_id int unsigned - id for the tbr to delete 
-- 		p_obj_name varchar -  name of the tbr to delete --
-- ==================================================================
SP__delete_tbr_actual_definition(IN p_obj_id int(10) unsigned, p_obj_name varchar)


-- ==================================================================
-- SP__insert_tnvc
-- inserts a new tnv collection definition into the db
-- IN
-- 		p_num_entries int(10) unsigned - number of entries in the collection
-- 		p_use_desc varchar -  human readble description for the collection
-- OUT 
-- 		r_tnvc_id int(10) unsigned - id of the collection
-- ==================================================================
SP__insert_tnvc_collection(IN p_num_entries int(10) unsigned, p_use_desc varchar, OUT r_tnvc_id int(10) unsigned)

-- ==================================================================
-- sp for inserting a single entry into a tnvc 
-- SP__insert_tnvc_entry
-- IN 
-- 		p_tnvc_id int(10) unsigned - id of tnvc this entry belongs to 
-- 		p_order_num int(10) unsigned - order number of this entry 
-- 		p_data_type_name varchar -  data type name 
-- 		p_data_name varchar - name of the tnvc 
-- 		p_definition_id int(10) unsigned - definition of the object could be literal
-- OUT 
-- 		r_tnvc_entry_id int(10) unsigned - id of this entrty
-- ==================================================================
SP__insert_tnvc_entry(IN p_tnvc_id int(10) unsigned, p_order_num int(10) unsigned, p_data_type_name varchar, p_data_name varchar, 
p_definition_id int(10) unsigned, OUT r_tnvc_entry_id int(10) unsigned)


-- ==================================================================
-- SP__insert_variable_definition 
-- inserting a new variable 
-- IN 
-- 		p_obj_id int(10) unsigned - metadata id of the variable
-- 		p_use_desc varchar - human readable description 
-- 		p_out_type int(10) unsigned - out type of the variable
-- 		p_num_operators int(10) unsigned - number of operators 
-- 		p_operator_ids_list varchar - 
-- OUT 
-- 		r_definition_id int(10) unsigned - definition id of the variable
--
-- ==================================================================
SP__insert_variable_definition(IN p_obj_id int(10) unsigned, p_use_desc varchar, 
p_out_type int(10) unsigned,  p_expression_id int(10) unsigned, OUT r_definition_id int(10) unsigned)




-- ==================================================================
-- SP__delete_var_actual_definition;
-- Parameters:
-- in 
--      p_obj_id int unsigned - id for the var to delete 
-- 		p_obj_name varchar -  name of the var to delete --
-- ==================================================================
SP__delete_variable_definition(IN p_definition_id int(10) unsigned, p_obj_name varchar)