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...

Similar Messages

  • The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    The calender on my iPhone 4 with iOS 6 no longer syncs with iCal 4.0.4 on my mac OS 10.6.8. However it is syncing with my iCloud account. Can someone help me with this?

    FYI: It seems it was a network problem with my WinXP PC. After complete deletion and new installation of XP and iTunes my iPhone will be recognized correctly, Wifi synchronization works (mostly) fine.

  • HT5655 I followed all the instructions to update Flash Player, but the installation fails at around 90%, it says that there is an Application running (Safari) bit I actually close all Apps. already. can someone help me with this issue ?? Thanks

    I have followed the instructions to update Flash Player, the Installation Fails at about 90%, it says that there is an Application running (Safari) and it says to close all the apps. and start again ... but I already close all the Applications ... none is running ... can someone help me with this issue ??? Thanks ...

    Dear Dominic
    Brilliant reply. Simple English. Simple to follow instructions. And it worked immediately, first time.
    Why couldn't the Apple and Adobe corporations get their programming right first time? We spend billions of UK pounds and US dollars with them. They reply with incompetent programming such as this, and arrogance to their customers in issuing faulty systems without doing the most rudimentary checks.
    Anyway, I certainly shan't be buying another Apple as this is the most unreliable, most incomprehensible, most illogical and downright thoughtless shoddy piece of computer kit which I have ever owned. And all of it is rubbish ~ emails disappear, photos can't be organised properly, spreadsheets don't work, Pages is laborious… the list goes on and on...
    But thanks to you Dominic, I have been able to load Adoble Flashj… maybe eyou should get  a job at Apple, and set them all on the right course to how to work simply and correctly with customers.
    Thanks again,
    David

  • My ipod touch 1st gen has gone into recovery and wont restore because of a error 1 or something like that can someone help me quick this ipod is my little cousins and i dont want her mum to find out what happend

    my ipod touch 1st gen has gone into recovery and wont restore because of a error 1 or something like that can someone help me quick this ipod is my little cousins and i dont want her mum to find out what happend

    I have not seen a solution for error (1)
    make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar

  • Some of my photos in iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    Some of my photos in Iphoto turn blank (white) when I tried to edit the size like zoon in and out.Can someone help me on this?

    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • So i have an apple ipod touch 1st generation and it is not charging! It shows the charging sign but its taking a really long time to charge. Ive had it charging for at least 3 hours and it still says under 20% so can someone help me figure this out??

    So i have an apple ipod touch 1st generation and it is not charging! It shows the charging sign but its taking a really long time to charge. Ive had it charging for at least 3 hours and it still says under 20% so can someone help me figure this out??

    Not Charge
    - See:      
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar 

  • I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    I have iOS 7. When I go to the itunes store on my ipod touch it gives me a blank screen with nothing on it. I restarted my ipod touch and it didn't work. Can someone help me with this?

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Go to Settings>iTunes and App stores and sign out and sign back in
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.      

  • I'm trying to clean up my mailbox and when I delete an item(s) I get a message that say's "operation could not be completed- file exists. Further, when I do this one message is copied (not deleted) to the trash folder. Can someone help me through this?

    I'm trying to clean my mailbox and when I click on delete or highlight and move to trash I get a message that says "operation could not be completed - file exists. Further, when I select a message or group of messages, one of them is copied (not deleted) to the trash folder. Can someone help me through this?
    Thanks.

    It's a POP account. I decided to clean up my mailbox today after noticing the computer was real slow after USA Today started sending their daily top stories with new graphics. Also before I noticed the problem with mail deletion - two things happened. 1) I updated security sofware as prompted by Apple and 2) downloaded Mackeeper and went throught some preliminary scans but did not buy their package. Thanks forn nstaying with me.

  • I'm having issues loading Youtube on my MacBook Pro for about a week now.  I'm not sure if this is because of my computer or internet but my sister's PC loads Youtube completely fine.  Can someone help me figure this out?

    I'm having issues loading Youtube on my MacBook Pro for about a week now.  I'm not sure if this is because of my computer or internet but my sister's PC loads Youtube completely fine.  Can someone help me figure this out?

    Hi, I had been having the same problem for over a week, but both my window's HP and my 2011 macbook pro barely could load youtube.  What kind of router you have?  I was using a belkin play router that was only 8 months old, switched to a new AirPort Extreme Base Station and now everything works perfect.

  • TS1292 i have a spanish gift card that won't work with my canadian account. can someone help me solve this

    i found an old gift card that i got with my ipod from spain
    i have a canadian account. when i tried using the gift card it said i couldn't use the spanish gift card with my canadian account. can someone help me solve this problem
    the gift card is 15 euros

    Sorry, but you cannot use that card with a Canadian iTunes Store account. A gift card is valid only in the country of purchase. You'll need to give or sell that card to someone in Spain.
    Regards.

  • I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    I have a problem with my blackberry 9360, I bought it last 2months, and now when I use video camera or camera I saw a red and blue line. Can someone help me with this issue?

    Hello zukafu, 
    Welcome to the forums. 
    In this case we can try to reload the software on the BlackBerry® smartphone to make sure it is running the latest version and there are no issues with the OS.
    Here is how to backup your BlackBerry smartphone http://bbry.lv/oPVWXc
    Once you have backed up your BlackBerry smartphone please follow the link below to complete a clean reload of the BlackBerry smartphone software.
    Link: http://www.blackberry.com/btsc/KB03621
    Once completed test it and proceed with a selective restore, here is how to restore http://bbry.lv/qgQxLo
    Thank you
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • HT4203 I have turned off the Data use on the I-phone 4s but am told by AT&T that data is still being used for applications.  How is this possible. Can someone help me understand this.  Thanks.

    I have turned off the Data use on the I-phone 4s but am told by AT&T that data is still being used for applications.  How is this possible. Can someone help me understand this. 

    I assume you are including the STIX font as part of your epub files?     
    Perhaps the folks who do this blog might be able to help -- they have done some work with font embedding:
    http://www.pigsgourdsandwikis.com/2011/04/embedding-fonts-in-epub-ipad-iphone-an d.html

  • After the OS 6 update my speaker does not work. My music plays but no sound comes out. Can someone help me with this issue? I currently have the 4S.

    After the OS 6 update my speaker does not work. Volume control on the side does not adjust the volume either. My music plays but no sound comes out. Can someone help me with this issue? I've tried rebooting my phone but still no sound comes out. I currently have the 4S.

    try to activate and desactivate the airplne switch a couple of time

  • Can someone help me with this powerpoint viewer with director issue?

    I have 'inherieted' an interactive CD that was built using director mx2004.  I get presentations from different people and put them on a CD to hand out at the end of a seminar. For the Power Point presentations I have director use the powerpoint viewer just in case someone does not have PowerPoint on there machine.  This works fine, but I have been getting people that are using PowerPoint 2007 which uses a different extension (pptx instead of ppt).  I also have word documents, adobe pdf, ect.  Here is the code that handles how to open up the files, whether using PPT viewer or the default program. wasn't sure if you needed all of this or not.
    --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
    on mouseUp me
      --if button 1-5 has been clicked
      if(_global.btnNum = 0 or _global.btnNum = 1 or _global.btnNum = 2 or _global.btnNum = 3 or _global.btnNum = 4 ) then
        --assign selected file to a variable
        selectedFile = sprite("listBox").selectedItem.data
        --path of the file that is selected
        filePath = "workshops\days\day" & _global.btnNum & "\" & selectedFile
        --find out the type of file
        fileExt = selectedFile.char[(selectedFile.length-2)..selectedFile.length]
      end if
      --if file is classified secret and not provided on this disc (must have "*" at data end)
      if(selectedFile.char[selectedFile.length] = "*") then
        --set file to placeholder.ppt (since it has an * at data end)
        filePath = "workshops\placeholder.ppt"
        --set file extension to ppt (since it has an * at data end)
        fileExt = "ppt"
      end if
      if(fileExt = "ppt")  then
        --opens file in powerpointviewer
        _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
        else
        --opens file in the default program on that computer
        _player.open(filePath, "launchers\PLAY.EXE")
      end if
    end
    I have been trying to get the pptx files to also open in the viewer.  I have been able to do this, but the problem is it wants to try to open everything in viewer.
    Here is what I have tried:
    1- This wants to open everything in PPT viewer.  Not sure why.
    if(fileExt = "ppt" or "pptx")  then
         --opens file in powerpointviewer
         _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
         else
         --opens file in the default program on that computer
         _player.open(filePath, "launchers\PLAY.EXE")
       end if
    end
    2-This will just open the 'pptx' file in Power Point.  I am sure I am using the 2007 version of PPT viewer in director.
    if(fileExt = "ppt")  then
        --opens file in powerpointviewer
        _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
      else if(fileExt = "pptx") then
        --opens file in powerpointviewer
      _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
      else
        --opens file in the default program on that computer
        _player.open(filePath, "launchers\PLAY.EXE")
      end if
    end
    I am not sure where to go from here.  Can someone help me?  Have not been using director for very long.
    Thanks

    It's unclear what exactly is the problem: is it managing to distinguish and open PowerPoint 2007 (*.pptx) files, or is it that every file tries to run in PPTView.exe?
    Part of your problem might be that .pptx is 4 characters long, while .ppt is only 3, and the code dealing with the file extension:
    fileExt = selectedFile.char[(selectedFile.length-2)..selectedFile.length]
    will only grab the last 3 characters regardless of where the "." is.
    Create a new #movie script member (press Ctrl + Shift + U and then hit the + button - "New Cast Member" - at the top-left of the script window that opens). Set the script syntax to JavaScript by altering the drop-down just below the + button and paste in the following:
    function jsGetExtension(fName){
      if(typeof(fName)!="string") return "";
      return fName.split(".").pop();
    Then use the following modification to your original script:
    global btnNum
    --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
    on mouseUp me
      --if button 1-5 has been clicked
      case btnNum of
        0, 1, 2, 3, 4:
          --assign selected file to a variable
          selectedFile = sprite("listBox").selectedItem.data
          --path of the file that is selected
          filePath = "workshops\days\day" & btnNum & "\" & selectedFile
          --find out the type of file
          fileExt = jsGetExtension(selectedFile)
      end case
      --if file is classified secret and not provided on this disc (must have "*" at data end)
      if (selectedFile.char[selectedFile.length] = "*") then
        --set file to placeholder.ppt (since it has an * at data end)
        filePath = "workshops\placeholder.ppt"
        --set file extension to ppt (since it has an * at data end)
        fileExt = "ppt"
      end if
      case fileExt of
        "ppt", "pptx":
          --opens file in powerpointviewer
          _player.open(filePath & " /S", "launchers\PPTVIEW.EXE")
        otherwise:
          --opens file in the default program on that computer
          _player.open(filePath, "launchers\PLAY.EXE")
      end case
    end
    However, I'm nervous that you aren't supplying the full path to files and executables. I don't know where the movie file that contains this code is relative to the folder "launchers\" or "workshops\" put I suggest you prepend the movie's full path (or the application's full path) like so:
    global btnNum
    --RUNS WHEN MAIN OPEN BUTTON IS PRESSED--
    on mouseUp me
      mPath = _movie.path -- OR _player.applicationPath
      --if button 1-5 has been clicked
      case btnNum of
        0, 1, 2, 3, 4:
          --assign selected file to a variable
          selectedFile = sprite("listBox").selectedItem.data
          --path of the file that is selected
          filePath = mPath & "workshops\days\day" & btnNum & "\" & selectedFile
          --find out the type of file
          fileExt = jsGetExtension(selectedFile)
      end case
      --if file is classified secret and not provided on this disc (must have "*" at data end)
      if (selectedFile.char[selectedFile.length] = "*") then
        --set file to placeholder.ppt (since it has an * at data end)
        filePath = mPath & "workshops\placeholder.ppt"
        --set file extension to ppt (since it has an * at data end)
        fileExt = "ppt"
      end if
      case fileExt of
        "ppt", "pptx":
          --opens file in powerpointviewer
          _player.open(filePath & " /S", mPath & "launchers\PPTVIEW.EXE")
        otherwise:
          --opens file in the default program on that computer
          _player.open(filePath, mPath & "launchers\PLAY.EXE")
      end case
    end

  • Can someone help me with this 201435 Error during Signal Express signal generating?

    I built this signal generation tast to generate a voltage waveform. The wave form is loaded from a lvm file. (as shown in attachment pic). The waveform can be correctly viewed in preview window, so i suppose nothing wrong with the file. but when i clkick the run button, error 201435 pops up, tell me "no samples provided to DAQmx Write to initialize buffered generation".
    i dont know what step do i missed in this task. can anyone help me with this problem?

    the attachment picture
    Attachments:
    task.PNG ‏9 KB

Maybe you are looking for

  • Password for installing softwre

    Ok, had this mac pro for around 2 weeks...set the password for myself when I got it...every program I installed asked for a password to install, no biggie, today, I go to install flip wmv and it asked for my password, typed it in and....will not acce

  • Problem with Page header width when column is hidded

    Hi All, am using SSRS-2008 R2 version. i had an issue width Page header width when am hiding column. Please find the below screen shoot for reference. Here , there is an audit parameter which contains a and b values respectively. If Audit= a then i n

  • Flash CS4 starts loosing my workspace settings over and over again.

    Recently my Flash CS4 keeps loosing my custom workspace settings. After last time i have even "created new" workspace, named and saved it. Now there is no trace of it anywhere and im looking at the default ones... This pisses me off like hell. Im on

  • Help! Nothing works...

    i have had my ipod nano for a week. i had it on charger and it finished charging. then all of a sudden while updating it came up with the funny little battery sign with the lightining bolt on the left? and it still has the do not disconnect sign. als

  • How would I suggest apple on function "FIND MY IPHONE"?

    I think this is a very useful function BUT It is too easy to turn this function OFF if there are anyone pick my iPhone up and know how to use the iOS 4.2 So, they just go to setting>mail&calendar>mobile me>find my iPhone>OFF See? I mean if anyone wou