Double sql statements in JSP..HELP...

When I use this code in a single JSP file it doesn't update the database....I guess there is something wrong with this....There is no error but in JSP but It doesn't update....Need help guys....
String SQLStatement = "select * from test, test1";
String SQLStatement1= "update test
set total_shares=total_shares - sTotal
where stock_code=Scode AND name_broker=Sbroker";
I get the Scode and Sbroker from the other table so I used the SELECT first...

String SQLStatement1= "update test
set total_shares=total_shares - sTotal
where stock_code=Scode AND name_broker=Sbroker";What are Scode and Sbroker ? Are they String datatypes? If yes, you can't be putting them as is within quotes. Please give the complete code.

Similar Messages

  • Inserting your own sql-statements in JSP

    How do I use my own sql-statements in JSP combined with the ones
    generated by JDeveloper?
    It seems to me that the following sentences are the ones
    generating the sql for inserting in a database:
    <jbo:DataSource id="ds" appid="MimPKG.MimPKGModule"
    viewobject="BidragView"/>
    <jbo:Row id="newRow" datasource="ds" action="Create">
    <jbo:SetAttribute dataitem="*"/>
    </jbo:Row>
    I would like to have more control and therefore I need to make
    my own sql-statements.
    Is that possible?
    Thanks
    Leise

    You can use ExecuteSQL data tag to do so. It allows you to
    include your own query like insert, update etc.

  • Odd results from SQL statement in JSP

    Hi.
    Getting very strange results from my SQL statement housed in my JSP.
    the last part of it is like so:
    "SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME, ..." +
    "REQUESTOR_EMAIL" +
    " FROM CHANGE_CONTROL_ADMIN a INNER JOIN CHANGE_CONTROL_USER b " +
    "ON a.CHANGE_CTRL_ID = b.CHANGE_CTRL_ID " +
      " WHERE UPPER(REQUESTOR_NAME) LIKE ? ";   I've set the following variables and statements:
    String reqName = request.getParameter("requestor_name");
    PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
    prepstmt.setString(1, "%" + reqName.trim().toUpperCase() + "%");
    ResultSet rslts = prepstmt.executeQuery();
    rslts.next();
    int aidn = rslts.getInt(1);          
    int actbox = rslts.getInt(2);     String reqname = rslts.getString(3).toUpperCase();
    String reqemails = rslts.getString(4);
    String bizct = rslts.getString(5);
    String dept = rslts.getString(6);
    String loc = rslts.getString(7);
    Date datereq = rslts.getDate(8);
    String busvp = rslts.getString(9);
    AND SO ONSo then I loop it, or try to with the following:
    <%
      try {
      while ((rslts).next()) { %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    rslts.close();
    selstmt.close();
    catch(Exception ex){
         ex.printStackTrace();
         log("Exception", ex);
    %>AND so on, setting 13 getXXX methods of the 16 cols in the SQL statement.
    Trouble is I'm getting wildly inconsistent results.
    For example, typing 'H' (w/o quotes) will spit out 20 duplicate records of a guy named Herman, with the rest of his corresponding info correct, just repeated for some reason.
    Typing in 'He' will bring back the record twice (2 rows of the complete result set being queried).
    However, typing in 'Her' returns nothing. I could type in 'ell' (last 3 letters of his name, Winchell) and it will again return two duplicate records, but typing in 'hell' would return nothing.
    Am I omitting something crucial from the while statement that's needed to accurately print out the results set without duplicating it and that will ensure returning it?
    There's also records in the DB that I know are there but aren't being returned. Different names (i.e. Jennifer, Jesse, Jeremy) won't be returned by typing in partial name strings like Je.
    Any insight would be largely appreciated.
    One sidenote: I can go to SQL Plus and accurately return a results set through the above query. Having said that, is it possible the JDBC driver has some kind of issue?
    Message was edited by:
    bpropes20
    Message was edited by:
    bpropes20

    Am I omitting something crucial from the while
    statement that's needed to accurately print out the
    results set without duplicating it and that will
    ensure returning it?Yes.
    In this code, nothing ever changes the value of reqname or any of the other variables.
      while ((rslts).next()) { %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    } You code needs to be like this:while (rslts.next()) {
      reqname = rslts.getString(3).toUpperCase();
      reqemails = rslts.getString(4);
      bizct = rslts.getString(5);
      dept = rslts.getString(6);
      loc = rslts.getString(7);
      datereq = rslts.getDate(8);
      busvp = rslts.getString(9);
    %>
      <tr class="style17">
        <td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
       <td><%=aidn %></td>
      </tr>
      <%
    There's also records in the DB that I know are there
    but aren't being returned. Different names (i.e.
    Jennifer, Jesse, Jeremy) won't be returned by typing
    in partial name strings like Je.Well, you're half-right, your loop won't display all the rows in the result set, because you call rslts.next(); once immediately after executing the query. That advance the result set to the first row; when the loop is entered, it starts displaying at the 2nd row (or later if there are more next() calls in the code you omitted).

  • Problems with SQL statement ..Urgent Help required

    Hi
    I have a table with something like this
    ::: inidicates column seperation
    col1 ::: col2 ::: col3 ::: col4
    ab,abc,abvfg,fghy ::: x1 ::: y1 ::: z1
    ba,mkl,huji,kill ::: x2 ::: y2 ::: z2
    I want to get something like this :
    col1 ::: col2 ::: col3 ::: col4
    ab ::: x1 ::: y1 ::: z1
    abc ::: x1 ::: y1 ::: z1
    abvfg ::: x1 ::: y1 ::: z1
    fghy ::: x1 ::: y1 ::: z1
    and so on......
    Either a procedure or a single sql statement is fine..
    PS: the first column can have any number of words separated with comma (,)
    Please advise
    Thanks in advance

    create table kris (
    a varchar2(200),
    b varchar2(20),
    c varchar2(20),
    d varchar2(20));
    insert into kris values('ab,abc,abvfg,fghy', 'x1','y1','z1');
    insert into kris values('ba,mkl,huji,kill', 'x2','y2','z2');
    select substr(','||a||',', instr(','||a||',', ',', 1, rn) +1,
         instr(','||a||',', ',', 1, rn+1) - instr(','||a||',', ',', 1, rn) -1)
         v,b,c,d
    from (select length(a) - length(translate(a, '1,', '1')) +1 L,
         a, b, c, d from kris) t, (select rownum rn from cat) c
         where c.rn <= t.L
    order by a, rn;
    V B C D
    ab x1 y1 z1
    abc x1 y1 z1
    abvfg x1 y1 z1
    fghy x1 y1 z1
    ba x2 y2 z2
    mkl x2 y2 z2
    huji x2 y2 z2
    kill x2 y2 z2

  • Can you use nested sql statements in jsp??

    HI, I was wondering if you can use nexted sql statements...
    example...
    <%@ page language="java" contentType="text/html" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="forum.DataAccess" %>
    <%
         // Create a new instance of the DataAccess Class
              DataAccess d = new DataAccess();
         // This call the database connection method from the DataAccess Class
              d.ConnectDatabase();
         /* This gets the threads from database for the categories */
              // This is initilzing the variables
                   String threadname = null;
                   int threadid = 0;
              // This sets the sql variable to nothing
                   String sql = "";
                   String sql1 = "";
              // This sets the rs variable to null
                   ResultSet rs = null;
                   ResultSet rs1 = null;
              // This is doing a SELECT on the thread table based on the category id
                   sql += "select * from forum_threads where ft_catid = 2";
                   rs = d.SQLQuery(sql);
         /* End of categories */
         while (rs.next()){
                                       threadid = rs.getInt("ft_threadid");
                                       threadname = rs.getString("ft_threadname");
         sql1 += "select * from forum_messages where fm_catid = 2 and fm_threadid = " + threadid + "";
         rs1 = d.SQLQuery(sql1);
    %>
    THis is the error I get.....
    javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
    I know what that is.. it is because I am trying to open another result set before the first one is closed... but I need that one open cause I need to loop through the ids and run it against the second query??
    Any suggestions...

    I am not positive but it seems from your error message you will not be able to use the nested SQL. Another option would be to store the values of the ResultSet in a Vector (or Array), and then close your ResultSet and loop through the vector or array instead...
    Zac

  • Small problem: SQL statement in JSP

    Hello, I have the following problem: I have an SQL-expression like this:
    SELECT * FROM tablename WHERE ...
    In the WHERE clausule I have to refer to a variable, like this:
    String varname = "abcde"
    "SELECT * FROM tablename WHERE attribute = varname";
    This doesn't work, also when I put the " before the referral to varname. In that way I get an error that there is a semicolon expected...
    Can anybody help me with this ??
    Thanx, Erik.

    String varname = "abcde";
    "SELECT * FROM tablename WHERE attribute = ' "+ varname + " ' ";
    Since u are passing a string value from outside it needs to be enclosed in single coats....use the select statement like shown above it will work....

  • SQL Statement error - Kindly help!

    Been scratchin my head but still can't figure why it's failing ..Trying to populate the space usage for the relevant tablespaces: Get the below error. Kindly advice?
    column free_space_mb format 9999999.999
    column allocated_mb format 9999999.999
    column used_mb format 9999999.999
    column tablespace format a12
    column filename format a20
    select ts.name tablespace, trim(substr(df.name, 1,100)) filename,
    df.bytes/1024/1024 allocated_mb,
    ((df.bytes/1024/1024) - nvl(sum(dfs.bytes)/1024/1024,0)) used_mb,
    nvl(sum(dfs.bytes)/1024/1024,0) free_space_mb
    from v$datafile df left outer join dba_free_space dfs
    on df.file# = dfs.file_id join v$tablespace ts
    on df.ts# = ts.ts#
    on df.name# = ts.name#
    and ts.name='DATA_TS'
    or ts.name='INDEX_TS'
    or ts.name='LOB_TS'
    group by ts.name, df.name, dfs.file_id, df.file#, df.bytes
    order by filename;
    ERROR at line 8:
    ORA-00933: SQL command not properly ended

    Hi,
    user568296 wrote:
    select ts.name tablespace, trim(substr(df.name, 1,100)) filename,
    df.bytes/1024/1024 allocated_mb,
    ((df.bytes/1024/1024) - nvl(sum(dfs.bytes)/1024/1024,0)) used_mb,
    nvl(sum(dfs.bytes)/1024/1024,0) free_space_mb
    from v$datafile df left outer join dba_free_space dfs
    on df.file# = dfs.file_id join v$tablespace ts
    on df.ts# = ts.ts#
    on df.name# = ts.name#
    and ts.name='DATA_TS'
    or ts.name='INDEX_TS'
    or ts.name='LOB_TS'
    group by ts.name, df.name, dfs.file_id, df.file#, df.bytes
    order by filename;
    ERROR at line 8:
    ORA-00933: SQL command not properly endedOn line 8 there is a 2nd ON clause for the same join. "AND" in place of "ON" would make syntaic sense, but filenames in v$datafile are usually superstrings of tablespace names in v$ablespace. That is, if ts.name (no # at the end) is 'DATA_TS', then df.name might be 'D:\ORACLE\ORADATA\DEVELOPMENT\DATA_TS01.DBF'.
    I don't think you need that condition at all. Try:
    select    ts.name                    tablespace,
           trim (substr (df.name, 1, 100))      filename,
           df.bytes/1024/1024                    allocated_mb,
           ( ( df.bytes / 1024 / 1024)
           - nvl ( sum (dfs.bytes) / 1024 / 1024
                  , 0
           )                         used_mb,
           nvl ( sum (dfs.bytes) / 1024 / 1024
               , 0
               )                         free_space_mb
    from                     v$datafile          df
    left outer join      dba_free_space          dfs     on     df.file#     = dfs.file_id
    join                   v$tablespace          ts     on     df.ts#          = ts.ts#
    --                                   AND     df.name          = ts.name     -- AND, not ON
                                       and     ts.name          IN ( 'DATA_TS'
                                                         , 'INDEX_TS'
                                                         , 'LOB_TS'
    group by  ts.name,
                 df.name,
           dfs.file_id,
           df.file#,
           df.bytes
    order by  filename;It's a bad idea to mix AND and OR at the same level in the same query. In this case, you can use the IN operator to avoid the need for OR. In other situations, use parentheses to isolate the ANDs from the ORs.

  • How to create a database using a SQL statement? Please help.

    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.25:1521:mydb","system","12345678");
    but mydb database does not exist.
    I want to make a connection to oracle server without database name.
    How can I do?

    Colleauge, what is the purpose of making a connection to a non-existent database.
    connections are made to the database to retrieve some data or put some data.
    for which the database should exists.
    so please create the mydb database first using Database Configuration Assistant (DBCA) which is much easier as it is GUI based rather than doing it with sql scripts.

  • How do I concatenate a SQL statement in JSP?

    why I'm getting compilation error from the following?
    <% String QueryAdd = "insert into SOIAdminUsers (PI,Name,Password,Admin) values (" %>
    <%= fPI %>
    <% + ", " %> <%= fName %>
    <% + ", " %> <%= fPassword %>
    <% + ", " %> <%= fAdmin %> <%"; %>
    thanks in advance.

    <%
    String QueryAdd = "insert into SOIAdminUsers (PI,Name,Password,Admin) values (" + fPI + " , " + fName + ", " + fPassword + "," + fAddmin + ")" ;
    %>

  • SQL problem with JSP

    In sql statements with JSP. Heres the deal:
    Access database:
    Tablename: EVENT
    FieldName: event_id
    DataType: Number
    I want to compare the event_id to an integer variable called "var" in a WHERE clause in an SQL statement through a JSP.
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = 'var' ";
    It says "Data type mismatch in criteria expression."
    Any Suggestions? I thought this should be straight forward! am i missing something?

    if i am reading correctly "var" is an int variable correct? If this is the case then the following will work;
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = " + Interger.toString(var) ;
    Hope that helps ( and i hope i read your problem correctly)

  • How to use presentaion variable in the SQL statement

    Is there any special syntax to use a presentation variable in the SQL Statement?
    I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
    If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
    And this works fine but when i convert this to SQL, it returns
    "Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
    And this does not work.It is not being set to the value in the prompt.
    I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. Thanks

    Try this: '@{Fscl_Qtr_Var}'

  • Pass parameter to sql statement in query manager

    Hai to all,
               I want to pass the percentage  as the parameter into the sql statemnet.i what to execute it in the query manager.
              If i execute that statement then cann't found the tablename error is coming.
             Other than the data in the table (general data)  pass to the parameter in the sql at runtime.
    for example:
    select [%0] *100
    how to pass 10 to that sql statement.
    Please help me...
    Regards,
    Raji.

    Hi Ramya,
    You can create a SP with parameters to accept and then execut this SP from SAP Business One Query Manager by passing the parameter (in your case 10). The result will be as desired.
    Ex:
    Create this Procedure in SQL Management Studio
    create proc Test(@a as int)
    as
    begin
    select (@a*100)
    end
    To Execute the Query use this Query and pass the desired values with parameters
    execute Test 10
    Regards,
    Reno

  • Update record using SQL statement

    I have VB6.0 and Oracle 10G Express Edition in Windows 2000 Server. My procedure in VB 6.0 can't update record in the table using SQL statement, and the Error Message is " Missing SET keyword ".
    The SQL statement in VB6.0 look like this :
    General Declaration
    Dim conn as New ADODB.Connection
    Dim rs as New ADODB.Recordset
    Private Sub Command1_Click()
    dim sql as string
    sql = " UPDATE my_table " & _
    " SET Name = ' " & Text3.Text & " ' " & _
    " AND Unit = ' " & Text2.Text & " ' " & _
    " WHERE ID = ' " & Text1.Text & " ' "
    conn.Execute (sql)
    Private Sub Form Load()
    Set conn = New ADODB.Connection
    conn.Open "Provider=MSDASQL;" & "Data Source=my_table;"& "User ID =marketing;" & "Password=pass123;"
    I'm sorry about my language.
    What's wrong in my SQL statement, I need help ........ asap
    Best Regards,
    /Harso Adjie

    The syntax should be
    UPDATE TABLE XX
    SET FLD_1 = 'xxxx',
    FLD_2 = 'YYYY'
    WHERE ...
    'AND' is improperly placed in the SET.

  • Single select query or any sql statement with o/p

    Hi,
    I have one table test_tab with column names empno,empname.The test_tab values is as follows,
    empno empname
    01 siva
    02 ram
    03 kamal
    04 sathish
    i will give the empname values like 'siva,kamal,roshan,sathish' and empno >03,but in the table roshan name is not there.I need the below mentioned o/p
    example qry: select empno,empname from test_tab where empname in('siva','kamal','roshan','sathish') and empno>03;
    my o/p should be like this,
    empname empno
    sathish 04
    roshan ''
    But the empname 'roshan' is not there in table.I need the empname as 'roshan' and empno is null value in a single select query or subquery or any sql statements.
    Please help me the resolve this issue.
    Thanks
    Sivaraman

    Hi,
    Do you want this?
    with data as
    (select 1 EMPNO, 'siva' as empname from  DUAL union all
    select 2 EMPNO, 'ram' from  DUAL union all
    select 3 EMPNO, 'kamal' from  DUAL union all
    select 4 EMPNO, 'sathish' from  DUAL union all
    select null EMPNO, 'roshan' from  DUAL )
    select *  from data
    where EMPNAME in ('siva','kamal','roshan','sathish')
       and nvl2(empno,empno,4) > 3 

  • Can someone help me correct this sql statement in a jsp page?

    ive been getting the java.sql.SQLException: Incorrect syntax error for one of my sql nested statements. i cant seem to find similar egs online, so reckon if anyone here could help, really appreciate it.
    as im putting the nested sql in jsp page, it has to be with lots of " " n crap. very confusing if there are nested.
    heres the sql statement without those "" that i want to use:
    select top 5 * from(
    select top+"'"+offset+"'"+" * from prod where cat=" +"'" cat "'"+"
    )order by prodID desc
    when i put this in my jsp pg, i had to add "" to become:
    String sql = "select top 5 * from("+"select top"+"'"+offset+"'"+" * from prod where cat=" +"'" +cat+ "'"+")order by prodID desc";cat=" +"'" cat "'"+")order by prodID desc";
    all those "" are confusing me to no end, so i cant figure out what should be the correct syntax. the error says the syntax error is near the offset.

    If offset is, say, 10, and cat is, say, "new", then it looks like you're going to produce the SQL:
    select top 5 * from(
      select top '10' * from prod where cat='new'
    )order by prodID descThat looks exactly like incorrect syntax to me... top almost certainly can't handle a string literal as its operand... you almost certainly would want "top 10" instead of "top '10'"...
    If you use PreparedStatement, you don't have to remember what you quote and what you don't and you can have your SQL in a single static final string to boot...

Maybe you are looking for

  • Can you edit older Dreamweaver files (CS5, etc.) in Dreamweaver CC?

    I'm contemplating purchasing the CC subscription for Dreamweaver and some other products and need to know the backwards compatibility.  For instance can the Dreamweaver CC files be read and edited in older versions of Dreamweaver such as CS5?  I'd al

  • Why does iPhoto keep corrupting my images?

    For the past year, iPhoto 11 has been tremendously buggy on my early 2011 15" MacBook Pro.  It started under Lion and has continued apace under Mountain Lion.  It first started going haywire and crashing every time I tried opening it after any premat

  • Movement type 501 in MIGO doing GR for FG Product

    I am using movement type 501 in MIGO doing GR for FG Product, at that time its giving error 'no manual posting allow to GL Account' We dont want to allow any manual posting in this GL . Can be configure this Movement type like that whenever we do GR

  • [svn:bz-trunk] 11459: Reverting my previous change 11396.

    Revision: 11459 Author:   [email protected] Date:     2009-11-05 03:03:07 -0800 (Thu, 05 Nov 2009) Log Message: Reverting my previous change 11396. After further testing, realized that the perceived performance speedup through the edge server was due

  • App Updater Crashes on MacOS with Air 3.9

    We just released a new version of our desktop Air app, nothing different with any of the configuration files except for a higher version number. One of our Mac users (10.8.5) who had already updated to Air 3.9 sees the auto updater dialog and it appe