Connection.getmetacolumn — get the names of columns in meta data recordsets
string Connection.getmetacolumn ( |
metaid) ; |
int | metaid; |
This method is used to find the names used by a data source provider for certain types of meta data. For example, you can use the Connection.opentablesrs() method to open a recordset listing all available tables. However the columns returned in this recordset will be highly dependent on the data source. A call to Connection.getmetacolumn(RSP_DB_META_TABLENAME) would return the name of the column containing the table names.
The parameter metaid should be one of the Meta Column Constants, depending on which column name you're interested in:
The method returns the name of the column requested, or "" if that column is unavailable from the data source. If the metaid has an invalid value then the result is undefined.
Example 61. Connection.getmetacolumn Example
// Get a list of all tables in the database. Ignore views and other objects. string nameCol = conn.getmetacolumn(RSP_DB_META_TABLENAME); string typeCol = conn.getmetacolumn(RSP_DB_META_TABLETYPE); string type = "TABLE"; // This array will be filled with table names string[] tables; Recordset rs = conn.opentablesrs(); if(rs == null) { %><p>Error: <%=htmlencode(error())%></p><% } else { int count = 0; while(!rs.eof()) { // Get the table type if that column is available if(typeCol != "") type = upper(rs.getstring(typeCol)); if(type == "TABLE") tables.resize(++count, rs.getstring(nameCol)); rs.next(); } rs.close(); }
Data sources and database access in RSP is explained in the section called “Accessing Databases”