MATLAB DATABASE TOOLBOX RELEASE NOTES Guia do Utilizador Página 546

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 684
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 545
7 Functions — Alphabetical List
7-116
sqlquery = 'select * from productTable';
curs = exec(conn,sqlquery,10)
curs =
Attributes: []
Data: 0
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: 'select * from productTable'
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 sun.jdbc.odbc.JdbcOdbcResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 sun.jdbc.odbc.JdbcOdbcStatement]
Fetch: 0
After finishing with the cursor object, close it.
close(curs)
Use a Variable in a Query
Using the dbtoolboxdemo data source, select data from the productTable table that
you access using the database connection conn, where productdesc is a variable. In
this example, you are prompted to specify the product description. Your input is assigned
to the variable productdesc.
productdesc = input('Enter your product description: ', 's')
The following prompt appears.
Enter your product description:
Type the following into the Command Window.
Train Set
To perform the query using your input, run the following code.
sqlquery = ['select * from productTable'...
'where productDescription = ' '''' productdesc ''''];
curs = exec(conn,sqlquery);
curs = fetch(curs);
Vista de página 545
1 2 ... 541 542 543 544 545 546 547 548 549 550 551 ... 683 684

Comentários a estes Manuais

Sem comentários