effective decision support systems require
flexibility in interacting with the user
decision makers may not always know
exactly what questions they want/need to ask
b/c decision makers may not know what questions they want to ask, it is important to
support “what if?” questions
pre-determining a list of potential queries can be
very limiting
using parameters within a query allows
the user to decide exactly what data to return
with parameters, the database programmer:
sets up the structure/template for the SQL statement, but leaves certain values unspecified
parameterized queries greatly improves
the usability of the system
parameterized queries are frequently used in (and also used in)
web-based DSS
- also used in desktop applications (.NET -> MS Access)
- also used within actual DBMS
within MS Access, parameterized queries can be used by
building userforms and collecting the parameter values as variables from the user
parameterized queries can also be called from other applications using a
DB provider/driver
(PHP/ASP.NET/VB.NET/Java)
example of calling parameterized queries externally
dim cmd as New OleDbCommand(“SELECT * FROM Customer WHERE LName = ?”)
Microsoft Access specific format
parameter order matters
“SELECT * FROM table1 WHERE col1 = ? OR col2 LIKE ?”
SQL server specific format
supports named parameters
“SELECT * FROM table1 WHERE col1 = @someCol1 OR col2 LIKE @theColour”
Oracle specific format
“SELECT * FROM table1 WHERE col1 = :someCol1 OR col2 LIKE :theColour”
advantages of parameterized queries
when query is compiled once at beginning,
parameter values can then be set as needed
SQL injection
consists of inserting or injecting SQL code via data that is sent to a DBMS, when (non-parameterized) dynamic SQL is used
because a parameterized query is expecting only the values for missing parameters,
it will protect against many SQL injection attacks
SQL injection example
; DROP TABLE employee;–