dynamic query to drop table
OrangeDog, thanks for asking!
Perhaps you are correct that it is an SQL rather than Java question, but I am using Java.
I am writing the program in java. This program needs to do everything dynamically. Saying that there are 2 tables was only an example. Basically I need to create tables with a suffix based on the tables that exist in the database. Thus for example, if x, y, z, are tables in the database, I need to create tables x_1, y_1, z_1. I have succeeded in doing that dynamically, meaning if the existing table is x, append _1 and so on. However, before I create them I must drop x_1, y_1, z_1, but not x,y,z. In the following
String dropTable = "drop table " + TableName. -- after the dot I see many methods in java. One such method is contains(CharSequence s), but it returns boolean, so the error is can't drop table TRUE. Substrings require beginIndex and would return string values, but do not give the correct result.
Using concat, i.e. "drop table " + TableName + "_1" makes the table X_1_1, Y_1_1, which does not exist. Any ideas?