dbListViews

Version 23.4.8839


dbListViews


Lists the views in the target database server. Depending on your configuration and the target database type, some of these parameters and output attributes might be irrelevant.

Required Parameters

Optional Parameters

  • includesystemviews: Whether to include system views. The allowed values are true or false. The default is false.
  • schema: The name of the database schema from which to list the views. The schema is commonly referred to as the namespace of a group of tables and views.
  • catalog: The catalog in the database server. This is commonly referred to as the database. If you do not provide a value, views from all catalogs in the database server are returned.

Output Attributes

  • db:name: The name of the view.
  • db:type: The type of the view.
  • db:schema: The schema to which the view belongs.
  • db:catalog: The catalog to which the view belongs. This is commonly referred to as the database.

Example

In this example, the targeted database server is MySQL and the targeted catalog (database) is sakila. Notice that there is no database parameter in the connection string: if the database is specified in the connection string, the catalog parameter is not required. This script writes all the attributes of the target catalog (database) to an output file.

<!-- Initializing the output item -->
<arc:set attr="output.data" />
<!-- Creating the input db item and the necessary attributes -->
<arc:set attr="db.driver" value="cdata.jdbc.mysql.MySQLDriver" />
<arc:set attr="db.catalog" value="sakila" />
<arc:set attr="db.conn" value="jdbc:cdata:mysql:server=localhost;port=3306;user=root;password=Password123;"/>

<arc:call op="dbListViews" in="db" out="results" >
  <!-- adding result data from the operation to an output item that will be pushed out as a file -->
  <arc:set attr="output.data">[output.data]\nView Name=[results.db:name]\nType=[results.db:type]\nCatalog=[results.db:catalog]\n-----
  </arc:set>
</arc:call>

<!-- setting the filename and pushing the file out --> 
<arc:set attr="output.filename" value="results.txt" />

The output file has the following format:

View Name=actor_info
Type=VIEW
Catalog=sakila
-----
View Name=customer_list
Type=VIEW
Catalog=sakila
-----
View Name=film_list
Type=VIEW
Catalog=sakila
-----
View Name=nicer_but_slower_film_list
Type=VIEW
Catalog=sakila
-----
View Name=sales_by_film_category
Type=VIEW
Catalog=sakila
-----
View Name=sales_by_store
Type=VIEW
Catalog=sakila
-----
View Name=staff_list
Type=VIEW
Catalog=sakila
-----

You can modify the example above to target other databases as long as the driver is installed on the machine where Arc is installed and running. Adjusting this example for .NET involves changing the driver and conn inputs as follows:

<arc:set attr="db.driver" value="System.Data.CData.MySql" /> 
<arc:set attr="db.conn" value="Server=localhost;Database=sakila;UID=root;Password=Password123;"/>