Can't think of suitable query

Hi, I have retrieved an integer in a variable 'n' using request.getParameter command. Now I want to delete first 'n' number of records from a table. What query should I write in PreparedStatement stat=con.prepareStatement(" ");

ah - see- I knew someone would come up with a better solution than my
// pseudocode here
ResultSet rs = statement.execute("SELECT * FROM yourTable");
String[] keys = new String[5];
for (int j = 0; j < 5; j++) {
    if (rs.next()) {
        keys[j] = rs.getString("primaryKey");   
for (int j = 0; j < 5; j++) {
    // preparedStatement is something like "DELETE FROM yourTable WHERE key = ?
    preparedStatement.setString(1, keys[j]);
    preparedStatement.executeUpdate();
}This is what happens when someone who only knows SELECT, INSERT, UPDATE, DELETE has to do SQL work.
Lee

Similar Messages

  • Can I put a SQL query into a bind variable and then use it to output report

    Hi,
    Can I put a SQL query into a bind variable and then use it to output report?
    I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
    select * from (:P1_TEXT);
    Do you think it is possible to do that? Any known limitations for APEX in this area?
    Thanks a lot,
    Angela

    You can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
    You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
    Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
    Tyler

  • Can't modify a Bex query, it is tied to a released transport

    Hello BW expert,
    I could not change a existing Bex query. It is always tied to a released transport.
    I have tested I can create a new BEx query and transport it to QA without errors.
    The issue is when I opened an existing query, it has a error.
    Bex transport request xxxxx is not available or not suitable.
    double click the errors, below is the details.
    No request has been set up as the standard transport request for BEx objects.
    The (set up) request 'DB2K901272' (for the package '' ) has already been released.
    The (set up) request 'DB2K901272' (for the package '' ) is not of the type 'transportable change request'.
    I have released transport 901272  before opening the query, I don’t know why this query is still tied to it.
    I tried to create a new BEx transport (DB2K901277) and opened the query again, but an error is still there.
    Third, I tried to collect all query elements for the query in the transport connection, and  put them in a standard transport, then I opened the query, but it is still tied to the same released transport.
    I never see an error like this before. Is there something we could change in the setting so the query is always in changeable mode?
    Thanks in advance!
    Jun

    Hello Vinod,
    I tried, still have the same issue. 
    I collect the query by query elment, select all the elements and the query in the transport connection, then click the the BEx transport. I see a Bex transport created, but no elements are included in the transport, it is a empty transport request. could this be the issue?
    Thank you very much!
    Jun

  • TS2446 I just got my iPad,  I have an iPod. When I go to put apps on it says my apple I'd Is disabled. I have reset the passwords. Somehow I have two id's?  I've gone into settings for apps signed out and back in with the new p.w.  I can't think of what e

    I just got my iPad,  I have an iPod. When I go to put apps on my new ipad it says my apple ID Is disabled. I have reset the passwords. Somehow I have two id's?  I've gone into settings for apps signed out and back in with the new p.w.  I can't think of what else to do to get the disabled block off.  Any ideas?? Thanks

    See this Apple document for help...
    http://support.apple.com/kb/ts2446

  • I need to connect my iPad to a projector and USB ports. What do I need to do this and where can I get the suitable fittings? I really need to have more than one USB connection port. Help

    I need to connect my iPad to a projector and have USB ports. What do I need to do this and where can I get the suitable fittings? I really need to have more than one USB connection port. Help

    You can connect via a cable or wireless using an Apple TV.
    http://ipad.about.com/od/iPad_Guide/a/How-To-Connect-Your-Ipad-To-Your-Tv.htm
    Connect an iPad to a Television or Projector
    http://www.everymac.com/systems/apple/ipad/ipad-faq/how-to-connect-ipad-to-tv-te levision-projector.html
    Connecting iPad iPhone or iPod to TV or Projector
    http://www.disabled-world.com/assistivedevices/computer/ipad-tv.php
    iPad Accessories: Connections for a TV or Projector
    http://www.dummies.com/how-to/content/ipad-accessories-connections-for-a-tv-or-p rojector.html
    You may be interested in AirPlay on the Apple TV:
    http://www.apple.com/airplay/
    Alternately, there are Apple Digital AV Adapters for hardwired connections:
    http://support.apple.com/kb/ht4108
    If your location does’t have wifi to use with the Apple TV, use a portable router.
    Portable routers http://compnetworking.about.com/od/routers/tp/travel_routers.htm
     Cheers, Tom

  • How can i display all the query items to a table?

    how can i display all the query items to a table in a jsp file?
    i always have an out of memory error..

    any body??any idea?
    is it possible thru configuration or i have to write a program by the abaper??
    Biswa

  • I have a Power PC G4 which is running on OSX 10.5.8, it has the AirPort utility but cannot connect to the internet as my iMac can, I think I might need an AirPort Card? Is that the case or do I need something different to connect to a wireless modem?

    I have a Power PC G4 which is running on OSX 10.5.8, it has the AirPort utility but cannot connect to the internet as my iMac can, I think I might need an AirPort Card? Is that the case or do I need something different to connect to a wireless modem?

    Welcome!
    Only one variant of the PowerMac G4 could use the faster Airport Extreme Card. The rest used the original Airport card that is pretty slow.
    To get fast wireless without buying more than one thing, consider this:
    http://eshop.macsales.com/item/Edimax/EW7722IN/
    It goes in an available PCI slot
    There are USB solutions also. However, all PowerMac G4 towers had only slower USB 1.1 ports, so any USB wireless adaptor can only run at about wireless 'B" speeds (slow) unless you also install a PCI USB 2.0 adaptor card. Doing that would allow a USB wireless adaptor to run at its maximum rated speed. These items working together would accomplish that:
    USB wireless "dongle:"
    Newer Technology MAXPower 802.11n/g/b USB Adapter + Plug and play direct or with extension cradle
    USB PCI adaptor:
    http://eshop.macsales.com/Search/Search.cfm?Ntk=Primary&Ns=P_Popularity%7c1&Ne=5 000&N=7069&Ntt=USB+PCI
    Each approach has its advantages. The PCI wireless card is a one-piece solution that takes up no desk space. The USB2 card+USB2 Dongle gives you more fast ports for transferring date from other external USB devices (primarily cameras and external hard drives) at hugely faster rates than can the original ports. I have a USB 2 PCI card in my G4 tower strictly for transferring images from my digital SLR camera in a timely manner.

  • RT: Remote desktop says "can't find a suitable device for drive C"

    Hello,
    there is a french post on exactly the same topic, but I can't apply the solution given there.
    My problem is the following: I have a remote desktop prepared to work as RT target. It has been checked for compatibility, the hard drive has been formatted in FAT32 format, it has been found by my host and has been assigned a static ip address. I have installed the software I need ( LabView 9.0 RT) using MAX. Now, when I try to boot it with the option "boot using software installed into the hard drive", all I get is the message
    "Can't find a suitable device for drive C"
    I have reseted the BIOS, have tried formatting the hard drive in the other format, uninstalled and reinstalled the software, tried to start the target pc without the usb stick, but nothing seems to work.
    Do you have any ideas about what is going wrong?
    Thank you,
    Samuel
    Solved!
    Go to Solution.

    So you've got a IDE (and not SATA) hard drive? That should be supported anyway.
    That would only confirm my experience... it's hard to find hardware compatible with LV RT. Before buying you cannot know if it's compatible. Once you have it the evaluation tool might tell you it's supported but still it might not work. I tried several motherboards in the last years, most of them did not work.
    Your best bet might be to use relatively old hardware.

  • Can I write a SELECT query on maintenance view?

    Hi,
    Can we write a select query on maint. view? If not what are the views on which we can write the select queries?

    hi,
    you can write select query for maintenance view, database view and projection view but not helpview as it is only intended for f4 help.
    reward if helpful
    prasanth

  • Can we rollback the update query using Transaction?

    Can we rollback the Update query by writing the update query with in the transaction, as i am implementing different update queries, sometimes I am mistakenly updating the table without where criteria, which is messing up the table. Is there anyway where
    we can write the update query within a transaction and rollback that particular update query which I am writing. I do have a backup table, but that wont be useful because we are doing lot of updates in a span of minutes. I researches about Apex Sql logs too,
    but we do not have access to download such tools. So, can anyone give me a good solution for this?

    Sure, if you use transaction like this
    begin transaction
    update 1
    update 2
    rollback transaction
    both updates will be rollbacked.
    If you want to always be sure about rows you're about to change, always first try with SELECT statement and put each individual UPDATE into separate transaction with rollback at the end, e.g.
    begin transaction
       select ... where some condition
       update . where same condition
       select ... where same condition to verify update
    rollback transaction
    If your last select showed correct info, change ROLLBACK into COMMIT and re-run that script again to perform the actual update.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Can I rewrite the following query without using Row_number() function ??!!

    Hello every one, can I rewrite the following query without using the 'ROW_NUMBER() OVER ' part.
    The query is supposed to pull out the records whose CODE is not NULL and has most
    recent date for UPDATE_DATE . The reason I wanted to do this is, When I embed this query
    in between many other queries along with JOINs, My oracle server is unable to execute. So, I thought
    its better to supplant 'ROW_NUMBER() OVER ' logic with something else and try it. .
    SELECT a.* FROM
    (SELECT b.*, ROW_NUMBER() OVER (PARTITION BY b.PIDM
    ORDER BY b.UPDATE_DATE DESC) AS Rno
    FROM
    SELECT *
    FROM SHYNCRO WHERE CODE IS NOT NULL
    )b
    )a
    WHERE a.Rno = 1

    Hi,
    You didn't write over 150 lines of code and then start testing it, did you?
    Don't.
    Take baby steps. Write as little as pssiblem test that. Debug and test again until you have something that does exactly what you want it to do.
    When you have somehting that works perfectly, take one baby step. Add a tiny amount of code, maybe 1 or 2 lines more, and test again.
    When you do get an error, or wrong results, you'll have a much better idea of where the problem is. also, you won't be building code on a flimsy foundation.
    If you need help, post the last working version and the new version with the error. Explain what you're trying to do in the new version.
    The error message indicates line 133. It looks like line 133 of your code is blank. Does your front end allow completely blank lines in the middle of a query? SQL*Plus doesn't by default; you have to say
    SET  SQLBLANKLINES  ONto have a completely blank line in SQL*Plus. (However, lines containing nothing but at commnet are always allowed.)
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as indented code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The 4 people who posted small code fragments for you to read all did this.  It would be so much easier for people to read your humongeous query if it were formatted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can't work with the Query after I save a 3.5 Query in 7.0 Query Designer

    Hello,
    my Problem is, I open a 3.5 Query in a 7.0 Query Designer. Then I save as another name. When i Open the Query
    i can't change things... WHY ? A Standart Transport is OK in RSA1, Transport, BexTransport. all ok..
    can't work with the Query after I save a 3.5 Query in 7.0 Query Designer
    Best Regadrs

    Hi,
    I cant click on it. It is grey..
    I open the 3.x Query in a 7.0 Query Designer and save as another name.. Then I try to open it with the 7.0 tool. The Query is displayed. But I cant change something...
    thnx

  • Can anybody provide the SQL query to find the files uploaded in a particular folder?

    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

    Nevin,
    Be great if we could know the version of Portal. For Rel. 1, here's the query
    select id,masterthingid from wwv_things
    where siteid = &site
    and cornerid = &corner
    &site - Content Area id
    &corner - Folder id
    if you don't know the folder id, use
    select id from wwv_corners where siteid = &site
    and name = &folder
    Hope this helps. I have run into this situation before. Usually, the culprits were
    one of the following:
    1. Junk Characters in description of item (caused due to Copy-Paste)
    2. Special Characters in the File name
    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

  • Can u write the following query without using group by clause

    select sp.sid, p.pid, p.name from product p, supp_prod sp
    where sp.pid= p.pid and
    sp.sid = ( select sid from supp_prod group by sid
    having count(*) =(select count(*) from product));
    thru this, we retrieving all the products delivered by the supplier.
    Can you write the following query without using the group by clause

      select sp.sid, p.pid, p.name
        from product p, supp_prod sp
       where sp.pid= p.pid the above query will still retrieve all the products supplied by the supplier. sub-query is not necessary.
    maybe if you can post some sample data and output will help us understand what you want to achieve.

  • Can i change table in query as per user given data

    hi master
    sir,
    can i change table in query as per user given data
    see
    select * from @variable
    i need use in lov
    please give me idea
    thankingyou
    Aamir

    You cant directly use in sql instead you can write an anonymous block and frame the query as per the input table name and then use execute immediate to execute the query.
    Something like this
    declare
    qry_table varchar2(30);
    qry_stmt varchar2(1000);
    type typ_sample is table of VARCHAR2(100) index by binary_integer;
    tab_sample typ_sample ;
    begin
    qry_table := &Table_name
    qry_stmt := 'select a from '||qry_table;
    execute immediate qry_stmt bulk collect into tab_sample ;
    end;
    Message was edited by:
    Shasi

Maybe you are looking for

  • How do i change the quality settings of my printer? the options are there but greyed out!

    how do i change the quality settings of my printer? the options are there but greyed out! ie on my old HP I could print in draft if i wanted to print a doc to read and then bin...the option/box is there but greyed out so I can't select. HELP!!!

  • CSS Popup menu export problems

    I have followed all the instructions to export css popup menus from Fireworks CS3. I can see them when I preview in browser from the launch button top right. But when I export the CSS etc. and view the files in Dreamweaver it simply doesn't make any

  • Auto page numbering trouble...

    HI, I get the same numbers on two different spreads in my document. I´ve tried putting new numbers on the master pages, but the same thing happens on the very same spreads. Please help...

  • Error 1714 & 1603 - Still causing problems despite some great posts!

    Help! Although this is not a new problem I'm posting it here again as a new thread as I have yet to find solution (and it's driving me crazy!). When attempting to install iTunes, I get the following dialogue box:- Error 1714. The older version of iTu

  • Getting crazy with new Xalan J 2 3 1!!! HELP!

    I am using the following code with new Xalan for XSL Transformations: public static String transform (Node xmlNode,Node xslNode) throws XPTOException{ StringWriter writer = new StringWriter(); TransformerFactory tFactory = TransformerFactory.newInsta