Database | Proc | Application | Created | Links |
sybsystemprocs | sp_setlangalias | 31 Aug 14 | Defects Dependencies |
1 2 /* Sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */ 3 /* 4.8 1.1 06/14/90 sproc/src/serveroption */ 4 5 /* 6 ** Messages for "sp_setlangalias" 17810 7 ** 8 ** 17201, "'%1!' is not an official language name from Syslanguages." 9 ** 17240, "'" + @alias + "' is not a valid name." 10 ** 17260, "Can't run %1! from within a transaction." 11 ** 17253, "'%1!' alias already exists in Syslanguages." 12 ** 17810, "Language alias not changed." 13 ** 17811, "Language alias reset." 14 ** 18773, "HA_LOG: HA consistency check failure in stored procedure '%1!' on companion server '%2!'" 15 ** 18775, "Unable to find a language entry with language name '%1!' and language id '%2!'." 16 */ 17 18 /* 19 ** IMPORTANT: Please read the following instructions before 20 ** making changes to this stored procedure. 21 ** 22 ** To make this stored procedure compatible with High Availability (HA), 23 ** changes to certain system tables must be propagated 24 ** to the companion server under some conditions. 25 ** The tables include (but are not limited to): 26 ** syslogins, sysservers, sysattributes, systimeranges, 27 ** sysresourcelimits, sysalternates, sysdatabases, 28 ** syslanguages, sysremotelogins, sysloginroles, 29 ** sysalternates (master DB only), systypes (master DB only), 30 ** sysusers (master DB only), sysprotects (master DB only) 31 ** please refer to the HA documentation for detail. 32 ** 33 ** Here is what you need to do: 34 ** For each insert/update/delete statement, add three sections to 35 ** -- start HA transaction prior to the statement 36 ** -- add the statement 37 ** -- add HA synchronization code to propagate the change to the companion 38 ** 39 ** For example, if you are adding 40 ** insert master.dbo.syslogins ...... 41 ** the code should look like: 42 ** 1. Before that SQL statement: 43 ** 44 ** 2. Now, the SQL statement: 45 ** insert master.dbo.syslogins ...... 46 ** 3. Add a HA synchronization section right after the SQL statement: 47 ** 48 ** 49 ** You may need to do similar change for each built-in function you 50 ** want to add. 51 ** 52 ** Finally, add a separate part at a place where it can not 53 ** be reached by the normal execution path: 54 ** clean_all: 55 ** 56 ** return (1) 57 */ 58 59 create procedure sp_setlangalias 60 @language varchar(255), 61 @alias varchar(255) 62 as 63 64 declare @msg varchar(1024) 65 66 declare @returncode int 67 declare @HA_CERTIFIED tinyint /* Is the SP HA certified ? */ 68 declare @retstat int 69 declare @maxlen int 70 71 72 select @HA_CERTIFIED = 0 73 74 75 76 77 /* check to see if we are using HA specific SP for a HA enabled server */ 78 exec @retstat = sp_ha_check_certified 'sp_setlangalias', @HA_CERTIFIED 79 if (@retstat != 0) 80 return (1) 81 82 /* 83 ** Check to see that the @alias is valid. 84 */ 85 select @maxlen = length from syscolumns 86 where id = object_id("syslanguages") and name = "alias" 87 88 if (char_length(@alias) > @maxlen) 89 begin 90 /* 91 ** 17240, "'" + @alias + "' is not a valid name." 92 */ 93 raiserror 17240, @alias 94 return (1) 95 end 96 97 /* 98 ** If we're in a transaction, disallow this since it might make recovery 99 ** impossible. 100 */ 101 if @@trancount > 0 102 begin 103 /* 104 ** 17260, "Can't run %1! from within a transaction." 105 */ 106 raiserror 17260, "sp_setlangalias" 107 return (1) 108 end 109 else 110 begin 111 set chained off 112 end 113 114 set transaction isolation level 1 115 116 /* check if user has sa role, proc_role will also do auditing 117 ** if required. proc_role will also print error message if required. 118 */ 119 120 if (proc_role("sa_role") = 0) 121 return (1) 122 123 /* Check to see if the language exists. */ 124 select @returncode = 0 125 execute @returncode = sp_validlang @language 126 if @returncode != 0 127 begin 128 /* 129 ** 17201, "'%1!' is not an official language name from Syslanguages." 130 */ 131 raiserror 17201, @language 132 return 1 133 end 134 135 /* Check to see if the alias exists. */ 136 select @returncode = 0 137 execute @returncode = sp_validaltlang @alias 138 if @returncode = 0 139 begin 140 /* 141 ** 17253, "'%1!' alias already exists in Syslanguages." 142 */ 143 raiserror 17253, @alias 144 return 1 145 end 146 147 148 149 /* Reset the alternate language name. */ 150 update master.dbo.syslanguages 151 set alias = @alias 152 where name = @language 153 154 /* If the update failed, say so. */ 155 if (@@error != 0) 156 begin 157 /* 158 ** 17810, "Language alias not changed." 159 */ 160 raiserror 17810 161 goto clean_all 162 end 163 164 165 166 /* 167 ** 17811, "Language alias reset." 168 */ 169 exec sp_getmessage 17811, @msg output 170 print @msg 171 return (0) 172 173 clean_all: 174 175 return (1) 176 177
exec sp_procxmode 'sp_setlangalias', 'AnyMode' go Grant Execute on sp_setlangalias to public go
DEPENDENCIES |
PROCS AND TABLES USED calls proc sybsystemprocs..sp_ha_check_certified reads table tempdb..sysobjects (1) calls proc sybsystemprocs..sp_getmessage calls proc sybsystemprocs..sp_validlang reads table master..syslanguages (1) reads table sybsystemprocs..sysusermessages reads table master..syslanguages (1) reads table master..sysmessages (1) calls proc sybsystemprocs..sp_validaltlang reads table master..syslanguages (1) reads table sybsystemprocs..syscolumns calls proc sybsystemprocs..sp_validlang writes table master..syslanguages (1) |