Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » simple example sqlite ref. not working core console
simple example sqlite ref. not working core console [message #52514] Tue, 15 October 2019 02:47 Go to previous message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

HI all-

Am I doing something wrong with this code?

I am running the most recent nightly build. MinGW with SQLite plug-in.

I tried another type of join too. That one didn't work either. At the end, I will put in a code block the SQLite code that works.

I also added a foreign key statement in the create table for SQLite.

Is there a trick for joining SQLite tables?

Hey guys, I am having bad juju. Today, I got a virus off a mirror that I frequent for code. Wah!
I ran this on my system with nmap, and there are no open ports Smile

thanks,
roboloki

TABLE_(a)
    INT_    (id) PRIMARY_KEY AUTO_INCREMENT
    INT_ (mydate)
END_TABLE
 
TABLE_(b)
    INT     (id) PRIMARY_KEY AUTO_INCREMENT
    INT_    (fk_A) REFERENCES (a)
    STRING_ (mytext, 35) 
END_TABLE


#include <Core/Core.h>
#include <plugin/sqlite3/Sqlite3.h>

using namespace Upp;

#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
#define MODEL <sqliteTest/ailien.sch>
#include "Sql/sch_header.h"
 
 
CONSOLE_APP_MAIN
{
    Sqlite3Session sqlite3;
    if(!sqlite3.Open(ConfigFile("ailien.db3"))) {
        Cout() << "Can't create or open database file\n";
        return;
    }
    
#ifdef _DEBUG
    sqlite3.SetTrace();
#endif

SqlId a("a"), b("b"), fk_A("fk_A"), mydate("mydate"), id("id"), mytext("mytext");
 
    Sql sql(sqlite3);
 Select(id.Of(a), mytext.Of(b))
.From(a)
.InnerJoin(b)
.On(id.Of(a) == fk_A.Of(b))
.Where(id.Of(a) == 2);
    while(sql.Fetch())
        Cout() << sql[0] << ' ' << sql[1] <<'\n'  ;
    
    //Error: Schema join not found ,a,       b (if I used a reference join syntax instead of plain old join)
}


select a.id, b.mytext from a join b
where a.id ==2;
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: with MariaDB (MySql) to capture error with Skylark
Next Topic: Jsonize() in database table structures (S_*) [patch]
Goto Forum:
  


Current Time: Sun Apr 28 01:31:40 CEST 2024

Total time taken to generate the page: 0.05104 seconds