I shall give thanks to You with uprightness of heart, When I learn Your righteous judgments.
NASB95
I will praise you with an upright heart, when I learn your righteous rules.
ESV
I will praise thee with uprightness of heart, when I shall have learned thy righteous judgments.
KJV

The righteous judgments of God include the whole revelation of His word—so called—as the rule by which He judges our present state, and will pronounce our final sentence. David's attainments here seemed to be as nothing. So much remained unlearned and unknown, that he could only anticipate the time, when he shall have learned them. "Your commandment"—he exclaims, "is exceedingly broad." When the Apostle, after twenty years' acquaintance with the gospel, expressed it as the one desire of his heart, "That I may know Christ;" evidently he entertained the same humbling views of his high attainments, and the same exalted apprehensions of the value of treasures yet unexplored, and progressively opening before him. Thus the wisest saints are only students in the Divine School. Yet whatever their learning be, it casts them into the mold and spirit of their doctrine. Conceit of one's knowledge, is the greatest enemy to knowledge, and the strongest proof of ignorance; so that, "if any man thinks that he knows anything, he knows nothing yet as he ought to know." "He deceives himself."

But what is the motive, that enlivens the believer in this holy learning? Is it that he may live upon the airy breath of human applause? No, rather that he may "praise his God with uprightness of heart." When our mind is dark, our lips are sealed. But when "He opens our understandings" to "learn His judgments," He will next "open our lips, and our mouth shall show forth His praise." And this indeed is the end for which "His people are formed;" for which they "are called out of darkness into marvelous light." This is the daily frame, in which our God will be glorified. Yet must we live as well as sing His praise. "The praise of the upright heart will be shown in the holy walk and conversation."

But let us watch, that our praise really flows "out of the abundance" of what our hearts have "learned" of His "righteous judgments." For do we not sometimes speak of our Savior with a secret lurking after self-exaltation? May we not really be seeking and serving ourselves in the very act of seeming to serve and honor Him? Surely the very thought of the selfishness that defiles our holiest earthly praise, may well quicken our longings after that world of praise, where the flame burns active, bright, incessant; where we shall offer our sacrifices without defilement, without intermission, without weariness, without end!

"I will praise you." From prayer to praise is never a long or a difficult journey. Be sure that he who prays for holiness will one day praise for happiness. Shame having vanished, silence is broken, and the formerly silent man declares, "I will praise you." He cannot but promise praise while he seeks sanctification. Mark how well he knows upon what head to set the crown. "I will praise you." He would himself be praiseworthy, but he counts God alone worthy of praise. By the sorrow and shame of sin he measures his obligations to the Lord, who would teach him the are of living so that he should clean escape from his former misery.

"With uprightness of heart." His heart would be upright if the Lord would teach him, and then it would praise its teacher. There is such a thing as false and feigned praise, and this the Lord abhors; but there is no music like that which comes from a pure soul which stands in its integrity. Heart praise is required, uprightness in that heart, and teaching to make the heart upright. An upright heart is sure to bless the Lord; for grateful adoration is a part of its uprightness: no man can be right unless he is upright towards God, and this involves the rendering to him the praise which is his due.

"When I shall have learned your righteous judgments." We must learn to praise, learn that we may praise, and praise when we have learned. If we are ever to learn, the Lord must teach us, and especially upon such a subject as his judgments, for they are a great deep. While these are passing before our eyes, and we are learning from them, we ought to praise God; for the original is not, "when I have learned," but, "in my learning." While yet I am a scholar I will be a chorister: my upright heart shall praise your uprightness, my purified judgment shall admire your judgments. God's providence is a book full of teaching, and to those whose hearts are right it is a music-book, out of which they chant to Jehovah's praise. God's word is full of the record of his righteous providences, and as we read it we feel compelled to burst forth into expressions of holy delight and ardent praise. When we both read of God's judgments and become joyful partakers in them, we are doubly moved to song—song in which there is neither formality, nor hypocrisy, nor lukewarmness; for the heart is upright in the presentation of its praise.