お知らせ
2023.12.5(Tue)
目次
みなさまこんにちは。黒木です。
前回のブログではX++におけるSQLの書き方を紹介しましたが、今回はSQLの書き方応用編をご紹介します!
前回のブログはこちらです。
Dynamics 365独自の言語! X++入門講座《基本的なSQLの書き方》
while select tableA where tableA.column1 == 'aaa' { tableA.column2 = 'bbb'; }
ttsbegin; update_recordset tableA setting column1 = 'aaa' where column2 = 'xxx'; ttscommit;
ttsbegin; while select forupdate tableA index column1 where tableA.column2 == 'xxx' { column1 = 'aaa'; tableA.update(); } ttscommit;
INSERTについては、メソッドの紹介のみで留めておきます。
INSERT処理でも、insert_recordsetなるものが存在します。現場では 前回のブログ でご紹介したinsert();を使うことが圧倒的に多く、insert_recordsetを使う機会はあまりありませんでした。
delete_from tableA where tableA.column1 == 'sss';
続いて結合条件についてご紹介します。
select firstonly tableA outer join tableB where tableA.column1 == tableB.columnA;
select firstonly tableA notexists join tableB where tableA.column1 == tableB.columnA;
いかがでしたでしょうか?
ここまで分かれば、X++でSQLを書くのには困らない……はずです! 次回はメソッドや構造体についてご紹介しようと思います。
それでは、また。
《関連記事》