If you are not using stored procedures, the most important part of a statement-type element is the SQL. You can use any SQL statement that is valid for your database system. Since SQLMap passes the SQL through to a standard libraries (Adodb for PHP), you can use any statement with SQLMap that you could use without SQLMap. You can use whatever functions your database system supports, and even send multiple statements, so long as your driver or provider supports them.
Because you are combining SQL and XML in a
single document, conflicts can occur. The most common conflict is the
greater-than and less-than symbols (><). SQL statements use these symbols as
operators, but they are reserved symbols in XML. A simple solution is to
escape the SQL statements that uses XML reserved symbols within a CDATA
element. The following example demonstrates this.
Many database systems support auto-generation of primary key fields, as a vendor extension. Some vendors pre-generate keys (e.g. Oracle), some vendors post-generate keys (e.g. MS-SQL Server and MySQL). In either case, you can obtain a pre-generated key using a <selectKey> stanza within an <insert> element. The following example shows an <insert> statement for either approach.
You can use SQLMap to execute any SQL statement your application requires. When the requirements for a statement are simple and obvious, you may not even need to write a SQL statement at all. The <generate> tag can be used to create simple SQL statements automatically, based on a <parameterMap> element. The four CRUD statement types (insert, select, update, and delete) are supported. For a select, you can select all or select by a key (or keys). The following example shows an example of generating the usual array of CRUD statements.
The tag generates ANSI SQL, which should work with any compliant database. Special types, such as blobs, are not supported, and vendor-specific types are also not supported. But, the generate tag does keep the simple things simple.
The generate tag supports two attributes.
Attribute | Description | Required |
---|---|---|
table | specifies the table name to use in the SQL statement | yes |
by | specifies the columns to use in a WHERE clause | no |