Excel-DB Advanced
Features
Advanced Database Connections:
Using the Data Link Properties wizard
The Data Link Properties wizard can be
used to connect from MS Excel to your database. For Excel-DB -
or any other program - to connect to your database through ADO
you need to specify a connection string. The Data Link
Properties wizard helps you to build a connection to your
database. Once the connection string is known Excel-DB will save
it and reuse it in the future without the need to go through
it all again.
Using the ODBC Data Source Administrator
The ODBC Data Source Administrator program in Windows can be used to connect
from MS Excel to your database. For Excel-DB - or any other program - to connect
to your database with the ODBC driver it needs a so called DSN: Data Source
Name. A DSN can be seen as a nickname for your database.
Batch execute Multiple Statements
The SQL dialog in Excel-DB has the
capability to take multiple SQL statements and other commands at the same time. When
submitting more than 1 SQL statement each statement should be ended with a semi
colon character (;). The source of the SQL does not
matter. Multiple select statements can be submitted from a SQL file, a worksheet
or from the SQL dialog itself. Let's give a few examples:
To query both
the emp and the dept table in one go enter the following into the SQL dialog (note that it also times these
queries):
set timing on;
select * from emp;
select * from dept;
Explicit Column Formatting
The Explicit Column Formatting feature of Excel-DB is the implementation of
SQL*Plus like commands with which the
resulset data can be explicitly formatted. These commands can be issued in the
SQL dialog.
The commands
supported in Excel-DB are:
column <column_name> format
<format_spec>;
column <column_name> format
<cell_reference>;
column <column_name> heading
<heading_text>;
Rerun a query
After a query was executed it can sometimes be handy to be able to rerun the
same query and effectively refresh the data. In Excel-DB there exists a shortcut
to achieve this.
Simply select the top left cell of the previously
created resultset table and execute the menu command Excel-DB|Query. It will now
load the SQL back into the query editor of Excel-DB. You can now rerun this SQL
statement.
Execute Excel-DB from Excel macros (VBA)
Excel-DB's internal commands can be used from within the macro editor of Excel.
By using VBA you can automate your Excel-DB tasks. Just record an Excel macro.
The easiest way to get started programming
Excel-DB commands with VBA is to record a macro in Excel and look at the generated
code.
Calling Procedures and Functions
You can call your database (package)
procedures and functions using Excel-DB. If you use an
Oracle database just wrap the function or procedure call in
a begin and end statement. Alternatively you an use the exec
command to run a procedure or
function: