FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to read DATABASES names from SQL server
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
How to read DATABASES names from SQL server
Posted: Tue Jan 24, 2012 01:30 PM

Hi all
I have INFORMIX server with few databases.
Please some help:

  1. How to read a list of DATABASES which exist on server (get list of databases)
    Something like: oOdbc:GetTables() for getting tables from database.

  2. How get a list of ROUTINES (procedures) for each of databases

  3. How to read content (text) of the some routine (procedure)

Best regards,

Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: How to read DATABASES names from SQL server
Posted: Thu Jan 26, 2012 08:25 PM

NOONE ? :(

Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: How to read DATABASES names from SQL server
Posted: Thu Jan 26, 2012 10:40 PM

sorry, i dont use mssql, but in ads i use the sql instruccion

SELECT * FROM system.TABLES

this return me a cursor with a tables in the database, can you search a similar intrucction in mssql.

salu2

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: How to read DATABASES names from SQL server
Posted: Fri Jan 27, 2012 05:06 AM
avista wrote:Hi all
I have INFORMIX server with few databases.
Please some help:

1. How to read a list of DATABASES which exist on server (get list of databases)
Something like: oOdbc:GetTables() for getting tables from database.

2. How get a list of ROUTINES (procedures) for each of databases

3. How to read content (text) of the some routine (procedure)

Best regards,

Code (fw): Select all Collapse
//  List of databases
cSql:="SELECT name FROM master.dbo.sysdatabases ORDER BY name" 

// List of tables from a database
cSql:="SELECT * FROM YourDatabaseName.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'"  

// List of user created stored procedures from the connected database, works from SQL 2005 onwards
cSql:="SELECT * FROM sysobjects WHERE type = 'P' AND category = 0 ORDER BY name"  

// Contents of stored procdure
cSql:="SELECT text FROM syscomments WHERE id = (SELECT id FROM sysobjects WHERE type = 'P' AND category = 0) ORDER BY colid "


CursorWait()
oRecSet:= CreateObject("ADODB.RecordSet")
oRecSet:CursorLocation := adUseClient
oRecSet:LockType := adLockOptimistic
oRecSet:CursorType := adOpenDynamic
oRecSet:ActiveConnection(oApp:oConnection)
oRecSet:Source :=cSql
TRY
   oRecSet:Open()
CATCH oError
   CursorArrow()
   MsgInfo("Failed to Retrieve Recordset data from the Remote Server")
   oRecSet:=NIL
   Return .F.
END
CursorArrow()
xbrowser oRecSet

// Show stored procedure content
MsgInfo(oRecSet:Fields("text"):Value)


Regards
Anser

Continue the discussion