Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: static/dynamic/embedded SQL distinctions
jrefactors_at_hotmail.com wrote:
> I want to distinguish between static SQL, dynamic SQL, and embedded
> SQL, but couldn't find too much useful resources in the web.
>
> For example, if we put SQL statements (SELECT, INSERT, UPDATE, etc...)
> inside an application (e.g. Java application, VB application, etc...),
> do we consider those SQL statements as static SQL? or embedded SQL?
>
> How about dynamic SQL? any practical examples?
>
> Please advise. thanks!!
My take on that would be...
static SQL
while(rs.next()) { System.out.println("colA: " + rs.getString(1)) ; System.out.println("colB: " + rs.getString(2)) ;}
dynamic SQL
"SELECT colA, colB from tableA" + (null==sCity ? "" : " WHERE city=?") ) ; if(null!=sCity) { pstmt.setString(1, sCity) ;
java.sql.ResultSet rs = getStmt(con, "London").executeQuery() ; while(rs.next()) { System.out.println("colA: " + rs.getString(1)) ; System.out.println("colB: " + rs.getString(2)) ;}
As for embedded SQL, I've always thought of that as putting SQL statements in code (in a language-neutral way) and using a preprocessor of some sort to generate code in place, e.g what Pro*C does for Oracle: http://www-db.stanford.edu/~ullman/fcdb/oracle/or-proc.html Received on Mon Aug 22 2005 - 14:54:44 CDT