Problem with SQLite INSERT statement, autoincrement column

Prolem solved

The SQLite database was located in the assets folder! But in this folder its not possible to make changes. So you can read from this SQLite Database without trouble but other operations like insert,update or deletes are not possible !!!

Solution use your own folder !

Hi there
I am new to the Kodular topic and I have a problem with SQLite.

(1) .OpenDatabase is reporting ok
(2) When i try to insert to the db I get an Error -1

What is wrong ?

grafik
tabeldescription… header_id with autoincrement

regards Franz

Are the Infomation exactly enough ?

as the header id autoincrements, remove that column and its value from the INSERT statement
Taifun

Hi Taifun,
I’ve had SQL know-how for several decades, so my first try was without this field, since I expected this field to be filled in automatically. But I have the problem with or without the ID Field
regards Franz

as test try to create a table without auto increment to verify, if the INSERT statement works there…

EDIT: you might want to provide a CREATE TABLE statement for that table, so I can test it in my sqlite extension…
https://puravidaapps.com/sqlite.php

Taifun

Good morning Taifun,
That would be really great if you could have a look there. Here are the tables in the database inventory

CREATE TABLE [inv_header](
[header_id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[header_date] TEXT NOT NULL,
[header_user] TEXT NOT NULL,
[header_text] TEXT NOT NULL UNIQUE,
[header_warehouse] TEXT NOT NULL,
[header_type] INTEGER DEFAULT 0,
[header_status] INTEGER NOT NULL DEFAULT 0);

CREATE TABLE [inv_line](
[line_id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[line_header] INTEGER NOT NULL,
[line_pos] INTEGER NOT NULL DEFAULT “1”,
[line_type] INTEGER DEFAULT “1”,
[line_item] TEXT,
[line_location] TEXT,
[line_qty_stored] INTEGER DEFAULT 0,
[line_qty] INTEGER NOT NULL DEFAULT 1,
[line_time] TEXT NOT NULL DEFAULT (DATETIME ()),
[line_counted] BOOLEAN NOT NULL DEFAULT FALSE);

regards Franz

here is the result using my sqlite extension
https://puravidaapps.com/sqlite.php

Taifun

Hi Taifun, i get crazy :rage:
Now I tried with your extention and with blocks from your testapp. I gget no result ???
What do I wrong
once more.

1) the content off the assets

2) the DDL of Inventory

3) see the folderstructur of the testmobil

  1. and now your code with my changes

5) the result ind lbl_count_Liste is
ERRPOR: no such table: Inventory.invheader (Sqlite code 1 SQLITE_ERROR):; while compiling: SELECT COUNT (*) from inventory.inv_header(OS error - 2 no such file or directory )

Besides I’ve teset with and without the databasename same result.

What dooing i’m wrong ???

regards Franz

this happens, because you do not use the Kodular workaround for the IMPORT method correctly
see Q11 about how to do it correctly here App Inventor Extensions: SQlite | Pura Vida Apps

Taifun

1 Like

Hi,
once more, but i don’t get sqlite up and running. No matter what kind of extension I use, it doesn’t work. In the end, is it due to my test phone or Android version 9.xx?

These little idiot procedures show the hurdle that I still have to overcome so that I can create useful apps.


The same result in both cases. I should mention one more thing. I noticed that when I create a data record with an external editor in the table inv_header, this record suddenly disappears after executing one of the two procedures ???

greetings Franz

Nobody an Idea ?

I only can provide support for my own sqlite extension
you might want to try my suggestion from my last contribution

and if you do not get it running, what about providing an updated screenshot of your relevant blocks?

Taifun

I am facing same problem does anyone found solution?

1 Like