Our teacher, the Rema, wrote: And likewise, if one swore or vowed not to sell, and transgressed and sold, the sale is valid. Thus far his words. And in Yoreh Deah siman 230, he wrote that some say anyone who swore not to do a certain thing, such as if he swore not to sell a certain object and transgressed and sold it, his sale is nothing, since he transgressed his oath. Thus far his words. And the truth is that there is a dispute of the Rishonim in this matter, and regarding the halachah, the great Acharonim wrote that the sale is void based on the principle: "Any matter that the Merciful One said 'do not do,' if one did it, it is not effective." And the opinion of the Rambam also appears so [Mishneh LaMelech chapter 9 of Malveh]. And even regarding a rabbinic prohibition we say this [Ketubot 81b]. And that which was explained that the sale is valid even with a prohibition, this is specifically when the essence of the sale is not prohibited, but rather it contains a detail of prohibition and he could have done it in a permitted manner, such as if he bought wheat cheaply because he advanced money to the seller, and likewise one who sells before the market price is established, and likewise one who sells on Shabbat, for he could have performed this acquisition on a weekday, or according to the market price, or when there is a market price. But in one who swears not to sell this object, behold, there is no side of permission at all in this sale [Sma]. And some say that it is a legal doubt [Shach and Bach]. And even though he has the ability to request absolution for the oath, this is not called having the ability to do it in a permitted manner, for "new faces have come here" and there is no oath here at all; but as long as the oath remains in its place, there is no side of permission in it. And there is one who says that the primary halachah is that even in this the sale is valid, for the prohibition is not in the sale but in the oath, and it is not called a prohibition in the sale itself unless the sages commanded not to sell this object [like that in Ketubot ibid.], and not when the prohibition is in the oath [Taz]. Furthermore, some say that this entire rule of "if one did it, it is not effective" applies only to prohibitions that the Torah or the sages decreed as a prohibition, and not to a prohibition that a person devised himself and made into a prohibition because of his oath [Tosafot Temurah 6a, s.v. "ve-hashta"]. And some raise difficulties against what we wrote, that in a place where one can do it in a permitted manner we do not say "if one did it, it is not effective," for behold, in all the prohibitions that the Gemara enumerated [ibid.] regarding this matter, it is possible to do them in a permitted manner [Ktzot HaChoshen and Netivot HaMishpat]. However, in a matter where the Torah explicitly commanded "do not do this thing" specifically, and he transgressed and did it, certainly it is not effective since he transgressed a Torah law. This is not the case in sales when he did it with a side of prohibition, for the Torah did not specifically command "do not sell in this manner," but rather the prohibition is included among the prohibitions, and since he could have sold without the prohibition, we do not say "if one did it, it is not effective" [it appears to me]. And some distinguish between a matter that can be retracted to nullify the prohibition, in which case we say "if one did it, it is not effective" in order to remove him from the prohibition he performed, and a matter that cannot be retracted, where the prohibition that was done is done, and there is no benefit if we nullify the matter since the prohibition has already been performed and cannot be restored [Maharit and Netivot HaMishpat]. Therefore, in every sale involving a prohibition, we uphold the sale and nullify the prohibition, such as in a sale of "reward for waiting" and a sale on Shabbat if we nullify it, for the prohibition that was done is done. And according to this, in advancing money before the market price was established and it became expensive, we should have compelled both of them not to uphold the sale according to what they stipulated, but it does not appear so from the poskim. And according to this view, one should be in doubt regarding an oath not to sell whether to nullify the sale or to uphold it and request absolution for his oath. And perhaps this is the intention of our teacher, the Rema, that here he wrote that the sale is valid, and in Yoreh Deah, which deals with the prohibition of an oath, he wrote that the sale is void, meaning until he requests absolution for the oath, but he is obligated to request absolution for the oath in order to uphold the sale. And furthermore, it is possible to say that certainly the buyer has the ability to uphold the sale against the will of the seller, for what does he have to do with the seller's oath? But if the buyer is not concerned with its nullification, we compel the seller to nullify the sale so that he does not transgress his oath [and therefore he was precise to say "the sale is valid" and there he wrote "his sale is nothing"]. And the primary halachah is like his words here [and there is clear proof from the Mishnah in Shevuot 25a: "an oath that I will not give," and it considers it an oath of expression; and if it enters your mind that his giving is nothing, how do you find that he transgresses his oath? For even if he gave it and the recipient did not return it, it is like theft in his hand].
כתב רבינו הרמ"א וכן אם נשבע או נדר שלא למכור ועבר ומכר המקח קיים עכ"ל וביו"ד סימן ר"ל כתב די"א כל מי שנשבע שלא לעשות איזה דבר כגון שנשבע שלא למכור חפץ פלוני ועבר ומכרו אין במכירתו כלום הועיל ועבר על שבועתו עכ"ל והאמת שיש בזה מחלוקת הראשונים ולענין דינא כתבו גדולי אחרונים דהמקח בטל מטעם כל מילתא דאמר רחמנא לא תעביד אי עביד לא מהני וגם דעת הרמב"ם נראה כן [מל"מ פ"ט ממלוה] ואף באיסור דרבנן אמרינן כן [כתובות פ"א:] וזה שנתבאר דהמקח קיים אף באיסור זהו דוקא כשעצם המכירה אינו באיסור אלא שיש בה פרט מאיסור והיה יכול לעשותה בהיתר כמו שלקח חטים בזול מפני שהקדים מעות להמוכר וכן במוכר קודם שיצא השער וכן במוכר בשבת שהיה יכול ליקח קנייה זו בחול או כפי השער שבשוק או שיהיה השער בשוק אבל בנשבע שלא למכור חפץ זה הרי אין במכירה זו צד היתר כלל [סמ"ע] וי"א דהוה ספיקא דדינא [ש"ך וב"ח] ואף שיש ביכלתו לשאול על השבועה אין זה נקרא שביכלתו לעשות בהיתר דפנים חדשות באו לכאן ואין כאן שבועה כלל אבל כל זמן שהשבועה על מקומה אין בה צד היתר ויש מי שאומר דהעיקר לדינא דגם בזה המקח קיים דאין האיסור בהמכירה אלא בהשבועה ולא נקרא איסור בהמכירה עצמה אלא כשצוו חז"ל שלא למכור חפץ זה [כהך דכתובות שם] ולא במה שהאיסור הוא בהשבועה [ט"ז] ועוד די"א בכל הך כללא דאי עביד לא מהני אינו אלא באיסורים שהתורה או חז"ל גזרו באיסורו ולא באיסור שבדה האדם מעצמו ועשה זה לאיסור מפני שבועתו [תוס' תמורה ו'. ד"ה והשתא] ויש שמקשים על מה שכתבנו דבמקום שיכול לעשות בהיתר לא אמרינן אי עביד לא מהני והרי בכל האיסורים שחשבה הש"ס [שם] בענין זה ביכולת לעשות בהיתר [קצה"ח ונה"מ] האמנם דבדבר שהתורה צותה מפורש לא תעשה דבר זה בפרטות ועבר ועשה ודאי דלא מהני כיון שעבר על ד"ת משא"כ במכירות כשעשה בצד איסור הרי לא צותה התורה בפרטות לא תמכור באופן זה אלא שהאיסור כלול בין האיסורים וכיון שהיה יכול למכור בלא האיסור לא אמרינן אי עביד לא מהני [נ"ל] ויש מחלקים בין דבר שאפשר בחזרה ולבטל האיסור דבזה אמרינן אי עביד לא מהני כדי לסלקו מהאיסור שעשה ובין דבר שא"א בחזרה ואיסורא דעבד עבד ואין תועלת אם נבטל הדבר כיון דהאיסור כבר נעשה ואין להשיב [מהרי"ט ונה"מ] ולכן בכל מכירת איסור מקיימים המכירה ומבטלין האיסור כמו במכירת אגר נטר ומכירת שבת אי מבטלין דאיסורא דעבד עבד ולפ"ז בהקדים מעות קודם שיצא השער ונתייקר היה לנו לכוף לשניהם לבלי לקיים המקח כפי מה שפסקו ולא משמע כן מהפוסקים ולדיעה זו יש להסתפק בשבועה שלא למכור אם לבטל המקח אם לקיימו ולשאול על שבועתו ואולי זהו כוונת רבינו הרמ"א שבכאן כתב שהמקח קיים וביו"ד דמיירי באיסור שבועה כתב שהמקח בטל כלומר עד שישאול על השבועה אבל מחוייב הוא לשאול על השבועה כדי לקיים המקח ועוד אפשר לומר דודאי הלוקח ביכלתו לקיים המקח בע"כ של המוכר דמה לו ולשבועתו של המוכר אבל אם הלוקח אינו חושש בביטולו כפינן את המוכר שיבטל המקח ולא יעבור על שבועתו [ולכן דקדק לומר המקח קיים ושם כתב אין במכירתו כלום] והעיקר לדינא כדבריו שבכאן [וראיה ברורה ממשנה דשבועות כה. שבועה שלא אתן וחשיב לה בשבועת ביטוי ואי ס"ד דאין בנתינתו כלום היכי משכחת לה שיעבור על שבועתו והרי אף אם נתנה והמקבל לא החזירה כגזל הוא בידו]: