ExecuteQuery - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

Connection

  

ExecuteQuery

  

execute a Single SQL Query

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

connection:-ExecuteQuery( stat, opts )

Parameters

connection

-

Connection module

stat

-

string; the SQL query to execute

opts

-

(optional) equation of the form output=name

Description

• 

ExecuteQuery executes an SQL query over connection.  The SQL string stat must contain only a single SQL statement that performs a query and returns a single table.  Passing any other statement to ExecuteQuery is an error.

• 

By default, the value returned by ExecuteQuery is a Result module. However, you can specify a different format by specifying the output optional argument.

  

output = result, table, Array, or browser

  

Specify the type for the return value of ExecuteQuery.

  

- result returns a Result module.

  

-  table formats the SQL table as a Maple table.

  

-  Array formats the SQL table as an Array.

  

-  browser opens a Maplet application to visualize the SQL table.

  

For more information, see ToMaple.

Examples

Query some data from the database.

driverDatabaseLoadDriver:

conndriver:-OpenConnectionurl,name,pass:resultconn:-ExecuteQuerySELECT * FROM animals

resultmoduleoptionunload=Close;localhandle;exportNext,Previous,Last,First,GetRowNumber,GotoRow,GetRowCount,InsertRow,DeleteRow,UpdateRow,GetData,UpdateData,GetType,GetName,GetColumnCount,SetOptions,GetOptions,Close,ToMaple;end module

(1)

Show the results.

whiler:-Nextdor:-GetDataid,r:-GetDataname,r:-GetDatanumber,r:-GetDatamassenddo

1,fish,100,0.0100000000000000002

2,dog,10,20.5000000000000000

3,cat,10,5.50000000000000000

4,rat,50,0.500000000000000000

5,horse,3,400.300000000000011

6,snake,1,7.75000000000000000

7,lizard,5,0.100000000000000004

8,parrot,20,2.

9,pig,4,10.

10,hamster,30,0.200000000000000012

(2)

Perform a more complex SELECT and convert the output to a Maple table.

c:-ExecuteQuerySELECT id, name FROM animals WHERE mass > 5,output=table

table2,id=3,4,id=6,3,name=horse,1,id=2,5,id=8,4,name=snake,3,id=5,2,name=cat,1,name=dog,5,name=pig

(3)

Perform another SELECT and convert the output to a Maple Array.

c:-ExecuteQuerySELECT name, mass FROM animals WHERE number BETWEEN 10 and 50,output=Array

dog20.5000000000000000cat5.50000000000000000rat0.500000000000000000parrot2.hamster0.200000000000000012

(4)

See Also

Database

Database[Connection]

Database[Connection][ExecuteUpdate]

Database[PreparedStatement]

Database[Result]

Database[Statement]

Database[usage]

 


Download Help Document