Page 1 of 1

Beginners Question

Posted: Fri Oct 11, 2013 2:41 pm
by trevordevore
[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.

Re: Beginners Question

Posted: Fri Oct 11, 2013 2:41 pm
by trevordevore
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.

Re: Beginners Question

Posted: Fri Oct 11, 2013 2:41 pm
by trevordevore
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.

Re: Beginners Question

Posted: Fri Oct 11, 2013 2:42 pm
by trevordevore
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