Eccl 2:3

κατεσκεψάμην ἐν καρδίᾳ μου τοῦ ἑλκύσαι εἰς οἶνον τὴν σάρκα μου* καὶ καρδία μου ὡδήγησεν ἐν σοφίᾳ καὶ τοῦ κρατῆσαι ἐπ᾽ ἀφροσύνῃ** ἕως οὗ ἴδω ποῖον τὸ ἀγαθὸν τοῖς υἱοῖς τοῦ ἀνθρώπου ὃ ποιήσουσιν ὑπὸ τὸν ἥλιον ἀριθμὸν ἡμερῶν*** ζωῆς αὐτῶν (Ecc 2:3 LX)

How I parsed in my head: I looked closely in my heart: in order to drag my flesh towards wine*, and my heart led in wisdom; and in order to** rule over thoughtlessness, until I may see what sort of good [is done] by the sons of man, who shall work under the sun the sum*** of the days of their life.

*I think this is a correct literal translation. What does it mean? That the flesh may be drug to wine (ie, excess of emotions? foolishness?), but the heart continues to be led in wisdom? Not familiar enough with LXX associations with wine to understand the meaning.
**I am thinking τοῦ κρατῆσαι… is a second infinitive clause expressing purpose, and is introduced the same way as τοῦ ἑλκύσαι…
***ἀριθμὸν ἡμερῶν - a number of days / the sum of the days / all the days – are all of these acceptable translations more ore less dependent on context?

The Greek here is a literal rendering of the Hebrew. Once you look at the Hebrew, the Greek makes more sense. But I believe the Greek can be unpacked without reference to the Hebrew.

He draws his flesh into οἶνος=χαρά, εὐφροσύνη, and into a lack of σωφροσύνη, to test to see what satisfaction earthly pleasures will bring. καὶ καρδία μου ὡδήγησεν ἐν σοφίᾳ is a type of parenthetical statement to show that this deliberate testing of pleasure was still conducted under the guidance of σοφία. You are correct that τοῦ κρατῆσαι ἐπ᾽ ἀφροσύνῃ, like τοῦ ἑλκύσαι εἰς οἶνον τὴν σάρκα μου, is dependent on κατεσκεψάμην ἐν καρδίᾳ μου. Your translation shows this; just put “and my heart led in wisdom” in parentheses.

Yes, a less literal/more Sophoclean Greek rendering might have been ἔτι βλέποντες (=ἔτι ζῶντες)

thanks