One verse

Srimad Bhagavatam 9.18.32

9.18.32

राजपुत्र्यार्थितोऽपत्ये धर्मं चावेक्ष्य धर्मवित् । स्मरञ्छुक्रवच: काले दिष्टमेवाभ्यपद्यत ॥ ३२ ॥

raja-putryarthito ’patye dharmam caveksya dharmavit smaran chukra-vacah kale distam evabhyapadyata

raja-putrya
by Sarmistha, who was the daughter of a king
arthitah
being requested
apatye
for a son
dharmam
religious principles
ca
as well as
aveksya
considering
dharma-vit
aware of all religious principles
smaran
remembering
sukra-vacah
the warning of Sukracarya
kale
at the time
distam
circumstantially
eva
indeed
abhyapadyata
accepted (to fulfill the desire of Sarmistha).

When Princess Sarmistha begged King Yayati for a son, the King was certainly aware of the principles of religion, and therefore he agreed to fulfill her desire. Although he remembered the warning of Sukracarya, he thought of this union as the desire of the Supreme, and thus he had sex with Sarmistha.