I have 2 calculated fields A & B they both are calculated using Table calculation.
Now I want is to make bins using them like:
Example: My Table calculation A & B
What I want to do is:-
IF A > 0 & B > 0 Then Case 1
IF A < 0 & B < 0 Then Case 2
IF A > 0 & B < 0 Then Case 3
IF A < 0 & B > 0 Then Case 4
Thank you for your response & apologize for not attaching the Workbook.
This should be fairly simple using IF + ELSEIFs - try the formula below:
IF (A > 0 & B > 0) THEN "Case 1"
ELSEIF (A < 0 & B < 0) THEN "Case 2"
ELSEIF (A > 0 & B < 0) THEN "Case 3"
ELSEIF (A < 0 & B > 0) THEN "Case 4"
END
This should return 4 distinct values Case 1, Case 2, Case 3, Case 4 based on the input variables A and B. Hope this helps!
Related
So, I have a formula ( =INDEX(Sheet1.A1:F15,RANDBETWEEN(1,15),RANDBETWEEN(1,6)) ) that returns a random number in the sheet. But, how to run the formula until the returned number is less than or equal to 25 ?
I thought of using for..next.. but couldn't get it how to run ...
Welcome!
As #thebusybee pointed out in his comment, a macro for this task is much easier than using built-in functions. As rightly pointed out #tohuwawohu, pre-filtering the values makes things a lot easier. The macro code could be, for example, like this
Option Explicit
Function getRandValue(aValues As Variant, nTypeCriteria As Integer, dCriteriaValue As Variant) As Variant
Rem Params: aValues - array of values,
Rem nTypeCriteria - -2 less then, -1 not more, 0 equal, 1 not less, 2 more than
Rem dCriteriaValue - value to compare
Dim aTemp As Variant
Dim i As Long, j As Long, k As Long
Dim bGoodValue As Boolean
k = UBound(aValues,1)*UBound(aValues,2)
ReDim aTemp(1 To k)
k = 0
For i = 1 To UBound(aValues,1)
For j = 1 To UBound(aValues,2)
bGoodValue = False
Select Case nTypeCriteria
Case -2
bGoodValue = (aValues(i,j) < dCriteriaValue)
Case -1
bGoodValue = (aValues(i,j) <= dCriteriaValue)
Case 0
bGoodValue = (aValues(i,j) = dCriteriaValue)
Case 1
bGoodValue = (aValues(i,j) >= dCriteriaValue)
Case 2
bGoodValue = (aValues(i,j) > dCriteriaValue)
End Select
If bGoodValue Then
k = k+1
aTemp(k) = aValues(i,j)
EndIf
Next j
Next i
If k<1 Then
getRandValue = "No matching values"
ElseIf k=1 Then
getRandValue = aTemp(k)
Else
getRandValue = aTemp(Rnd()*(k-1)+1)
EndIf
End Function
Just put a call to this function in a cell in the form
=GETRANDVALUE(A1:F15;-1;25)
I have the following 3 examples of case expressions in postgres, which I would expect to evaluate in the same way. However the first and the third give ERROR: invalid input syntax for integer: "2017,7". The second one seems to be ok. Why is the difference?
Postgres documentation states
"A CASE expression does not evaluate any subexpressions that are not
needed to determine the result."
select case when 0 = 0 then 1 < 2
when 0 = 2 then ('2017.7')::bigint > 2000
end
(DB Fiddle)
select case when 0 = 0 then 1 < 2
when 0 = 2 then 2000 = ('2017.7'||'')::bigint
end
(DB Fiddle)
select case when (array[1,2])[1] =1 then 1 < 2
when (array[1,2])[1] = 2 then 2000 = ('2017.7'||'')::bigint
end
(DB Fiddle)
I am having problem in using button with function. I know only about java application and I am trying to learn HTML and JavaScript. I want the button to set the text present in conditional statement on to the webpage and conditions are based on select box.
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>P-Block Chemical Reactions</TITLE>
</HEAD>
<BODY>
<CENTER><FONT FACE="TIMES NEW ROMAN" COLOR="GREEN" size="50"><b><u>P-Block Chemical Reactions</u></b></font>
<br><br><br><h2>Structure of P-Block</h2><br>
<img src="http://2.bp.blogspot.com/-HNGbTyDrWso/UAGMqI2uY6I/AAAAAAAAAC0/mSWX5ZivvDk/s1600/Use%252Bnowwwww-723799.jpg">
<br></center>
<br>
<form>
<select id="Groups" name="Groups" >
<option value="1">Group 13</option>
<option value="2">Group 14</option>
<option value="3">Group 15</option>
<option value="4">Group 16</option>
<option value="5">Group 17</option>
<option value="6">Group 18</option></select>
<button onClick="gr();">See</button></form>
<script type="text/javascript">
function gr()
{
var s = document.getElementById('Groups');
var g = s.options[s.selectedIndex].value;
if (g === 1)
{
document.write("<b><h3>Chemical Reactions for GROUP 13 :</h3></b><br>
< ul type = "disc" >
< li > Reaction with O < sub > 2 < /sub> <br>
Boron is unreactive in crystalline form.Aluminium forms a very thin oxide layer on the surface which protects the metal from further attack. < br > < br >
2E(s) + 3O < sub > 2 < /sub>(g) → 2E<sub>2</sub > O < sub > 3 < /sub>(s)
(E = element) < br > < br >
< li > Reaction with N < sub > 2 < /sub><br>
With dinitrogen at high temperature these elements form nitrides. < br > < br >
2E(s) + N < sub > 2 < /sub>(g) → 2EN(s)
(E = element) < br > < br >
< li > Reaction with acids and alkalies < br >
Boron does not react with acids and alkalies even at moderate temperature, but aluminium dissolves in mineral acids and aqueous alkalies and thus shows amphoteric character. < br > Aluminium dissolves in dilute HCl and liberates dihydrogen. < br > < br >
2Al(s) + 6HCl(aq) → 2Al < sup > 3 + < /sup>(aq) + 6Cl<sup>-</sup > (aq) < br > < br >
However, concentrated nitric acid renders aluminium passive by forming a protective oxide layer on the surface. < br > < br >
Aluminium also reacts with aqueous alkali and liberates dihydrogen. < br > < br >
2Al(s) + 2NaOH(aq) + 6H < sub > 2 < /sub>O(l) → 2Na<sup>+</sup > [Al(OH) < sub > 4 < /sub>]<sup>-</sup > (aq) + 3H < sub > 2 < /sub>(g) <br><br>
< li > Reaction with halogens < br >
These elements react with halogens to form trihalides (except TlI < sub > 3 < /sub>).<br><br>
2E(s) + 3X < sub > 2 < /sub>(g) → 2EX<sub>3</sub > (s) & nbsp; & nbsp; & nbsp; & nbsp; (X = F, Cl, Br, I)
< /ul>");
}
else if (item === 2)
{
document.write("<b><h3>Chemical Reactions for GROUP 14 :</h3></b><br>
< ul type = "disc" >
< li > Reaction with O < sub > 2 < /sub> <br>
All members when heated in oxygen form oxides.There are mainly two types of oxides, i.e., monoxide and dioxide of formula MO and MO < sub > 2 < /sub> respectively. SiO only exists at high temperature. Oxides in higher Oxidation states of elements are generally more acidic than those in lower oxidation states.<br><br> The dioxides : CO<sub>2</sub > , SiO < sub > 2 < /sub> and GeO<sub>2</sub > are acidic, whereas SnO < sub > 2 < /sub> and PbO<sub>2</sub > are amphoteric in nature.Among monoxides, CO is neutral, GeO is distinctly acidic whereas SnO and PbO are amphoteric. < br > < br >
< li > Reaction with water < br >
Carbon, silicon and germanium are not affected by water.Tin decomposes steam to form dioxide and dihydrogen gas. < br > < br >
Sn + 2H < sub > 2 < /sub>O → SnO<sub>2</sub > + 2H < sub > 2 < /sub> <br><br>
Lead is unaffected by water, probably because of a protective oxide film formation. < br > < br >
< li > Reaction with halogen < br >
These elements can form halides of formula MX < sub > 2 < /sub> and MX<sub>4</sub > (where X = F, Cl, Br, I).Except carbon, all other members react directly with halogen under suitable condition to make halides.Most of the MX < sub > 4 < /sub> are covalent in nature. The central metal atom in these halides undergoes sp<sup>3</sup > hybridisation and the molecule is tetrahedral in shape.Exceptions are SnF < sub > 4 < /sub> and PbF<sub>4</sub > , which are ionic in nature. < br > PbI < sub > 4 < /sub> does not exist because Pb-I bond initially formed during the reaction does not release enough energy to unpair 6s<sub>2</sub > electrons and excite one of them to higher orbital to have four unpaired electrons around lead atom.Heavier members Ge to Pb are able to make halides of formula MX < sub > 2 < /sub>. Stability of dihalides increases down the group. Considering the thermal and chemical stability, GeX<sub>4</sub > is more stable than GeX < sub > 2 < /sub>, whereas PbX<sub>2</sub > is more than PbX < sub > 4 < /sub>. Except CCl<sub>4</sub > , other tetrachlorides are easily hydrolysed by water because the central atom can accomodate the lone pair of electrons from oxygen atom of water in d orbital.
< /ul><br><br>");
}
else if (item === 3)
{
document.write("<b><h3>Chemical Reactions for GROUP 15 :</h3></b><br>
< ul type = "disc" >
< li > Reaction with Hydrogen < br >
All the elements of Group 15 form hydrides of the type EH < sub > 3 < /sub> where E = N, P, As, Sb or Bi.<br> The stability of hidrides decreases from NH<sub>3</sub > to BiH < sub > 3 < /sub> which can be observed from their bond dissociation enthalpy. Consequently,the reducing character of the hydrides increases. Ammonia is only a mild reducing agent while BiH<sub>3</sub > is the strongest reducing agent amongst all the hydrides.Basicity also decreases in the order NH < sub > 3 < /sub> > PH<sub>3</sub > & gt; AsH < sub > 3 < /sub> > SbH<sub>3</sub > & ge; BiH < sub > 3 < /sub>.<br><br>
< li > Reaction with Oxygen < br >
All these elements form two types of oxides: E < sub > 2 < /sub>O<sub>3</sub > and E < sub > 2 < /sub>O<sub>5</sub > .The oxide in the higher oxidation state of the element is more acidic than that of lower oxidation state.Their acidic character decreases down the group.The oxides of the type E < sub > 2 < /sub>O<sub>3</sub > of nitrogen and phosphorus are purely acidic, that of arsenic and antimony amphoteric and those of bismuth is predominantaly basic. < br > < br >
< li > Reaction with Halogen < br >
These elements react to form two series of halides: EX < sub > 3 < /sub> and EX<sub>5</sub > .Nitrogen does not form pentahalide due to non - availability of the d - orbitals in its valence shell.Pentahalides are more covalent than trihalides.All the trihalides of these elements except those of nitrogen are stable.In case of nitrogen, only NF < sub > 3 < /sub> is known to be stable. Trihalides except BiF<sub>3</sub > are predominantly covalent in nature. < br > < br >
< li > Reaction with Metal < br >
All these elements react with metals to form their binary compounds exhibiting - 3 oxidation state, such as, Ca < sub > 3 < /sub>N<sub>2</sub > (Calcium nitride), Ca < sub > 3 < /sub>P<sub>2</sub > (Calcium phosphide), Na < sub > 3 < /sub>As<sub>2</sub > (Sodium arsenide), Zn < sub > 3 < /sub>Sb<sub>2</sub > (Zinc antimonide) and Mg < sub > 3 < /sub>Bi<sub>2</sub > (Magnesium bismuthide). < br > < br >
< /ul>");
}
else if (item === 4)
{
document.write("<b><h3>Chemical Reactions for GROUP 16 :</h3></b><br>
< ul type = "disc" >
< li > Reaction with Hydrogen < br >
All the elements of Group 16 form hydrides of the type H < sub > 2 < /sub>E (E = S, Se, Te, Po). Their acidic character increases from H<sub>2</sub > O to H < sub > 2 < /sub>Te. The increse in acidic character can be explained in terms of decrease in bond (H-E) dissociation enthalpy down the group. Owing to the decrease in bond (H-E) dissociation enthalpy down the group, the thermal stability of hydrides also decreases from H<sub>2</sub > O to H < sub > 2 < /sub>Po. All the hydrides except water possess reducing property and this character increases from H<sub>2</sub > S to H < sub > 2 < /sub>Te.<br><br>
< li > Reaction with Oxygen < br >
All these elements form oxides of the EO < sub > 2 < /sub> and EO<sub>3</sub > types where E = S, Se, Te or Po.Ozone (O < sub > 3 < /sub>) and sulphur dioxide (SO<sub>2</sub > ) are gases while selenium dioxide (SeO < sub > 2 < /sub>) is solid. Reducing property of dioxide decreases from SO<sub>2</sub > to TeO < sub > 2 < /sub>. SO<sub>2</sub > is reducing while TeO < sub > 2 < /sub> is an oxidising agent. Besides EO<sub>2</sub > type, sulphur, selenium and tellurium also form EO < sub > 3 < /sub> type oxides (SO<sub>3</sub > , SeO < sub > 3 < /sub>, TeO<sub>3</sub > ).Both types of oxides are acidic in nature. < br > < br >
< li > Reaction with Halogen < br >
Elements of Group 16 form a large number of halides of the type, EX < sub > 6 < /sub>, EX<sub>4</sub > and EX < sub > 2 < /sub> where E is an element of the group and X is a halogen. The stability of the halides decreases in the order F<sup>-</sup > & gt; Cl < sup > - < /sup> > Br<sup>-</sup > & gt; I < sup > - < /sup>. Amongst hexahalides, hexafluorides are the only stable halides. All hexafluorides are in gaseous nature. They have octahedral structure. Sulphur hexafluoride, SF<sub>6</sub > is exceptionally stable for steric reasons. < br >
Amongst tetrafluorides, SF < sub > 4 < /sub> is a gas, SeF<sub>4</sub > a liquid and TeF < sub > 4 < /sub> a solid. These fluorides have sp<sup>3</sup > d hybridisation and thus, have trigonal bipyramidal structures in which one of the equatorial positions is occupied by a lone pair of electrons.This geometry is also regarded as see - saw geometry. < br >
All elements except selenium form dichlorides and dibromides.These dihalides are formed by sp < sup > 3 < /sup> hybridisation and thus, have tetrahedral structure. The well known monohalides are dimeric in nature. Examples are S<sub>2</sub > F < sub > 2 < /sub>, S<sub>2</sub > Cl < sub > 2 < /sub>, S<sub>2</sub > Br < sub > 2 < /sub>, Se<sub>2</sub > Cl < sub > 2 < /sub> and Se<sub>2</sub > Br < sub > 2 < /sub>. These dimeric halides undergo disproportionation as given below: <br><br>
2Se < sub > 2 < /sub>Cl<sub>2</sub > → SeCl < sub > 4 < /sub> + 3Se <br><br>
< /ul>");
}
else if (item === 5)
{
document.write("<li><b><h3>Chemical Reactions for GROUP 17 :</h3></b><br>
< ul type = "disc" >
< li > Reaction with Hydrogen < br >
They all react with hydrogen to give hydrogen halides but affinity for hydrogen decreases from fluorine to iodine.They dissolve in water to form hydrohali acids.The acidic strength of these acids varies in the order: HF & lt; HCl & lt; HBr & lt; HI.The stability of these halides decreases down the group due to decrease in bond (H - X) dissociation enthalpy in the order: H - F & gt; H - Cl & gt; H - Br & gt; H - I. < br > < br >
< li > Reaction with Oxygen < br >
Halogens form many oxides with oxygen but most of them are unstable.Fluorine forms two oxides OF < sub > 2 < /sub>, O<sub>2</sub > F < sub > 2 < /sub>. However, only OF<sub>2</sub > is thermally stable at 298 K.These oxides are essentially oxygen fluorides because of the higher electronegativity of fluorine than oxygen.Both are strong fluorinating agents.O < sub > 2 < /sub>F<sub>2</sub > oxidises plutonium to PuF < sub > 6 < /sub> and the reaction is used in removing plutonium as PuF<sub>6</sub > from spent nuclear fuel. < br >
Chlorine, bromine and iodineChlorine, bromine and iodine form oxides in which the oxidation
states of these halogens range from + 1 to + 7. A combination of kinetic and thermodynamic factors lead to the generally decreasing order of stability of oxides formed by halogens, I & gt; Cl & gt; Br.The higher oxides of halogens tend to be more stable than the lower ones. < br >
Chlorine oxides, Cl < sub > 2 < /sub>O, ClO<sub>2</sub > , Cl < sub > 2 < /sub>O<sub>6</sub > and Cl < sub > 2 < /sub>O<sub>7</sub > are highly reactive oxidising agents and tend to explode.ClO < sub > 2 < /sub> is used as a bleaching agent for paper pulp and textiles and in water treatment.<br>
The bromine oxides, Br < sub > 2 < /sub>O, BrO<sub>2</sub > , BrO < sub > 3 < /sub> are the least stable halogen oxides (middle row anomally) and exist only at low temperatures. They are very powerful oxidising agents. The iodine oxides, I<sub>2</sub > O < sub > 4 < /sub>, I<sub>2</sub > O < sub > 5 < /sub>, I<sub>2</sub > O < sub > 7 < /sub> are insoluble solids and
decompose on heating.I < sub > 2 < /sub>O<sub>5</sub > is a very good oxidising agent and is
used in the estimation of carbon monoxide. < br > < br >
< li > Reaction with Metals < br >
Halogens react with metals to form metal halides.For example, bromine reacts with magnesium to give magnesium bromide. < br > < br >
Mg(s) + Br < sub > 2 < /sub>(l) → MgBr<sub>2</sub > (s) < br > < br >
The ionic character of the halides decreases in the order MF & gt;
MCl & gt; MBr & gt; MI where M is a monovalent metal.If a metal exhibits
more than one oxidation state, the halides in higher oxidation
state will be more covalent than the one in lower oxidation state.
For example, SnCl < sub > 4 < /sub>, PbCl<sub>4</sub >
, SbCl < sub > 5 < /sub> and UF<sub>6</sub >
are more covalent than SnCl < sub > 2 < /sub>
, PbCl < sub > 2 < /sub>, SbCl<sub>3</sub >
and UF < sub > 4 < /sub> respectively.<br><br>
< li > Reaction with Halogens < br >
Halogens combine amongst themselves to form number of compounds known as interhalogens of the types XX < sup > ` < /sup>, XX<sup>`</sup > < sub > 3 < /sub>, XX<sup></sup > < sub > 5 < /sub> and XX<sup>`</sup > < sub > 7 < /sub> where X is a larger size halogen and X<sup>`</sup > is a smaller size halogen. < br > For example: & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; I < sub > 2 < /sub> + Cl<sub>2</sub > & nbsp; → 2ICl < br > & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; (equimolar) < br > < br >
< /ul>");
}
}
</script>
</body>
</html>
Pastebin code
Problems I had to fix;
< br > turns in to plain text: < br > . Use this instead for ALL the HTML tags: <br> without the spaces.
if (item === 2) ???? Item was not defined, had to change it to if (g === "2") ; Please note that "2" is not the same as 2
Applied a classname group to every div; to Hide them whenever the gr() is called.
Goodluck, Jeroen
The problem is in the document.write
You can't do: document.write("")
The javascript thinks website.html is a variable
In your code:
document.write("<b><h3>Chemical Reactions for GROUP 13 :</h3></b><br>
< ul type = "disc" >
It expects "disc" to be a variable
You either can encode all of the " symbols, or put the text in divs and show them when you select an option.
Also; with document.write you can't use [enter] to prettify your code.
Your best bet is placing the text in separate divs and showing/hiding them whenever you hit the see button !
Jeroen
I write an algorithm that checks the stability of the closed system of the Nyquist criterion (http://en.wikipedia.org/wiki/Nyquist_stability_criterion)
function answear=stability(re,im)
%% Function check stability of system
%re is real part of transmitation
%im is imagine part of transmitation
%% Check number of vectors elements
re(end +1:5) = 0;
im(end +1:5) = 0;
if( length(re) > length(im))
root = length(re);
else
root = length(im);
end
for w=1:root
tran(w) = re(1) + re(2)*w.^1 + re(3)*w.^2 + re(4)*w.^3 + re(5)*w.^4 +1i*(...
im(1) + im(2)*w.^1 + im(3)*w.^2 + im(4)*w.^3 +im(5)*w.^4);
end
%% Algorithm
switch root
case 0
exist('Write nonzero numbers', 'var')
case 1
for w=1:length(w)
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
answear=1;
else
answear=0;
end
end
case 2
for w=1:length(w)
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) > 0)
answear=1;
else
answear=0;
end
end
end
case 3
for w=1:length(w)
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) < 0)
answear=1;
else
answear=0;
end
end
end
end
case 4
for w=1:length(w)
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) < 0)
if( real(tran(w)) > 0 && imag(tran(w)) < 0)
answear=1;
else
answear=0;
end
end
end
end
end
end
%% Answear
if answear==1
disp('System unstable')
else
disp('System stable')
end
plot(real(tran),imag(tran))
grid on
end
Function returns
Undefined function or variable "answear".
Error in stability (line 87) if answear==1
So the algorithm is badly written?
Your code could use a lot of cleanup:
Instead of an if-statement such as this one:
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
answear=1;
else
answear=0;
end
you could write a boolean assignment:
answear = real(tran(w)) > 0 & imag(tran(w)) > 0);
Why do you have three (almost) identical nested if-statements at all?
if( real(tran(w)) > 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) > 0)
if( real(tran(w)) < 0 && imag(tran(w)) < 0)
First of all, you could replace everything with one if-statement. But what are you actually testing with this? It seems that those nested if statements are never executed. For instance, real(tran(w)) cannot be both positive and negative at the same time (unless it is a vector you are working on, in which case you shouldn't be using the operator &&).
Also, this is probably your code triggers the error regarding variable answear. Accessing it is impossible since it hasn't been assigned a value (none of the if-statements have been executed).
What is tran, and what is w? Are they global variables? If they are, pass them as input parameters. Your function is probably poorly designed if it relies on external states and variables.
I haven't actually run your code, but these suggestions should make it easier for you to debug it.
P.S:
Please fix the annoying spelling error (it is "answer" and not "answear") :)
In one of the stored procedures in TSQL I came across the code
Alter procedure Name
#parameter1 ,
#parameter2 ,
..........
if (substring(#bitmap,1,1) & 1 = 1) or //what does this mean?
(substring(#bitmap,1,1) & 2 = 2) or
(substring(#bitmap,1,1) & 4 = 4) or
(substring(#bitmap,1,1) & 128 = 128) or
(substring(#bitmap,2,1) & 1 = 1)
[Column1] = case substring(#bitmap,1,1) & 1 when 1 then #parameter1 else [Column1] end,
[Column2] = case substring(#bitmap,1,1) & 2 when 2 then #parameter2 else [Column2] end,
[Column3] = case substring(#bitmap,1,1) & 4 when 4 then #parameter3 else [Column3] end,
[Column4] = case substring(#bitmap,1,1) & 8 when 8 then #parameter4 else [Column4] end,
[Column5] = case substring(#bitmap,1,1) & 16 when 16 then #parameter5 else [Column5] end,
[Column6] = case substring(#bitmap,1,1) & 32 when 32 then #parameter6 else [Column6] end,
[Column7] = case substring(#bitmap,1,1) & 64 when 64 then #parameter7 else [Column7]end,
[Column8] = case substring(#bitmap,1,1) & 128 when 128 then #parameter8 else [Column8] end,
[Column9] = case substring(#bitmap,2,1) & 1 when 1 then #parameter9 else [Column9] end,
[Column10] = case substring(#bitmap,2,1) & 2 when 2 then #parameter10 else [Column10] end
Googling this i found that it helps to dynamically build the procedure. But I still have few doubts.
(substring(#bitmap,1,1) & 1 = 1) or //what does this mean?
substring(#bitmap,2,1) & 1 when 1 then #parameter9 else [Column9] end,//what does this mean
case SUBSTRING(#bitmap,1,1) & 256 when 256 or
case SUBSTRING(#bitmap,1,1) & 512 when 512
Thanks
#bitmap is a bitmask which defines which of the #parameterN values is used to overwrite the (existing?) values of the ColumnN values.
The expression (value & x) when x checks whether a given bit is set in the #bitmap for x being a power of 2.
The expression CASE expression WHEN value THEN x ELSE y END is equivalent to the IF ELSE statement (or if/switch in C# etc.).