ViaCognita
(ViaCognita)
1
Hi!
I’m using Unreal 5.0.3.
Do you know if there is an example of FSQLitePreparedStatement
to do a Select with many results?
I have to do this SELECT:
"SELECT RArad, DErad, Hpmag from Catalogue"
It will return more than one row, always.
Thanks.
ViaCognita
(ViaCognita)
2
I’ve done it this way, but I’m not sure if it is the best way to do it:
TArray<FStar> ACataloguector::GetVisibleStarsWithinMagnitude(
double SmallerMagnitude,
double BiggerMagnitude)
{
TArray<FStar> Stars;
FSQLiteDatabase* CatalogueDb = new FSQLiteDatabase();
if (CatalogueDb->Open(*DbPath, ESQLiteDatabaseOpenMode::ReadOnly))
{
FSQLitePreparedStatement* PreparedStatement = new FSQLitePreparedStatement();
if (PreparedStatement->Create(*CatalogueDb, *MagnitudeSQL, ESQLitePreparedStatementFlags::Persistent))
{
if (PreparedStatement->Execute())
{
while (PreparedStatement->Step() == ESQLitePreparedStatementStepResult::Row)
{
FStar star;
PreparedStatement->GetColumnValueByName(TEXT("RArad"), star.RArad);
PreparedStatement->GetColumnValueByName(TEXT("DErad"), star.DErad);
PreparedStatement->GetColumnValueByName(TEXT("Hpmag"), star.Hpmag);
Stars.Add(star);
}
}
}
PreparedStatement->Destroy();
delete PreparedStatement;
}
CatalogueDb->Close();
delete CatalogueDb;
return Stars;
}