# DynamicSQL.jws Sample

This topic inludes the source code for the DynamicSQL.jws Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/database/dynamicSQL/

## Sample Source Code

`01 package database.dynamicSQL; 02 03 import database.dynamicSQL.ItemsDBControl.ItemRecord; 04 /** 05 * This web service demonstrates the different sorts of dynamically generated SQL statements 06 * and phrases that can be passed to a database control. 07 */ 08 public class DynamicSQL implements com.bea.jws.WebService 09 { 10 /** 11 * @common:control 12 */ 13 private database.dynamicSQL.ItemsDBControl itemsDBControl; 14 15 static final long serialVersionUID = 1L; 16 17 /** 18 * This method passes an entire SQL statement to the database control. 19 * 20 * The other methods of this web service pass SQL phrases to the database control. 21 * 22 * @common:operation 23 */ 24 public ItemRecord[] dynamicStatement() 25 { 26 String queryParam = "SELECT * FROM WEBLOGIC.ITEMS WHERE ITEMNAME LIKE '%" + "cycle" + "%'"; 27 return itemsDBControl.dynamicStatement(queryParam); 28 } 29 30 /** 31 * This method passes a SQL WHERE phrase to the database control. 32 * 33 * @common:operation 34 */ 35 public ItemRecord dynamicWhereClause() 36 { 37 return itemsDBControl.dynamicWhereClause("WHERE ITEMNUMBER = 624"); 38 } 39 40 /** 41 * This method passes a single value to the database control 42 * 43 * @common:operation 44 */ 45 public ItemRecord simpleSubstitutionWhere() 46 { 47 return itemsDBControl.simpleSubstitutionWhere(Integer.parseInt("624")); 48 } 49 50 /** 51 * This method passes a SQL LIKE phrase to the database control. 52 * 53 * @common:operation 54 */ 55 public ItemRecord[] dynamicLikeClause() 56 { 57 return itemsDBControl.dynamicLikeClause("LIKE '%cycle%'"); 58 } 59 60 /** 61 * This method passes a pre-formatted string into a LIKE clause. 62 * Note that the pre-formatted string does not include single quotes, because these are 63 * implicitly added when the value is substituted into the LIKE clause. 64 * 65 * @common:operation 66 */ 67 public ItemRecord[] simpleSubstitutionLike() 68 { 69 String paraMatchString = "%" + "cycle" + "%"; 70 return itemsDBControl.simpleSubstitutionLike(paraMatchString); 71 } 72 73 74 }`