בָּר֖וּךְ אַתָּ֥ה יְהוָ֗ה לַמְּדֵ֥נִי חֻקֶּֽיךָ׃
Błogosławionyś Boże, naucz mnie ustaw Twoich.
Abudarham
...We find the following in Tosefta Brachos: "Whoever fulfills a commandment must recite a blessing beforehand." This idea is mentioned in Yerushalmi Brachos and is supported by the following verse in Exodus 24: "And I will give you the stone tablets, the law, and the commandment." The law and the commandment are mentioned together because they have a common feature. So goes the argument there: "In the same way that one must recite a blessing when studying the law, one must also recite a blessing when fulfilling a commandment." But why must one recite a blessing when studying the law? We find this question under discussion in Tractate Brachos Chapter 3, as follows: "Whoever reads the Torah must recite a blessing beforehand and afterward. Why must one recite a blessing beforehand? Scripture states: 'When I read aloud the Name of the Lord, attribute greatness to our God' and, elsewhere, 'You are blessed, Lord; teach [us] your statutes.' The law is called the Name of the Lord because it is the study of His great Name. A similar idea is expressed in the following verse: '[When] you are careful to fulfill all the words of this law, to fear this honorable and awesome Name — the Lord your God.' Why must one recite a blessing afterward? It makes sense when using the following logical inference: If one must recite a blessing after eating, which only provides temporary sustenance, then one must certainly recite a blessing after reading the Torah, which provides eternal sustenance. But why must one recite a blessing after eating? Scripture states: 'You will eat, you will be sustained, and you will bless the Lord your God.' That supports the need to recite a blessing afterward, but why must one recite a blessing beforehand? Rabbi Isaac said that it is supported by the following verse: 'He will bless the sacrifice, and then the guests will eat.' Rabbi Nathan said that it is supported by the following verse: 'You must serve the Lord your God, and He will bless your bread.' The bread is only yours until you eat it. Rabbi felt that it makes sense when using the following logical inference: If one must recite a blessing afterward, when one is sustained, then one must certainly recite a blessing beforehand, when one is hungry." The blessing recited after reading the Torah should only be recited after a public Torah reading, as stated in Yerushalmi Brachos: "Rabbi Samuel son of Avdima said that the logical inference used to establish that a blessing be recited after reading the Torah based on the blessing that is recited after eating is only used to establish that a blessing be recited after a public Torah reading; however, an individual studying Torah alone should not recite a blessing afterward."
Kitzur Shulchan Arukh
You must be careful never to recite a berachah in vain God forbid, or cause yourself to recite a berachah which is unnecessary. If you recited a berachah in vain, or if you uttered the Name of Hashem in vain, you should immediately say: Boruch sheim kevod malchuso le'olam va'ed ["Blessed [is His] Name, Whose glorious kingdom is forever and ever."] If immediately after pronouncing Hashem's Name you remember that the berachah is unnecessary, you should conclude [with]: lamdeini chukecha, (teach me Your laws),10Psalms 119:12 the complete verse is בָּרוּ אַתָּה ה׳ לַמְדֵנִי חוּקֶךָ. which is a complete verse. Thus it is considered as learning [Torah] and [the Name] was not mentioned in vain. If you began the word Elokeinu [our God], and immediately recall after saying Elokei and have not said the suffix nu you should conclude by saying: Yisrael Aveenu meolam ve'ad olam [Israel our father forever and ever]11The berachah is now a Scriptural verse which reads Blessed are you God, God of Israel, our Father, forever and ever. (which is also the syntax of a verse in Chronicles I, Chapter 29). Nevertheless you should also say: Boruch sheim kevod malchuso le'olam va'ed (See Tzlach, Maseches Berachos, Page 39).
Kitzur Shulchan Arukh
If the place to be read was shown to the oleh and he recited the blessing, and then it was realized that it was not the [right] place, but, rather, another place is to be read, regardless if the reading has started or has not started, [the following must be considered:] if the place [in the Torah] that was to be read was also open before him, [during the berachah], even if it is in another column [as long as it was] past the place that was shown to him, he need not recite a second berachah, because his mind was on the place on which he intended the berachah as well as on whatever was opened before him. But, if the place was not open before him, and they must now roll the Seifer Torah [to the proper place], or even if the place was open before him, but it is located before the place that was shown to him; he must recite the berachah: asher bachar banu a second time. But, Barechu [es Hashem hamevorach] should not be said a second time. He must first (before repeating the berachah) say: Baruch sheim kevod malchuso leolam va'ed36“Blessed is His Name, Whose glorious kingdom is forever and ever.” This is said to somewhat atone for the sin of having mentioned His Name in vain at the first berachah. on the first berachah which was recited in vain. If [the error was realized] when he had said only: Baruch atah Hashem. then he should conclude… lamdeinu chukecha.37Resulting in his having said altogether: בָּרוּךְ אַתָּה ה' לַמְּדֵנִי חֻקֶּיךָ, “Blessed are You, Hashem, teach me Your statutes,” (Ps 119:12) which is a complete verse, thereby avoiding a בְּרָכָה לְבֵטָלָה—a berachah recited in vain. If the place to be read precedes the place shown him, but is close enough to it, and so situated to make it possible that three verses can also be read from the place [upon which] he said the berachah and further, [and with the condition that] it is all included in that day's portion, then this should be done in order to avoid a second berachah.