DataBase Cursor
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
DataBase Cursor
I have a routine where I open a database and read all of the table names into a field.
I use this data to select a table that I would like to do a query on. I cannot query the tables. is this because the pointer of cursor of the database is at the bottom and needs to be reset?
I use this data to select a table that I would like to do a query on. I cannot query the tables. is this because the pointer of cursor of the database is at the bottom and needs to be reset?
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: DataBase Cursor
Hi,
I'd use revdataFromQuery() function:
I'd use revdataFromQuery() function:
Code: Select all
put "SELECT * FROM users ; " into tSQL
put revDataFromQuery(tab,return,connID,tSQL) into tRecords
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: DataBase Cursor
Thanks Max,
I actually found the problem.
I was beating my head against a wall that was somewhat impenetrable. I found out that LiveCode cannot process tableNames that have spaces in them. It throws a "revdberr" message.
Does anyone have a work around for this problem? Unfortunately I am not in control of the data source and I need a fix.
I actually found the problem.
I was beating my head against a wall that was somewhat impenetrable. I found out that LiveCode cannot process tableNames that have spaces in them. It throws a "revdberr" message.
Does anyone have a work around for this problem? Unfortunately I am not in control of the data source and I need a fix.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: DataBase Cursor
This isn't an LC issue. This is an SQL parser issue. You "quote" tablenames and fieldnames in SQL by surrounding them with square brackets.
Re: DataBase Cursor
SELECT [field name with spaces embedded in it] FROM [table name with spaces in it]
This isn't an LC problem. It's a result of the way the SQL parser works (tokens are delimited by spaces).
This isn't an LC problem. It's a result of the way the SQL parser works (tokens are delimited by spaces).
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: DataBase Cursor
Mikey,
This is the code that I used and the same problem is still existing.
put "SELECT * FROM [465 halstead coppercube_10100_tl1]" into tSQL
put revDataFromQuery(tab,return,lDatabaseID,tSQL) into tRecords
put tRecords into field "Field2"
What am I doing wrong?
This is the code that I used and the same problem is still existing.
put "SELECT * FROM [465 halstead coppercube_10100_tl1]" into tSQL
put revDataFromQuery(tab,return,lDatabaseID,tSQL) into tRecords
put tRecords into field "Field2"
What am I doing wrong?
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: DataBase Cursor
Have you tried putting that query into valentina to play with it? Without looking at the schema it will be hard to tell exactly what's going on.
Are you sure the 465... is a table name and not an item value?
Are you sure the 465... is a table name and not an item value?
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: DataBase Cursor
Mikey,
I don't have Valentina.
The 465 is part of the table name.
I actually made a copy of the table without the spaces and the code works (this is before the square brackets). This is how I found out about the spaces in the Table Name and spaces.
So, the square brackets don't seem to be working for me yet.
I don't have Valentina.
The 465 is part of the table name.
I actually made a copy of the table without the spaces and the code works (this is before the square brackets). This is how I found out about the spaces in the Table Name and spaces.
So, the square brackets don't seem to be working for me yet.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: DataBase Cursor
Valentina is free to download and makes it easy to mess with databses, test queries, etc.
Again, without seeing the schema it will be difficult to help much more, but if you google spaces in table names you'll see more about it.
Again, without seeing the schema it will be difficult to help much more, but if you google spaces in table names you'll see more about it.
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: DataBase Cursor
Mikey and all who need it.
Thanks to Mikey for helping me.
During a search I found the answer.
Use the tick symbols which you can usually find on your keyboard to the left from digit 1.
This Works.
Thanks to Mikey for helping me.
During a search I found the answer.
Use the tick symbols which you can usually find on your keyboard to the left from digit 1.
This Works.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
Re: DataBase Cursor
Does the following code work?
Code: Select all
put "SELECT * FROM " & quote & "465 halstead coppercube_10100_tl1" & quote & ";" into tSQL
put revDataFromQuery(tab,return,lDatabaseID,tSQL) into tRecords
put tRecords into field "Field2"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Re: DataBase Cursor
Hi Max,
I tried many iterations of quotes but I don't remember just using the keyword quote. I used "put quote &" and that didn't work.
I'll try that later.
Thanks.
I tried many iterations of quotes but I don't remember just using the keyword quote. I used "put quote &" and that didn't work.
I'll try that later.
Thanks.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com