Perspective table. Scripting the data into the table

Im just starting to get the hang out of the scripting, and i used to test some scripts on vision that work perfectly fine and that don´t work anymore on perspective.
Im trying to put data from a SQL table into a perspective table by pressing a button but without doing a named query, the whole thing by scripting.
Any idea to where to start? i was thinking to do it all “local” by adding the script to a method in the button, and then call it on the event of cliking on it, so that it gives all the data to the table.

I’m not sure how much help you need but it’s not too hard.

In designer, right click on your button and click ‘configure events’. In the event configuration window select ‘onClick’ and then click the ‘+’ button. Select ‘script’ from the list. Now you have a place to write your script for the onClick event for that button.

Here’s some pseduo code that will help a little.

#create a query string
query="SELECT Col1,Col2 FROM Table"

#here's the command to run the query
returnedData = system.db.runQuery(query,"DBname")

#I don't recall if runquery returns a dataset, i think it does
#if it is a dataset than you just set the table property 'data' = to the sql return
self.getSibling("TableName") = returnedData

This is assuming you have a database connected to your gateway. Hope this is enough to get you started.

1 Like

It actually worked perfectly, Im going to try adding parameters and do experiments with this.
Thank you!

1 Like

Tagging this so I can test it on my project.