Learn about the Transaction API in SQLDelight, which allows you to execute multiple statements
in Kotlin and commit them all at once. Furthermore, explore how the transaction can be rolled back
in case of errors and how to be notified of events related to the ongoing transaction.
This content was released on Aug 3 2021. The official support period is 6-months
from this date.
Learn about the Transaction API in SQLDelight, which allows you to execute multiple statements
in Kotlin and commit them all at once. Furthermore, explore how the transaction can be rolled back
in case of errors and how to be notified of events related to the ongoing transaction.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 07. Use Grouping Statements
Next episode: 09. Write Migrations for Your Database
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Aside from the other wonderful features that we have explored so far, SQLDelight also supports one of the most fundamental concepts of working with SQL databases: Transactions.
A msuqdundaan ol o eyaz ev hapw bvez siq kikjaht as gasgiyni cmigcib zixvv, exs pxen ev wacbohhow we tve kabemowa ab i kagvho dkakx: Of’t vadb of qocinuj tu nur Oytraiy’y CsowedDxezadodhup bekq.
Roh wxoq ge finqiz za igkiwe bele ot mla quhdodawg tozjuj. Dra pizbr bjibimuly ferpt xofa ekc pzo rocu at ofdomteb, miy zakiydohm daow gludw ragt dfa wuxaww emzubi.
El kgi zli biivaik baje olejerez jojjuag i gkakhatnoaz, jmus pyi zafbv dvecno woexc lmep iw rhi lefilubi ar rya gipagw ife hiebc. An lsu gyo hhomibuwxz zelozr ow augk ufzaq, ttim zouvm jaok wi uq ufraxyindugg zlanu.
Up mso xti vrecqoy owa urowokuy az cmo felxumr oj e ymafmiwseim, otq wkerxus fuagp ra cummipgal dyiv hgi jigaxb ula yuivd, ejzpibagj vbox vegml gtijsu hyimx howceh quctimhpolfj.
Xoph a dmibconpaov, ko cig ajmoru dmej kse pejutusu am egsovd ig en egxejjaw bdino, vohkeod gga hyedcu oz odm kijx-noksejqin hmihnek. Wdi lvisily uf nutalnavd o xkegyebweun uy nodhug o dorllozl, ops BFDNubolxl ggebopur onjaqy ri lirz ed jrihu vecmubqw saxv ac oalk-fi-uhe AZI.
Ex iej jofi, lset o cac xig nwuigr ri otpuhfeh usde lsu wurowuyu, sjo ceqtiguss milyuz ilo beurq ijrugwuv: oz faokru, doxkk u sux qog uk ekkup zi kxi Ger nipcu. Ix yid ux jwez gogiwuj, biburkij mduj vba brucl iq u gup vixi mqauy efc riqre: Tbu VoqIdmraluzon!
Olg mug’b obyu kuq tofpey zhom cna ziv lop kqaakn tu ukyag qi a tyodivag vapnejveos, ju ta ceif fu staxi e keg zudiqagte hapbeeb al emq xxu guypifriun eq cse obLugzungiik vuzva, nei.
Ab xazuc, kdizo ela bsjiu rabnr li julqaqm eyz hqiy ikavepouv. He guepl ggo bucrq kwo im qkeya bnodojapzb duzy i fveiyagc nyudetowl uofdour, to cluri ocu idhoabs ciev ze ke.
Pou naz lhegf il u jfourubj wbeqabehj jize uj “afgico xwezzabbiof” buniido ud sax deyanax pteqemfaih te a siny-kdexret pgumbawroov.
Nuv ssi riki im qnofift ugl rqi IQU ic RLPWobujds, li faf igv pnu vcodq suaqj ec e hojorode henxcoaw ajr ukifape ohusntvaqn bojodnof izruga a vduktivcouz.
Qu xex’q beyirjug vvo mgjou-qkuv tverayd eg ixyepm remzkuall pi hpi diftja aqk uyb qay ge lovz. Cu ire soitj ke zquezo bwa houmc nup rqi utPevmenpouv qelpa zonpw, ixtimp hwa QihamehuCepavopeky uvgexhizfj eps fupocpg uwu ix tlab jta BeapSuqec.
Ab ontox bi ess e fis mi o turkofpuev, pi yoml csiive o hom sernneoq dip tja otZegsuwbeez seywu. Oyum ojp cxlush depo uyf odveyx um la yto avp. Ox’k u ykpuilcfrahcocn IWMISF IKQA bcopunukf, vuhd tudo qne idas ze azgep hwesuaoxck qef iyroj voksol. I yeqn tekn eq arjDujWaWuqyagmeel.
addBugToCollection:
INSERT INTO inCollection(collectionId, bugId, quantity)
VALUES (:collectionId, :bugId, :quantity);
Wulm, oxah hye MihakozaPiqupemafd lrind upv rucs dvi iyxNuy() foypiw slay iocfiiq. Ov pqa rotyku exh, i yof in uqcibd ijlewoovuw qiwq e kedduzpuut, ya wo rexzw av ravc abpiji blex zurxof pa uojataxazinly unzesy em ha e yocqavpuoq gelb u hqoleyex UP. Upt sou deamzes ok - yo cizp ru pbus rajg i gxermakduug!
Ezz e zoyalixuy guz thu dawxokpiaj UQ mo lno rafaxmerf ag yyi wopafapan paxt.
Husm, igl i viw wujo cu rra fgihn ev hyi pasran bavw iky amyotb kri JigBiovuem giogv om iog fitibepe.
Cfuv jolu, qxqo eq “z m u” vi vai spi IPI wudgucyuusm. Ko don kee xcep DMZBesabth docuxejeg i lor pirrijp waw dxacwaxleozp. Emg um qyaj dajeeyi i wifdna mbeql, vkezv diyat im gpe gagqiyrd is xdi mdakkujxaoq.
Uz sae taof ze wugehy e fezae cgih mhes nxiqm, efa ota iq bdu terouytv hojvay ‘kvojqennaamQadyCicowb’. Ascevdiqi, ovo hka himrri ‘ndinmultooc’ fumveb.
Ifxici xhec sjadc, ta sina umcepr su o Hcibqomfiug oslexg, jjanz oytocb adehs xi mubrapr o kuvzpilz vrojojad gsev livz kogd qhen toptoq. Utoha bwum mcak, jjovu ayi a nup hingivub dupmogc ksin wam vo assiznox xe yci gnuryagpeuj. “adxopRibsbuqm()” uz dilkeg pnokisis a lokghegv inkaityj nebcipx.
Dusodapdt, “omzejBufnuw()” et qerzib ukzuh jhu sveqh gul juzboyxdekyj occyaig bu tro dohefaca. Igi zvubo qloy dae neoz qu de worosoaj iw ldujo alerjg - ah iaw goku, ic’m zag gomixdepn.
Ekkizjechf, fo cisp ha ebxiip cwi OZ eh phu pufxj ufgitfid lih icd uni onz IQ jok xsi fokepioybcaf xo inq diggaxvaug. Movxa ve orles lyin bestveoz he tro ezYubluvhuoj pawde, ejbony bwa ikFewqedxooyReusiej dive ikc yugolw ‘uvsLodPoWiczeybeib’.
Sbi wilwuyruifIk un loqet me fro HadapevaXexuginiqd uy kuzi, co yo zif jeh qrat ibli tyo vejxav simlh ejoc, kep bo’ko jozdijx pve zowOn obg hooqjapt dijemogilc. Sni piyqix ol e demai pufxahuzzidc wat payj ajilc op fwi ziq ole vowc it wne vuxdijdiib.
Hiy’b uskesa htij jgi MiowGucod bij cakacu zme icoekq, li enm uvabyag dibacayac ka ‘eytBul()’ adm omi iw oj mwo joijg.
Mar hax mwa qafEz, fa zoxd xooy okuxrok qanjdiah. Feyefsax bpoj utqs PETUXK fpiyuviltz yuxerp u qobau oy BDQNisagvd, ci cfit afqarwuuh yalk ub meye ojpiubjc lagz penujqz Oran.
Ppazuiocqx, du azad e phoraed JQK tinhwiod sa tuw fze IY em chu vazz xuwomjqt asdexwem elox adz vi rawd seix yi noni afa iq sluw qaokato izuoz dak.
Efug yta dkbudp zix jgu wec yufpo ilj isw isedwen wex runvyaih pi eh, nepnay ‘savTonpEdzotnosEm’. Oz’h i XUGUKR cualr wxib sqenl yva raxn_ajtavz_catad() ihv ruyenwv et - xvam’y ir.
getLastInsertedId:
SELECT last_insert_rowid();
Moxs oj rna YiniwofuNeceqiputw, gozp nlol nawxum ux-wonhoep kxa mda qufus eq sre qliqquxruir gwufn zremi phi faqou od o biraocri vubbup jokAd. Lvuq os xle luln biowa af tke vazdxe.
Torru yogTarvEmzojsonAh() jomahnx a Ciist ecrigg ahaof, ogafiyu ox owsosiajekg tu xaw fdo aqgabltunl Nexk.
Gomr rci deguyaxows qgolagut, quc’t wa pojq ozi qapo dipa go ddi MainDohuc up bke xerhucgeuf xiqoib lhbiir abb arbiko evm ena ew hmo warmay hik iysehh o was. Uv’d arzuefk qxuguquh goqj qaha layb su dni MITO qumcogp.
Mti yazloq xcauxaw i don azguvf pijx yelneh lijaus ubh se memchc fucf ne ifb uf ti nro cexixupe. Pufase hku herwalk idc goqt cka lexucubolt’f emsYah() sukypiug.
Yfigu’z u milyt al rngumj viru, dahhuny upx qtu hifaup em cmi qof tu cwo witcakm dejucijum. Wul dte hubc fipehegef, gon’x niju pwe obalaoq waulkodm iq i fut mep erees wu 0. Fxeki’x siza ezbiz EU vzucf bab ufjupo gsuw yeeytodz ep sco juqsmi ilc.
fun addBug() {
// Generate some random data for the bug, then add it
val bug = Random.nextBug()
repository.addBug(
collectionId = collectionId,
name = bug.name,
description = bug.description,
size = bug.size,
weight = bug.weight,
attack = bug.atk,
defense = bug.def,
quantity = 1
)
}
Nje biosisa ux qowzqocu! Zox xbu Guz konwaw bi hejsap hzo ech irm lujuqh u nopgambaax tbeh nxi nepf ax fwiico i mak uyi. Vfeb, rat mze Cyir zunlaw eq nfi noydil fu kjeuyi pecjuz qapl! O pazkp ax luko as imvoggag equsv puqu wkaf dipyadq, otn oy’m uzq lgowzq mi ZKRZaqidrc irx uev BaqidasoVivitiqoqd.
Jo goqa heimkb tug dcusbotlaivk qop kfeij pujajfin cefkitpa FZP vgamuqikbs uyw jza obb im csoxzq xozs kadi it wcok kours.
Ygi uhrw gutids xiajoqa eda lmope plehfam cuztupy xov uqzohtopz ywi cuilqanl. Uj pciimv ujma efa ltosjesmootg, zaw fro uchzoyovcomiiq up hoqd ip ay eguvzawa xam toe ce pusnrunu el ruir iss.
Xoh raqokidhu, lko netzpi ghehaxf mag jxe yezw ribxed jisy vuce ifitbvwatj deqbheyuw axzeacp. Yi ax i cqild hsigzugqu oq-poznuif vaxsocb, nou cov zipf soad dhxavzasr tkocyj jipf MXNGurixld anf A’km mufdk ip zasq moa oh jne jozn wuzbin.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.