How to put apostrophes in a query

Hi,
We use JDK1.2.2 with Oracle 8. We are using JDBC with the Oracle Driver installed.
We have a list of companies in our database, some of which have an apostrophe in them. However, if someone types a company name containing an apostrophe on a company search webpage i get the error
java.sql.SQLException: ORA-00911: invalid character
So how would i query the database for a name which contains an apostrophe. The apostrophe in the database is written as ' and not any special characters etc.
What do i do?

This is nothing to do with java.
Invalid SQL
select * from atable where name='someone's'
The apostrophe is considered closing single quote, and last part (s') becomes invalid
Valid SQL
select * from atable where name='someone''s'
double apostrophes can be used within the single quote
select * from atable where name="someone's"
single apostrophe can be used within the double quote

Similar Messages

  • How to put distinct in the query

    Hi all,
    How to put distinct in the query.I checked in RPD , Distinct supported is already available. I marked the distinct check box in advance option still then i'm not getting distinct in the query.
    any idea , please help...

    In the RPD i have join between base table and view .i'm selecting 2 columns one from base table and other from view . which gives cartesian product . to avoid that i want to put distinct . I'm not using any measure . I'm taking direct columns.
    I'm getting distinct keyword if i'm accessing the report directly . but when i'm accessing it from dashboard in the back end while preparing the query it's writing distinct but the actual query which is sending to db does not have distinct.
    ==================================================
    RqList distinct
    VW_SCNR_114000074_TA_DATA.Match Identifier as c1 GB,
    VW_SCNR_114000074_TA_DATA.Tot Trans Amt as c2 GB,
    VW_SCNR_114000074_TA_DATA.Tot Trans Ct as c3 GB,
    case when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '1' then 'Productive' when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '2' then 'Non Productive' else 'Indeterminate' end as c4 GB,
    VW_SCNR_114000074_TA_DATA.Batch Identifier as c5 GB
    DetailFilter: Alert TA Data.Run Id > 0 and Alert Scenarios.Scenario Name = 'ScnroName' and Alert TA Data.Batch Id > 0
    OrderBy: c4 desc
    =================================================
    -------------------- Sending query to database named KYC1.1DEV-179 (id: <<16315>>):
    select T353.BATCH_ID as c1,
    case when T353.QLTY_RTG_CD = '1' then 'Productive' when T353.QLTY_RTG_CD = '2' then 'Non Productive' else 'Indeterminate' end as c2,
    T353.TOT_TRXN_CT as c3,
    T353.TOT_TRXN_AM as c4,
    T353.BREAK_ID as c5,
    T117.SCNRO_NM as c6
    from
    KDD_SCNRO T117,
    KDD_TA_DATA T130,
    KDD_TSHLD_SET T171,
    VW_SCNR_114000074_TA_DATA T353
    where ( T117.SCNRO_ID = T130.SCNRO_ID and T117.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T353.SCNRO_ID and T130.TSHLD_SET_ID = T171.TSHLD_SET_ID and T171.SCNRO_ID = T353.SCNRO_ID and T171.TSHLD_SET_ID = T353.TSHLD_SET_ID and 0 < T130.BATCH_ID and 0 < T130.RUN_ID )

  • How to put the form in Query mode

    Hello
    Please let me know how to put the form or block in Query mode , so that when i run the form it should be in Query mode . I have seen properties of SET_FORM_PROPERTY and SET_BLOCK_PROPERTY but cannot find one
    Thanks

    QUERY mode? Did you mean, that you can only QUERY without changing data.
    This is the QUERY-ONLY-mode, which can be started e.g. call_form
    this is the help for that topic:
    PROCEDURE CALL_FORM
    (formmodule_name VARCHAR2,
    display NUMBER,
    switch_menu NUMBER,
    query_mode NUMBER,
    data_mode NUMBER,
    paramlist_name VARCHAR2);
    query_mode     
    NO_QUERY_ONLY (The default.) Form Builder will run the indicated form in normal mode, allowing the end user to perform inserts, updates, and deletes from within the called form.
    QUERY_ONLY Form Builder will run the indicated form in query-only mode, allowing the end user to query, but not to insert, update, or delete records.

  • How to put loop in select query..?

    Hi All,
    I am setting select query which CRecordSet is going to execute.
    Existing query is,
    Select branchNumber,Count(*) from branches where branchNumber = %d and dowloadType >%d;  
    Here %d is getting filled every time with new value. Now this query is getting execute 500 times if 500 branches are there.
    We want to improve performance. and want branchnumber and count(*) in One go.
    something like, 
    select branchNumber,Count(*) from Branches where 
    (branch =1 and dowloadType >2)
    (branch =2 and dowloadType >100)
     (branch =3 and dowloadType >234)
    how can we do that?
    Kindly help me on this.
    Thanks,
    Sachin.

    Thanks For reply. but here values are coming from different collection from source code.
    For e.g.  Map[branchNumber][DownloadType] = [1,233],[2,444],[30,234],[5,456].
    Now these values i need to insert at the place of  S.branch   and    S.DownloadType                              
    SELECT GB.Branch ,
    COUNT(*)
    FROM @Sample S
    INNER JOIN @GroupBy GB ON GB.Branch = (value from map)
    AND GB.DownloadType < (value from map)
    GROUP BY GB.Branch;

  • How to put this condition in Query

    Dear experts,
    I have a scenario where in the calculation should be dynamic between key figures in query
    For example i have a
    Target Cost and Actualcost1, Actualcost2, Actualcost3
    i need to findout the variance between the Target and Actual
    but the catch is that i need to findout the variance with the latest actual cost
    1. )  Target cost = 100
    Actual cost1=10, Acutal cost2=0, actual cost3=0
    then the formula should be Actual cost1-target cost
    2. )But if
    Target cost  =100
    Actual cost1=10, Actual cost2=5, Actual cost3=0
    then the formula should be Actual cost2- Target cost
    3. Target cost =100
    Actual cost1=10, Actual cost2 = 5, Actual cost3= 15
    then the formula should be Actual Cost3-Target cost
    How to achieve this
    Thanks and regards
    Neel

    Hi Neel,
    Do you have indicator saying that a particular actual cost is the latest? If you have any indicator thsi would make the job easy. Else you need to create new formulas to derive the logic.
    Else you can proceed with the belwo logic.
    1.target cost
    2. Actual Costs 1 - Hide
    3. Actual Costs 2 - Hide
    4. Actual Costs 3 - Hide
    5. New formula whcih evaluates the latest.
    Write the condition
    If Actual costs3 = 0 and actual cost2 = 0 then actual cost1.
    else if actual cost2= 0 then actual cost1
    else if actual cost1 NE 0 and actual cost2 NE 0 then Actual cost3.
    Then hide the above new formula.
    And in a new formula you can find the diff between the Target cost and the latest cost derived in teh above new formula.
    If the conditions is too big in the above new formula, you can split across two three new formulas and derive the logic.
    Just make some changes to the above logic if it is not 100%.
    I believe this logic will work.

  • Put a form in QUERY mode

    Hi,
    how to put a form in QUERY mode ?
    Many thanks.

    It is F11, type your query, then Ctrl + F11
    Or, click on View > Query By Example > Enter, enter your query, then click on View > Query By Example > Run
    Get all shortcuts from Help > Keyboard Help

  • How to display the out put of the sql query in a text file using forms

    I want to display the out put of the sql query in a text file using forms 6.0.Same could be done using spool command in sqlplus but i want it using forms....Fiaz

    Have a look at the text_io package:
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/oraini/c_text_io.html&vtTopicId=
    cheers

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to put line break in the text

    Hi guys,
    This is a simple problem.i don't know how to concat a line break while creating a text.
    I am looping through the results of a query and want to form the text using the results.
    For each row of the resultset,I want to create a new line in the text i create.
    I was wondering how to put a new line in the text.
    I thought I can concat '\n' ,but it does not work.
    the code snippet in the procedure is :
    for c1_rec in c1 loop
    vMsg := ' There are ' || c1_rec.total ||
         ' documents of type ' || c1_rec.doc_type || '\n' ;
    end loop;
    Please give the solution.
    Thanks in advance.

    Thank you Mark.
    I tried your suggestion.But line break is not working in email.
    Here is how my code is
    in procedure 1 ,i create the message String as :
    for c1_rec in c1 loop
    vMsg := vMsg || ' ' || today_str || ' - ' || c1_rec.total ||
         ' Total inbound documents from : ' || c1_rec.target_value || CHR(13)||CHR10) ;
    dbms_output.put_line(' ' || vMsg);
    end loop;
    --here sending mail calling another procedure
    sendmail( '[email protected]' ,'[email protected]' , 'Test Subject ' , vMsg );
    In Procedure 2( i.e sendmail procedure )
    i am preparing email server connection from and to adresses .Then i am preparing and sending message as
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    conn:= utl_smtp.open_connection( EmailServer, Port );
         utl_smtp.helo( conn, EmailServer );
         utl_smtp.mail( conn, SENDER);
         utl_smtp.rcpt( conn, RECEIVER )
    mesg:= 'Subject: ' || SUBJECT || crlf ||
                   'Date: '||TO_CHAR( SYSDATE, 'Dy, dd Mon yyyy hh24:mi:ss' )||
                   crlf ||
                   'From:'||SENDER|| crlf ||
                   'To: '||RECEIVER || crlf ||
                   'Content-Type: text/html; charset=ISO-8859-1' || crlf ||
                   '' || crlf || MESSAGE ;
         utl_smtp.data( conn, mesg );
         utl_smtp.quit( conn );
    even now the mail we are getting is not having the line break.I am having line break in dbms output,but not in the mail.
    Is there any mistake how I am sending the mail.Or is there any other way we can put line break in the text
    Thank you.

  • How to put restriction/variable in BI 7.0 ? Is there any settings required?

    Hello,
    I am working on BI 7. I want to know ""How to put restriction/variable in BI 7.0 ? Is there any settings required? I am putting some variables in BI 7.0 while making some query""
    amit shetye.

    Hi Amith,
              just create a new query  like a previous  versions how u create..  and  now  select particular charecterstic  in the  left side window itself.. and drill down it.. and create  a variable..  and assign all the properties to that variable.. now  drag that particular variable.. in to the Rows  or filters..
         for Restrictions...  put any charecterstics into Free charecterstics.. and right clcik that and select  Restriction. now you need to give  the  values.. based on that  it will  RESTRICT THE VALUES..
    BI 7.0 reporting features
    http://searchsap.techtarget.com/cgi-bin/rd.pl/ftID-1121728-ctID-1064004?//expert/KnowledgebaseAnswer/0,289625,sid21_gci1064004,00.html
    http://help.sap.com/saphelp_nw04s/helpdata/en/9d/24ff4009b8f223e10000000a155106/content.htm
    https://www.sdn.sap.com/irj/sdn/developerareas/bi?rid=/webcontent/uuid/ba95531a-0e01-0010-5e9b-891fc040a66c [original link is broken]
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/F9D041D6392AE3E10000000A422035/frameset.htm
    BI7.0
    For greater information on reporting.....
    Good Knowledge in BW Reporting
    regards
    @jay

  • How to put OR clause in SELECT statement

    Hi
    How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
    <pre>
    SELECT
    a.id ,
    flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
    apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
    from
    a ,
    b
    where b.street_name = a.street_name
    AND b.SUBURB = a.SUBURB
    AND b.STATE = a.STATE
    </pre>
    Thsi will return this as exact match.
    ADDRESS 1
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    ADDRESS2
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    However this only matches number_first.
    How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.

    Hi, I have a hard time understanding your request, and below is what I thought you want:
    SELECT
        a.id ,
           flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb  address1,
             apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
          from
                 a ,
                 b
                where          b.street_name = a.street_name
                 AND            b.SUBURB      = a.SUBURB
                AND            b.STATE       = a.STATE
                AND  (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
    Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
    (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
    Edited by: PhoenixBai on Aug 26, 2010 11:33 AM

  • How to see views created on query in a report.

    Hi
    Could you please help me out urgently?
    I have a question regarding how to see views created on query in a report.
    Is there any table or query through which we can see views created on Query?
    Thanks & Regards
    Neha

    Hi,
    If you created a view on any query,
    What is view ?
    once you execute the query and save the output as view right ?
    But we can not see the view in query output.
    Insted of executing the query, directly we can execute the view which you have saved as query output.
    Open the BEX and search for the view insted of query then it will give you the out put directly.
    I hope it will help you.
    Regards,
    Yerrabelli.

  • How to know if executing a query cost long time

    Hi,
    I have a question about how to figure out if execution of a query takes long time. I am building a web application in java. The back end database is oracle. If a query is too large, I want to put show the user the error message to let the user make more specific query. but how can I tell if the query execution takes long time? Thanks.

    The following link may be of help.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3175.htm#1123208

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • How to put database in single user mode?

    hi
    how to put database in single user mode?and what could be the impact of this to EBS R12 RUP 6.DB 10.2.0.0
    rgrds

    hsawwan wrote:
    Hi,
    Are you referring to restricted mode? If yes, please see these links/docs.
    Restricting Access to an Open Database
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/start002.htm#ADMIN11155
    Note: 1059291.6 - How to Put a Database into Restricted Mode and Verify Restricted Mode
    The impact is none of the users will be able to connect to the database/application (except for the sys user which can connect to the database). Usually, you would need to put the database in restricted mode when doing upgrade/migrate (i.e. you do not want to have active user sessions in the database during that time).
    Thanks,
    HusseinHi
    i want to mean:
    ALTER SYSTEM QUIESCE RESTRICTEDThe ALTER SYSTEM QUIESCE RESTRICTED statement may wait a long time for active sessions to become inactive. You can determine the sessions that are blocking the quiesce operation by querying the V$BLOCKING_QUIESCE view. This view returns only a single column: SID (Session ID). You can join it with V$SESSION to get more information about the session, as shown in the following example:
    select bl.sid, user, osuser, type, program
    from v$blocking_quiesce bl, v$session se
    where bl.sid = se.sid;I suspect all apps user can.t login to db?
    Edited by: new2appsdba on Aug 19, 2010 1:54 AM

Maybe you are looking for

  • Oracle Application Server 10G base release on AIX 5.1 L

    We are having 2 AIX Servers with AIX 5L V5.1 working through cluster HACMP V 4.5 and Oracle Application Server 9.0.2.3 ported on one of its node se,because of the bug in the AS we have disabled the clustering services on the node porting the Applicat

  • Help with Movie Clips

    Hi - I'm having a problem with my movie clips playing simultaneously and cannot, for the life of me, figure out what I have done wrong. I'm new to flash, so I may have set something up incorrectly, but here's what I have so far: 11 layers, total: 1 l

  • Tomact examples and form base authentication

    I am looking at the tomcat examples web.xml security constrains and login info settings: <security-constraint> <display-name>Example Security Constraint</display-name> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name>   

  • SOA Suite 11G EM and Windows 7 / IE8

    Anyone else have an issue where 11GR1 is installed on a remote server (Win2K3) and you can log in to EM console using Firefox but not IE8 from Windows 7? My Firefox on Win7 works fine but the integrated IE8 just hangs on the login screen and 'spins'.

  • Why isnt the menu button working???

    Right i've just had a new iPod mini because my last one broke, and its been working fine since last night and the menu button has just stopped working the iPod is working fine but the menu button just isnt working! does anyone know why and how to fix