Beginners Question

This is the place to post technical queries about SQL Yoga

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, trevordevore

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Beginners Question

Post by trevordevore » Fri Oct 11, 2013 2:41 pm

[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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Beginners Question

Post by trevordevore » Fri Oct 11, 2013 2:41 pm

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:

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
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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Beginners Question

Post by trevordevore » Fri Oct 11, 2013 2:41 pm

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.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 882
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Beginners Question

Post by trevordevore » Fri Oct 11, 2013 2:42 pm

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
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “SQL Yoga”