#####################################################################################################
#!/usr/local/bin/perl -w
use DBI;
# use FileHandle;

##	The arguments $catalog, $schema and $table may accept search patterns according to the database/driver, 
##		for example: $table = '%FOO%'; Remember that the underscore character ('_') is a search pattern that 
##		means match any character, so 'FOO_%' is the same as 'FOO%' and 'FOO_BAR%' will match names like 'FOO1BAR'. 

##	The value of $type is a comma-separated list of one or more types of tables to be returned in the result set. 
##		Each value may optionally be quoted, e.g.: 


##	The statement handle returned has at least the following fields in the order show below. Other fields, after these, may also be present. 

##	TABLE_CAT: Table catalog identifier. This field is NULL (undef) if not applicable to the data source, which is usually the case. 
##		This field is empty if not applicable to the table. 

##	TABLE_SCHEM: The name of the schema containing the TABLE_NAME value. This field is NULL (undef) if not applicable to 
##		data source, and empty if not applicable to the table. 

##	TABLE_NAME: Name of the table (or view, synonym, etc). 

##	TABLE_TYPE: One of the following: "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", 
##		"ALIAS", "SYNONYM" or a type identifier that is specific to the data source. 

##	REMARKS: A description of the table. May be NULL (undef). 


%attr = (
       TABLE_CAT   => $catalog  # String value of the catalog name
     , TABLE_SCHEM => $schema   # String value of the schema name
     , TABLE_NAME  => $table    # String value of the table name
     , TABLE_TYPE  => $type     # String value of the table type(s)
  );


#
### Open the DBI Connection

my $data_source = 'dbi:Proxy:hostname=192.215.10.89;port=5731;dsn=dbi:ODBC:VNPoller';

my $dbh = DBI->connect("$data_source",'sa','',{RaiseError => 1, PrintError => 1}) or die $DBI::errstr;

## Returns an active statement handle that can be used to fetch information about tables and views that exist in the database
	
  $sth = $dbh->table_info( $catalog, $schema, $table, $type, \%attr );
  
  $sth->execute();
  
  	while( @row = $sth->fetchrow_array )
	{
     	print  $row[0]."\n";
   	}

	

$sth->finish;

$dbh->disconnect;

exit;
###------------------------------------------------------------------------------------------------------------------------------------------------------