[This post is an archive from the old SQL Yoga forums]
I'm just trying to begin learning SQL Yoga (and SQL). I've successfully connected to my database on my ISP server. But, there is nothing there at this time. I have a rev stack with a datagrid containing about 500 records. I have no idea how to get an array from that datagrid into my database. Can I do it all at once as an array, or do I need to do it one record at a time? Can someone please start me in the right direction? As I said before, I'm totally new to using any kind of database and SQL Yoga.
Beginners Question
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Beginners Question
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Beginners Question
Hi John,
The simplest way is going to be to sqlquery_create. You can loop through the Data Grid array and perform the insert for each record.
Take a look at this lesson on exporting data from a Data Grid: http://lessons.runrev.com/spaces/lesson ... Data-Grid-
In the repeat loop make the call to sqlquery_create:
The above assumes that each row in your data grid only has values in it that match fields in your table.
Let me know if you need additional info or clarification on anything.
The simplest way is going to be to sqlquery_create. You can loop through the Data Grid array and perform the insert for each record.
Take a look at this lesson on exporting data from a Data Grid: http://lessons.runrev.com/spaces/lesson ... Data-Grid-
In the repeat loop make the call to sqlquery_create:
Code: Select all
repeat for each item theIndex in theIndexes
put theDataA[theIndex] into theRecordA ## get array for 1 record from data grid
sqlquery_create "Name of Table", theRecordA ## insert into the database.
end repeat
Let me know if you need additional info or clarification on anything.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Beginners Question
It sounds like SQL Yoga hasn't imported a database schema yet as it can't find the table. You don't need to create an actual table object to use sqlquery_create.
Since you've already connected to the database you can use the SQL Yoga plugin to update the db schema. Here are the instructions:
http://revolution.screenstepslive.com/s ... efinitions
After you follow the above instructions you should be able to see your table listed in the plugin on the Properties tab. Try executing the code again and see if it works.
Since you've already connected to the database you can use the SQL Yoga plugin to update the db schema. Here are the instructions:
http://revolution.screenstepslive.com/s ... efinitions
After you follow the above instructions you should be able to see your table listed in the plugin on the Properties tab. Try executing the code again and see if it works.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: Beginners Question
SQL Yoga doesn't actually create tables in the database for you (yet). So if the table didn't already exist in the database then that explains why things weren't working.
Table objects are objects within Rev so when you create one the object just exists in Rev. You can read more about table objects starting with this lesson in the manual:
http://revolution.screenstepslive.com/s ... le-Objects
Table objects are objects within Rev so when you create one the object just exists in Rev. You can read more about table objects starting with this lesson in the manual:
http://revolution.screenstepslive.com/s ... le-Objects
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder