Prepared Statement with ORDER BY

I am trying to use order by with prepared statement but it is not ordering.
String sql = "SELECT * FROM MATERIAL WHERE (LOWER(NAMEE) LIKE ('%' || ? || '%') ORDER BY ? ";
PreparedStatement ps=CM.getStatement(sql);
ps.setString(1,p);
ps.setString(2,sort);
          ResultSet r = ps.executeQuery();
Can any one tell me how do I use prepared statement with order by

You can not parameterize column names and such, only literals. You should build the ORDER BY clause dynamically.

Similar Messages

  • Could not find prepared statement with handle 13

    Hi,
    I'm having a terrible problem: When I try to execute a SQL Query the following exception is thrown:
    * "java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 13."
    This exception is thrown is this line:
    boolean returnResultSet = ((PreparedStatement)sqlStatement).execute();
    The sqlStatement object is a java.sql.PreparedStatement that was received as a Statement in the method definition.
    The following query is being executed in this PreparedStatement:
    SELECT id_promocao, ds_nome, id_tipo, ds_sinopse, dt_lancamento, pt_site, pt_caminho_relativo, fl_ativo FROM TAB_CINE_GM ORDER BY ds_nome
    I'm using Macromedia JRun 4 build 61650 and I'm using MS-SQL Server 2000 as a database server.
    If anyone can help, I'll thanks a lot.
    Helcio Chaves
    S�o Paulo - SP - Brazil
    [email protected]

    There is a common way to check runtime type:
    if (sqlStatement instanceof PreparedStatement)
    returnResultSet = ((PreparedStatement)sqlStatement).execute();
    else
    returnResultSet = sqlStatement.execute();
    }By the way - I can't understand why you're trying to cast sqlStatement to PreparedStatement? It doesn't matter at all due to so-called polymorphism of all Java methods (except static ones). Anyway execute() will run for PreparedStatement but bot for Statement
    Enjoy,
    Pavel

  • Could not find prepared statement with handle %.

    Greetings. I've seen several posts for this error on the web, but no clear cut answers. I captured the code below in profiler, with the intention of replaying in mgmt studio.
    However, the attempt end in the following error: "Could not find prepared statement with handle 612."
    declare @p1 int
    set @p1=612
    declare @p2 int
    set @p2=0
    declare @p7 int
    set @p7=0
    exec sp_cursorprepexec @p1 output,@p2 output,N'@P0 int,@P1 int,@P2 int,@P3 int,@P4 bit',N'EXEC dbo.mySproc @P0,@P1,@P2,@P3,@P4 ',4112,8193,@p7 output,219717,95,NULL,1,0
    select @p1, @p2, @p7
    Something noteworthy is that my sproc only has 5 input parameters, but this makes it look like it has many more.
    How do I manipulate the code enough to make it work in mgmt studio? Thanks!
    TIA, ChrisRDBA

    In profiler you would normally see RPC:Starting and RPC:Completed. The statement shown in RPC staring is what you need to pick because as Erland explained, completed would show "funky" behavior.
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • FindByPrimaryKey: Could not find prepared statement with handle 3

    I've inherited a WL61 application and been asked to make it work under WL81. We're using SQL Server 2000. We only access two tables. The XML got auto-converted during the upgrade, but I had to correct the RDBMS column names in the weblogic-cmp-jar.xml
    The application mostly works except the findByPrimaryKey fails with:
    ERROR ExecuteThread: '14' for queue: 'weblogic.kernel.Default' Administrator : TargetSessionBean - Error finding promotion with ID <2>
    javax.ejb.FinderException: Problem in findByPrimaryKey while preparing or executing statement: 'weblogic.jdbc.wrapper.PreparedStatement_weblogic_jdbc_base_BasePreparedStatement@95':
    java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 3.
    java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 3.
    at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
    at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
    I've checked the database table and the row exisits with the appropriate PK (in this case a promotion with ID <2>).
    In the WL61 version the findByPrimaryKey was explicitly defined in the weblogic-cmp-rdbms-jar.xml as follows:
    <finder>
    <method-name>findByPrimaryKey</method-name>
    <method-params>
    <method-param>com.fujitsu.ftxs.corema.server.PromotionPK</method-param>
    </method-params>
    <finder-query><![CDATA[ (= $0 promotionId) ]]></finder-query>
    <finder-expression>
    <expression-number>0</expression-number>
    <expression-text><![CDATA[@0.promotionId]]></expression-text>
    <expression-type>int</expression-type>
    </finder-expression>
    </finder
    But I understand that with WL81 I should no longer define this - it's done implicitly - so I've removed this finder definition.
    Any help appreciated. Thanks,
    - Andy Abel

    I fixed it by switching from the using the BEA driver:-
    DriverName="weblogic.jdbc.sqlserver.SQLServerDriver"
    URL="jdbc:bea:sqlserver://host:1433"
    And using the Microsoft Driver instead:-
    DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
    url=jdbc:microsoft:sqlserver://host:1433
    If anyone can explain why the Microsoft Driver works and the BEA driver does not I'd like to know.
    Thanks,
    - Andy Abel

  • Could not find prepared statement with handle 1.

    [Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 1.
    I'm getting this error message in what appear to be random ways. The first time I look at a page I might not get it, but the second time I might. I discovered that removing a cfqueryparam tag worked, but that is not really a safe solution. I checked that the cf_sql_type matched the database field, and in one case changed a cf_sql_varchar to a cf_sql_char so it would match a SQL Server nchar(10) field. But still these errors. Any ideas? I've not had any luck Googling this.
    I should add that I'm running Coldfusion 9 as a Tomcat webapp on a Linux server. The database is SQL Server 2005, I think.

    Here's the one that is breaking now:
    <cfquery name="CheckCredentials" datasource="#application.crossreg_dsn#">
                                            SELECT [name_first]+' '+[name_last] as name
                                                        ,p.[uni]
                                                        ,p.email
                                                        ,p.role_id
                                                         ,r.role_name
                                                      ,p.external_program_id
                                              FROM [CrossReg].[dbo].[People] p
                                               INNER JOIN dbo.Roles r on r.role_id = p.role_id
                                              WHERE uni = <cfqueryparam cfsqltype="cf_sql_char" value="#Session.username#">
    </cfquery>
    Session.username is being returned from a CAS authentication system. I've never had troubles with it before.

  • Prepared statement parameter order?

    We have prepared statements for insert and update where changing the order of columns in the statement gives different results.
    Problem 1:
    For an update statements setting 8 column values via preparedStatement.executeUpdate, we got the following exception containing an internal error:
    java.sql.SQLException: Interner Fehler: Daten-Array nicht zugewiesen
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.dbaccess.DBDataSetImpl._setDBItem(DBDataSetImpl.java:365)
    at oracle.jdbc.dbaccess.DBDataSetImpl._bindsRowCompleted(DBDataSetImpl.java:737)
    at oracle.jdbc.dbaccess.DBDataSetImpl.rowCompleted(DBDataSetImpl.java:1619)
    at oracle.jdbc.driver.OraclePreparedStatement.get_data_for_columns(OraclePreparedStatement.java:2343)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:362)
    All statement ? parameters where bound correctly.
    When we changed the order of the update's set-clauses and of the according setString parameters to the same order the table is created in the database, the statement works fine.
    Problem 2:
    An insert statement using a VALUES clause with not more than 10 columns works fine independent of the column order.
    But if we have a table with more than 10 columns, the insert only works if the columns in the insert statement are in the same order as the database table. Otherwise we got an IndexOutOfBoundsException - looks like a array overflow in an internal array used to sort column indexes...
    We are using Oracle 8.1.7 and JDBC 1.2 thin driver.
    Anyone else with similar problems?

    Did you try to define the Parameter name?
    Like these:
    strSQL="XXX(p_1=>?, p_2=>?,p_3=>?)"
    cstmt.setXXX(1,'v1');
    cstmt.setXXX(3,'v3');
    cstmt.setXXX(2,'v2');
    I am suprised, If you have so many parameter, how can you maintain you code if you do not define the parameter names?

  • Using once created prepared statement with different connections in Oracle

    Can I use same statement cash using different connections in Oracle
    For example I have a prepared statement p1. After its using i close connection (return it to the pool)
    Next time I want use p1 statement using another connection.
    Question : When I creat p1 in second time ,is it returned from cash or created as a new statement. And what I should do to use once prepared statement using differend connections.
    Thaks.

    As far as I know a PreparedStatement lives and dies with the Connection that created it. So, you cannot use a PreparedStatement with other Connection instances than the one that created it.
    You will have to recreate the PreparedStatement for each time you open a connection, or use the same PreparedStatement and NOT close the Connection in between. The last suggestion can be risky though, if you never close the connection...
    Jakob Jenkov
    www.jenkov.com

  • Prepared Statement with SQL 'IN' Clause

    Hi,
    I am trying to write a JDBC SQL call to a database using a prepared statement, the call looks something like:
    select *
    from table
    where field in (?, ? ,?)
    this thing is that i don't know how many 'IN' parameters are needed until runtime (they come from a List), so is there an easy way of dealing with this, I haven't been able to find any information on this problem anywhere?

    >
    Hmmm...more expensive than say doing a query on on 2 billion rows with no index?
    More expensive than doing a cross server join?
    More expensive than doing a restore?
    I knew that someone would point this out. :)
    I just tried to exaggerate the importance of cursor sharing. This is one of the most important topic in DBMS world, but quite often ignored by JAVA world. I hope that you understand my good intention.
    >
    2. Insert data corresponding to bind variable to "T". Interesting idea. Please provide the algorithm for that. The only ones I can come up with
    1. Involved creating a "dynamic" SQL for the insert
    2. Doing multiple cross network inserts.
    The first of course is exactly what you said your solution prevented. The second will be more expensive than sending a single dynamically created select.Hopefully, this is not just an "interesting" idea, but very common technique in DBMS. Actually one of the common techniques. There are couple of ways to handle this kind(variable number of bind variables in "IN" clause) of problem.
    What i commented was that the simplest one. It's like this:
    (based on Oracle)
    SQL> create global temporary table bind_temp(value int);
    PreparedStatement stmt = con.prepareStatement("INSERT INTO bid_temp VALUES(?)");
    for(...) {
         stmt.setInt(1, aValue)
         stmt.addBatch();
    stmt.executeBatch();
    Statement stmt2 = con.executeQuery("SELECT * FROM target_table WHERE id IN (bind_temp)");
    ...Doesn't it look pretty? Pretty for both Java developers and DBAs.
    By virtue of the mechanism of batch processing, the total DBMS call is just twice and you need just 2 completely sharable SQL statements.
    (Hopefully you might understand that Oracle global temporary table is just session scope and we don't need them to be stored permanently)
    Above pattern is quite beneficial than these pattern of queries.
    SELECT * FROM target_table WHERE id IN (?)
    SELECT * FROM target_table WHERE id IN (?,?)
    SELECT * FROM target_table WHERE id IN (?,?,?)
    SELECT * FROM target_table WHERE id IN (?,?,?,?,.......,?)
    If you have large quantity of above patterns of queries, you should note that there are another bunch of better techniques. I noted just one of them.
    Hope this clairfies my point.

  • Prepared Statement with "INTERVAL ? DAY" clause

    Hi,
    I am having problems when using a INTERVAL ? DAY clause in a
    preparedStatement in Oracle 8i with the classes12.zip jdbc
    driver.
    The code following code:
    String sql1 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL '10' DAY";
    String sql2 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL '?' DAY";
    String sql3 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL ? DAY";
    try {
    st = con.prepareStatement(sql1);
    ResultSet rs = st.executeQuery();
    System.out.println("1 successful");
    catch (Exception e) {
    System.err.println(e);
    try {
    st = con.prepareStatement(sql2);
    st.setInt(1, 10);
    ResultSet rs = st.executeQuery();
    System.out.println("2 successful");
    catch (Exception e) {
    System.err.println(e);
    try {
    st = con.prepareStatement(sql3);
    st.setInt(1, 10);
    ResultSet rs = st.executeQuery();
    System.out.println("3 successful");
    catch (Exception e) {
    System.err.println(e);
    produces this output:
    1 successful
    java.sql.SQLException: ORA-01036: illegal variable name/number
    java.sql.SQLException: ORA-00933: SQL command not properly ended
    Can anybody help me figuring out what's wrong with the 2nd or
    3rd prepared statement?
    Thanks
    Bernie

    Hi,
    I am having problems when using a INTERVAL ? DAY clause in a
    preparedStatement in Oracle 8i with the classes12.zip jdbc
    driver.
    The code following code:
    String sql1 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL '10' DAY";
    String sql2 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL '?' DAY";
    String sql3 =
    "select from my_table where created_ts > SYSDATE -
    INTERVAL ? DAY";
    try {
    st = con.prepareStatement(sql1);
    ResultSet rs = st.executeQuery();
    System.out.println("1 successful");
    catch (Exception e) {
    System.err.println(e);
    try {
    st = con.prepareStatement(sql2);
    st.setInt(1, 10);
    ResultSet rs = st.executeQuery();
    System.out.println("2 successful");
    catch (Exception e) {
    System.err.println(e);
    try {
    st = con.prepareStatement(sql3);
    st.setInt(1, 10);
    ResultSet rs = st.executeQuery();
    System.out.println("3 successful");
    catch (Exception e) {
    System.err.println(e);
    produces this output:
    1 successful
    java.sql.SQLException: ORA-01036: illegal variable name/number
    java.sql.SQLException: ORA-00933: SQL command not properly ended
    Can anybody help me figuring out what's wrong with the 2nd or
    3rd prepared statement?
    Thanks
    Bernie

  • Executiong prepared statement with Like% in SQL Query?

    Hi,
    We are developing GUI project.In which we need to retrieve the contract details based on the Name which we enter in eVision page.Here we will not enter the whole name,we will enter only the part of the name,for example if the actual name is Sun Seebeyond,I will enter only Su.So if there are five records in data base which starts the name with Su.Then it should return the five names..
    For this I am using the prepared statement as
    select name,contractid from table1 where name Like '?%'.
    Here my runtime input value will set to this parameter ?.When I execute this qry in my project I am getting error as "Unable to set parameters on the Object: Invalid parameter index 1".
    If I replace the ? with Su in query itself ,then it works fine..
    Please let me know is there any effective way,using which I can solve..
    Thanks,
    Renga.S.

    Hi,
    This option I already tried and it work fine too.
    I am looking for an option ,where we can handle with in the Query,so we dont need to write any code appending % into the actual valus.
    Thanks,
    Renga.S.

  • JDBC: Prepared statements with more parameters than column names

    I'm using the latest version of the JDBC driver - 4.1.5605.100_enu - on Java 1.7, Linux.
    I'm connecting to MS SQL Server 2012 Express Edition using a connection URL of the form jdbc:sqlserver://10.0.0.2;user=username;password=pwd;database=testdb1
    I have a table with two columns. One is an ID (type bigint) and one is numeric(38, 19).
    The following code works exactly as expected:
    PreparedStatement stm = connection.prepareStatement("INSERT INTO myTable(id, num) VALUES (?, ?)")
    // repeatedly set parameters using setLong, setBigDecimal, then addBatch
    stm.executeBatch()
    The following code does not work as expected:
    PreparedStatement stm = connection.prepareStatement("INSERT INTO myTable(id, num) VALUES (?, ?),  (?, ?)");
    stm.setLong(1, 1);
    stm.setBigDecimal(2, new BigDecimal("1.234"));
    stm.setLong(3, 2);
    stm.setBigDecimal(4, new BigDecimal("1.234"));
    stm.addBatch();
    stm.executeBatch();
    The code runs normally in the second case, but the second row inserted contains the wrong value in the "num" column - it's been rounded to 1.0 instead of stored as 1.234.
    I think this may be because the driver does not understand the types of parameters whose indexes are beyond the number of columns in the insert statement. Running the following code on the second prepared statement:
    System.err.println(stm.getParameterMetaData().getParameterTypeName(2)); // prints "numeric"
    System.err.println(stm.getParameterMetaData().getParameterTypeName(4)); // fails with IndexOutOfBoundsException
    As far as I can tell from the JDBC JavaDoc, this usage is valid and ought to work. Certainly it works as expected (including the parameter metadata) using PostgreSQL and their JDBC driver. Is this a bug in Microsoft's driver?

    Hi dtn-cfl,
    Thanks for your waiting.
    Based on my research(using
    SQL Server Profiler to trace DB events), the preparedStatement finally passes the below statements to SQL Server.
    stm.setLong(1, 1);
    stm.setBigDecimal(2, new BigDecimal("1.234"));
    stm.setLong(3, 2);
    stm.setNull(4, Types.DECIMAL);
    declare @p1 int
    set @p1=0
    exec sp_prepexec @p1 output,N'@P0 bigint,@P1 decimal(38,3),@P2 bigint,@P3 decimal(38,0)',N'INSERT INTO myTable(id, num) VALUES (@P0, @P1), (@P2, @P3) ',1,1.234,2,NULL
    select @p1
    Pay attention to the @P3 decimal(38,0),  it seems(I don't have access to JDBC source code so that I have to use seem) that the
    stm.setNull(4, Types.DECIMAL) will finally parsed as a type decimal(38,0). In SQL Server, to a
    decimal datatype,one with smaller scale has a higher precedence. To understand the precedence, please see below code. If you have more interest in data type precedence, you can click
    here.
    declare @num1 decimal(38,3) --scale 3
    declare @num2 decimal(38,2) --scale 2
    set @num1 = 3.225
    set @num2 = 3.22
    select @num1 as num
    union all
    select @num2
    output
    num
    3.23
    3.22
    @num1 get rounded to keep the column data type consistency, namely keep the column as type decimal(38,2)
    Let's go back to your code, if you would like to make your code work properly, please see below.
    stm.setLong(1, 1);
    stm.setBigDecimal(2, new BigDecimal("1.234"));
    stm.setLong(3, 2);
    stm.setNull(4, Types.INTEGER);As per the above data type precedence link, a decimal has a higher precedence than integer, so your decimal will not get rounded.
    Not only the case in your post, but also any data type inconsistency will lead to the rounding problem. See below.
    stm.setLong(1, 1);
    stm.setBigDecimal(2, new BigDecimal("1.234"));
    stm.setLong(3, 2);
    stm.setBigDecimal(4, new BigDecimal("1.2")); // or new BigDecimal("1.23") and any other decimal with different scale leads to rounding problem.
    So when you set parameters for a prepareStatement like "INSERT INTO myTable(id, num) VALUES (?, ?),  (?, ?)" with more than one row, you should pay attention to data type consistency fact.
    The Microsoft JDBC driver for SQL Server may not be that intelligent, however we can't say that is a bug definitely.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Performance issue doing a prepare statement with LIKE

    Hi
    I'm doing a preparestatement like this
    select foo
    from bar
    where des like ?
    and then do the prepare with the string 'foo%'
    If I do the prepare of this variable, the query is very slow. If I don't do the prepare, the query is very fast. Can anyone help me out on this? DBA's will kill me if I don't use prepare statements but users will kill be if the query is slow...
    Thank you!
    HappyGuy

    As indicated in the last reply this probably has to do with use of string literals over bound variables
    With a prepared statement the optimiser dosen't get the chance to use histograms against your data... so whilst it might be more efficent to drive off an index for some of the searches it looses access to the data (histograms) that enable it to make this decission...
    Hints are probably the way to go... if your sure that driving off a index is always going to be the most efficent...
    Using explain (inside of JDeveloper9i or turning on the autotrace functionality inside of sqlplus) will give you some idea of how Oracle would drive the query if you use a string literal
    Dom

  • Prepared Statement with IN Operator

    Hello all, do anyone know how to use IN operator in a prepared statement? For ex.,
    "select name from user where user_no in (?)"
    If I do preparedStatement.setString(1, "2, 3, 4") and execute it, it would give me an ORA-01722: invalid number exception. Any help or pointer will be appreciated. Thanks.
    yien

    You can't (easily) pass a comma-separated list to a SQL statement. If you want to pass N values straight to a PreparedStatement, you would need N bind variables, i.e.
    select name from user where user_no in (?, ?, ?)I would tend to either pass an array to a stored procedure that returned a REF CURSOR for the SELECT or create a pipelined table function that parsed the comma-separated list into a table structure.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to use INSERT INTO ALL statement in jdbc prepared statement with beans

    Kindly give me some example that how we can use "INSERT INTO ALL STATEMENT" in jdbc prepared statement inside a jsf bean?
    Actually i want to take employee id's of present employees using single jsf page and using one textbox for each employee id.
    How can i use INSERT INTO ALL statement to achieve this?
    Following is my code snippet.
    AttendanceBean.java:
    public class AttendanceBean {
    private int atteid;
    private String attdname;
    private int attday;
    private int attmonth;
    private int attyear;
    public static Connection getAttConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:globldb3";
    String username = "scott";
    String password = "tiger";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
    public String addAttendance(){
    Connection conn = null;
    PreparedStatement pstmt = null;
    boolean committed = false;
    try {
    conn = getAttConnection();
    conn.setAutoCommit(false);
    String query = "INSERT ALL INTO attendance VALUES (?,?,?,?,?)";
    pstmt = conn.prepareStatement(query);
    pstmt.setInt(1,this.atteid);
    pstmt.setString(2,this.attdname);
    pstmt.setInt(3,this.attday);
    pstmt.setInt(4,this.attmonth);
    pstmt.setInt(5,this.attyear);
    pstmt.executeUpdate();
    conn.commit();
    conn.setAutoCommit(true);
    committed = true;
    return "home.xhtml";
    } catch (Exception e) {
    e.printStackTrace();
    return "CRM.xhtml";
    } finally {
    try{
    if (!committed) conn.rollback();
    if (pstmt != null) pstmt.close();
    if (conn != null) conn.close();
    }catch(Exception e){
    e.printStackTrace();
    }

    Check this program for some info on Push buttons:
    1-DEMO_DYNPRO_PUSH_BUTTON
    2-DEMO_DYNPRO_MODULE
    3-DEMO_DYNPRO_ON_CONDITION
    Suppose Your screen is 101
    Then in that screen create one push button and assign it a function code.
    Now in the PAI of the 101 screen
    Create Module for user command
    Inside that module checc the sy-ucomm if sy-ucomm eq <Function code of your push button>
    Insert the values in database.
    *& Module USER_COMMAND_0101 INPUT
    process after input for screen 0101 *
    MODULE USER_COMMAND_0101 INPUT.
    CASE OK_CODE.
    WHEN 'SAVE'.
    *Insert the values here
    WHEN 'DISP'.
    ENDCASE.
    CLEAR OK_CODE.
    ENDMODULE. " USER_COMMAND_0101 INPUT
    Regards
    Neha
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:02 AM
    Edited by: Neha Shukla on Dec 3, 2008 1:06 AM

  • Best Practice: Combine prepared statements with ;

    Hi,
    I would like to know what the best prctice is for combining prepared statements to give the query below
    INSERT INTO my_table (value) VALUES (?); SELECT LAST_INSERT_ID()The reason for this is that i have written a simple DB wrapper to handle my database connections and queries based on a property file containing sql strings. I would prefer not to change this wrapper code, but be able to specify combined queries in the sql string if possible.
    Thanks in advance

    Have you thought about using Batch statements ?

Maybe you are looking for