{ ************************************************************************* }
{                                                                           }
{  Licensed Materials - Property of IBM and/or HCL                                     }
{                                                                           }
{  IBM Informix Dynamic Server                                              }
{  (c) Copyright IBM Corporation 1996, 2004 All rights reserved.            }
{  (c) Copyright HCL Technologies Ltd. 2017.  All Rights Reserved.             }
{                                                                           }
{ ************************************************************************* }
{                                                                           }
{   Title:      boot940.sql                                                 }
{                                                                           }
{   Description:                                                            }
{       Bootstrapping script for a 9.40 database                            }
{                                                                           }
{ ************************************************************************* }
{                                                                           }
{  ** IMPORTANT - PLEASE READ                                               } 
{                                                                           }
{     All types and routines referenced in this file must be prefixed       }
{     with the user name "informix". E.g., use "informix.boolean"           }
{     and not "boolean"                                                     }
{									    }
{     Also, please follow the formatting conventions!!!                     }
{                                                                           }
{     Please ensure that the identifiers that you choose are <= 18          }
{     characters in length. Otherwise the changes would affect database     }
{     reversion.                                                            }
{                                                                           }
{ ************************************************************************* }

{ ifx_replace_module() with a new parameter to replace module in  }
{ user specific schema.                                           }

create dba procedure informix.ifx_replace_module (oldmodulename varchar(255),
        newmodulename varchar(255),
        languagename varchar(255), module_ownername varchar(32)) returns int

     define retvalue int;
     let retvalue = ifx_invalid_module(oldmodulename,
                          languagename);

     if retvalue = 0 then 
         let retvalue = ifx_update_extern( oldmodulename, newmodulename, languagename);
         update informix.sysprocedures
         set externalname = ifx_new_external(newmodulename, externalname,
                              languagename)
         where owner = module_ownername 
             and ifx_match_external(oldmodulename, externalname) = 1;
         let retvalue = ifx_load_internal(newmodulename, languagename);
     end if;

     if retvalue = 0 then
         return 0;
     else 
         raise exception -9720;
     end if;

end procedure;

grant execute on procedure informix.ifx_replace_module (varchar(255),varchar(255),
     varchar(255), varchar(32)) to public as informix;

