why should my database have no numbers as names

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo,
why should my database have no numbers as names?

B4X:
 ayir2(0) = "34783478389"

B4X:
SQL1.ExecNonQuery("DROP TABLE IF EXISTS " & ayir2(0))
SQL1.ExecNonQuery("CREATE TABLE "  & ayir2(0) & " (Nummer TEXT , Name TEXT, Mesaj TEXT , Link TEXT, Datum TEXT)")
SQL1.ExecNonQuery2("INSERT INTO "  & ayir2(0) & " VALUES(?,?,?,?,?)", Array As Object(ayir2(0), ayir2(1), ayir2(2), ayir2(3), ayir2(4)))

I always get an error, if the name is a number.
PS: the number is a String and not Integer or so...


grüße
sinan
 

mc73

Well-Known Member
Licensed User
Longtime User
It seems that table names cannot begin with a decimal character.
Look here.

Best regards.
Didn't check the link, but I see no reason for arithmetic names in sqlite. We simply have to add `` at the borders of the name.
B4X:
create table `1234`(id integer, something text)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Sinan asks:
why should my database have no numbers as names

Yes, you can use all numbers as a table name provided you enclose the table name in brackets, although I would avoid it if possible. I have tested it and it works. In this case the table name is: 34783478389. Here is the working code:
B4X:
ayir2(0) = "34783478389" :ayir2(1) = "Test1" :ayir2(2) = "Message1"
ayir2(3) = "Link1" :ayir2(4) = "22034m"

SQL1.ExecNonQuery("DROP TABLE IF EXISTS [" & ayir2(0) & "]" )
SQL1.ExecNonQuery("CREATE TABLE ["  & ayir2(0) & "] (Nummer TEXT , Name TEXT, Mesaj TEXT , Link TEXT, Datum TEXT)")
SQL1.ExecNonQuery2("INSERT INTO ["  & ayir2(0) & "] VALUES(?,?,?,?,?)", Array As Object(ayir2(0), ayir2(1), ayir2(2), ayir2(3), ayir2(4)))
 
Upvote 0
Top