How to insert a string containing a single quote to the msql database? help

how can i insert a string which contains a single quote in to database... anyone help
Message was edited by:
sijo_james

Absolutely, Positively use a PreparedStatement. Do not use sqlEscape() function unless you have some overriding need (and I don't know what that could possibly be).
There are 1000's of posts on the positive aspects of using a PreparedStatement rather than using a Statement. The two primary positive attributes of using a PreparedStatement are automatic escaping of Strings and a stronger security model for your application.

Similar Messages

  • Trouble with inserting a string containing a single quote

    Using php with Oracle
    If I do the following two lines before sending my $Query string through the parse function
    $name = "Dominick's";
    $Query = "INSERT INTO customers (name) values ('$name')";
    it gives me the following error:
    Warning: Ora_Parse failed (ORA-00917: missing comma -- while processing OCI function OPARSE)
    If I try and force the single quote to be surrounded by double quotes and therefore not be confused:
    $name = "Dominick's";
    Query = "INSERT INTO customers (name) values (\"$name\")";
    Trying that yields the following error:
    Warning: Ora_Parse failed (ORA-01741: illegal zero-length identifier -- while processing OCI function OPARSE)
    Help
    Jeff

    If it is possible (and here it is) you should use str_replace instead of ereg_replaceThanks for the reminder about str_replace().
    $Query = "INSERT INTO customers (name) values ('".addSlashes($name)."')";This gives an invalid Oracle SQL statement, which will generally fail with
      ORA-01756: quoted string not properly terminatedFor Oracle, single quotes must be doubled, not escaped with backslash.
    Of the solutions to insert the data, I'd prefer using bind variables
    since no escaping or quote doubling is needed.
    -- CJ

  • How to Insert two queries in a single workbook in BI 7 ?

    Hi,
               I am trying to insert two queries in a single workbook. The queries are of Accounts Receivable.I have inserted one query in a workbook , but am not able to proceed to inserting the second query. In BEx analyzer, in design mode , using analysis grid , i tried inserting the second query but when saving and running, i am getting message " Variables are present, change their values " . should i maintain same variables for two queries ? i am stuck up. please explain me as how can this be done.
    Roja.

    Hi,
    If you get the message "Variables are present, change their values" ,it means that the query which you inserted having variables.
    You just click the "Change Variables" icon in the Analysis Toolbox,which will invoke the variable screen.
    Set the values in the variable screen and click OK.
    Now you will be able to see the data in the grids based on the values selected in the variable screen.
    Both queries data will be displayed in the workbook.
    Let me know in case of any clarifications!
    Rgds,
    Murali

  • How to insert multiple records in a single query

    Dear all,
    Can you please tell
    how to insert multiple records in a single query ??

    INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
    INSERT INTO table_name
    (column_1, column_2)
    SELECT 'value_A', 'value_B' FROM DUAL
    UNION ALL
    SELECT 'value_C', 'value_D' FROM DUAL
    ;Edited by: Benton on Nov 9, 2010 1:59 PM

  • How to insert some strings in a query with the clausule 'in' in a procedure

    Hello fellows.
    Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
    I tell us my problem with an example:
    I want to use this select but introducing a variable instead the 'value1', 'value2':
    select * from table1 where field1 in ('value1', 'value2');
    if I declare the variable var1 as:
    TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
    and I use it as:
    select * from table1 where field1 in (TC_VAR1);
    It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
    select * from table1 where field1 in ('value1, value2');
    If I use the data type TABLE, I don't know how to use well:
    TYPE varchar2_table IS TABLE OF VARCHAR2(10);
    tb_var varchar2_table;
    select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
    A curious case is that if I have a sql script (for example script1.sh) with this query:
    select * fromt able1 where field1 in (&1)
    and I invoke this script as
    script1.sh "'''value1'',''value2'''". It works
    Can anybody helps me?.
    Thanks.

    Thanks to all. Really.
    First, sorry for my English. It's horrible. Thank to all for understand it (my English).
    I've resolved my problem with these links:
    ORA-22905: cannot access rows from a non-nested table item
    and
    http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
    At last, I have used someting like this:
    DECLARE
    number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
    BEGIN
    FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
    UNION ALL
    SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
    NULL;
    END LOOP;
    END;
    but first I had to create the type NUM_ARRAY like this:
    CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
    THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
    Edited by: user12249099 on 08-sep-2011 7:37
    Edited by: user12249099 on 08-sep-2011 7:37

  • How to determine if string contains HashSet item using LINQ

    Hi,
    I know how to iterate through a HashSet to see if an item is contained in a string.  But, I can't quite figure out how to do it with LINQ.
    Something like if( string.Contains(???))
    I would appreciate any help!
    Thanks much!!

    Thanks everyone.  I like the examples posted above.
    Actually, what I want to know is if any HashSet values can be found in a string using LINQ
    HashSet<string> terminals = new HashSet<string>();
    terminals.Add("FD4A");
    terminals.Add("FD4B");
    terminals.Add("FD4C");
    //a collection of a bunch of transactions done at various terminals
    List<string> transactionList = new List<string>();
    foreach (string transaction in transactionList)
        foreach (string terminal in terminals)
           if (transaction.Contains(terminal) == true)
                //this is one of the transactions I want - do something
                break;
    Thanks much and have a great weekend!!

  • How to copy item value that contain a single quote(')?

    Hi,
    I have one "Copy" button in a APEX form. When user clicks it, it simply copy the item's values from the form to a new form by using APEX provided function behind the button- "Set these item values with these values". It is simple and works fine in normal cases. However, see, we have a text field called "Product Details", user types in for example "Oracle's new vision". When I click COPY button, APEX try to copy the text in "Product Details" field from this form to a new form but it returns error because of that single quote. Is there any way I can do something to replace that single quote with two single quote like we usually do in PL/SQL in the place "Set these item values with these values" of APEX button? I tried REPLACE(#P66_PRODUCT_DETAILS#., '''', '''''') but not work. I saw someone in the forum meantioned that to use something like "/#P66_PRODUCT_DETAILS#/" to get around. Any one with success?

    Thanks. I think it should work this way. However, our form has about 20 ~30 text fields, I have to create 20~30 hiddle fields to handle the problem because I never know which field could contain a single quote. Ideally, a new version of APEX should have the functionality to deal with the problem when using "set values with those values" method. At least, it should provide some kind of interaction for user to get away from single quote or comma or column etc.
    What I did is to get out of APEX native function and to create a new records in background by PL/SQL using record id that passed in from APEX form. It works perfectly. Although, user can only edit the record after it is created, not as user friendly as "Copy first-look at it-edit it-then create it" I originally planed.
    Thanks for your help,

  • How can I will declare the symbol u2018 (Single Quote) in the report

    Hi ,
    Could you please tell me how can I will declare the symbol u2018 (Single Quote) in the report.
    My requirement is that I have concate the data with single quote and after that I have to store the data in to an internal table and I have to download the data in the form text file in the presentation server.
    For example :
    Let the below data I want to download into the presentation serve in the format of text file by storing in internal table.
    Assume all are constants:
    1st line : abcu2019add
    2nd line :  defu2019gef
    Thanks in advance.

    Hi Jyothi,
    Thanks for the quick reply .
    I can agree with you are point but My requirement is like this I am explaining clearly.
    I have declared the internal table like this.
    DATA: BEGIN OF OTAB OCCURS 0,
             LINE (9024),
           END OF OTAB.
    So I have to append the each line item into the internal table.
    So I am explaining what the data I have to append
    Ist line contains
    'UNBUNOC:2020308u2019 where 020308 I will get the  date from reguh table
    2nd line contains:
    'DTM+20020510' where the 20020510 will be reference document number from the table reguh.
    So I want to declare a constant 'UNBUNOC:2
    2nd the date from reguh table
    And another constant u2018
    So that I can concate all the three and I can put into string and I will append into internal table and I can download the data into the presentation server.
    Please let me know if you need any more clarification regarding my requirement.
    Thanks in advance.

  • SSRS Report Returning Double Quote string from a Single Quote String

    Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote. 
    For example  following string:
    'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
    Returns: 
    ''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
    through SSRS report.
    Here is the split function Im using in a report.
    CREATE Function [dbo].[fnSplit] (
    @List varchar(8000), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(8000) NULL 
    As 
    Begin 
    Declare @item varchar(4000), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
    Select @List = @List + @Delimiter -- get position of first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    FYI: I'm getting @List value from a table and passing it as a string to split function. 
    Any help would be appreciated!
    ZK

    Another user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
    CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
    RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
    AS
    BEGIN
    WHILE CHARINDEX(@delim,@string) > 0
    BEGIN
    INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
    SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
    END
    INSERT INTO @result (value) VALUES (@string)
    RETURN
    END
    GO
    ZK

  • String with embedded single quote

    Hi, all. We're trying to pass a string from one procedure to another, which will then do an EXECUTE IMMEDIATE on it. However, there are single quotes withing the string, and they're driving us nuts! This is what the concatenated string should look like when passed to the pw_execDDL procedure:
    insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values ('MEAG', to_date('02-OCT-05','DD-MMM-YY'), 'Y',1);
    Here's the concatenation process that doesn't work, and there are functions being called within the string:
    chr_sql := 'insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values (' || '''' || prm_inoc_id || '''' || ', ' || 'to_date(' || '''' || prm_proof1 || ''''||','||'''' ||'DD-MMM-YY'||''''||')' || ', ' || '''' || fw_is_proof_valid(prm_birth_date, prm_proof1) || '''' || ',1);';
    pw_execDDL(chr_sql); /* call the procedure to do the EXECUTE IMMEDIATE */
    Help! We've tried every combination -- using two single quotes together, three, and four, and still no luck. Thanks.

    insert into appimmunization.wsrprfs (inoc_id, proof,
    is_valid,proof_num) values ('MEAG',
    to_date('02-OCT-05','DD-MMM-YY'), 'Y',1);
    This statement can be made in a string with the following affectation:
    chr_sql := 'insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values (''MEAG'', to_date(''02-OCT-05'',''DD-MMM-YY''), ''Y'',1)';
    Note please that each single quote in your original string must be specified using two single quotes and that is all. It is more readable and more easy to do it this way.
    Michel.

  • Passing String Which Has Single Quote Row/Value to a Function Returns Double Quoate

    Hi, I'm getting weird thing in resultset. When I pass String which has single quote value in it to a split function , it returns rows with double quote. 
    For example  following string:
    'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
    Returns:
    ''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
    Here is the split function:
    CREATE Function [dbo].[fnSplit] (
    @List varchar(8000), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(8000) NULL 
    As 
    Begin 
    Declare @item varchar(4000), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
    Select @List = @List + @Delimiter -- get position of first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    FYI: I'm getting @List value from a table and passing it as a string to split function.
    Any help would be appreciated!
    ZK

    fixed the issue by using Replace function like
    Replace(value,'''''','''')
    Big Thanks Patrick Hurst!!!!! :)
    Though I came to another issue which I posted here:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a26469cc-f7f7-4fb1-ac1b-b3e9769c6f3c/split-function-unable-to-parse-string-correctly?forum=transactsql
    ZK

  • Single quote in the String????

    Hello All,
    I want to supress the meaning of single quote in the string, so that I can use the string as one of the fields in my sql query, for doing this inserting "/" before the single code is the way or is there any other standard way to achieve this.
    Thanks in Advance,
    Sarada.

    usually you need to use the scape character for stopping the meaning of a single qoute, or even double quite \', \"
    String s = "select empname from emps where id=\'123\'" ;
    Regards

  • Am new at pages and cannot figure out how to insert a bullet where I want it in the text, not at the beginning of the paragraph.  Word was much easier for me

    Am new at this forum and also at pages and can't figure out how to insert a bullet where I want it in the text, not at the beginning of the paragraph.  I found word much easier to use.  Please help. Trying to do a resume.

    On a US keyboard it is Option + 8 (above the letters). •

  • Can we have a Single quote in the tooltip text?

    Hi,
    We have some tooltips for the presentation columns which contains a single quote.
    When I try to view the tooltip from answers the single quote is being replaced by double quotes.
    I tried to use all sorts of escape characters for single quote, like "\'" and ''' and "'" but that didn't work.
    Is there any way to do this.
    Thanks!!
    Vasantha.P

    As I said in my earlier post, I am looking for the tooltips for the Presentation tables and columns. The tooltips for these were extracted from the RPD using the externalize Strings option and these externalized strings are stored in the database.
    So I am escaping the single using a single quote both in rpd and in the database.
    Example text I have used both in the rpd and database is something like "Shipment's start time". I tried with "Shipment''s start time", " Shipment'''s start time", but it didn't work.
    Thanks!!
    Vasantha.P

  • How can I create an active table of content in the sidebar to help readers to get to the section?

    How can I create an active table of content in the sidebar to help readers to get to the section?

    You can create bookmarks with Adobe Acrobat.

Maybe you are looking for

  • How Can I Move the Image in the Workspace to Align with 0 on the Ruler (CS5)?

    I am completely new to Photoshop (CS5) so I don't know all the correct terms to explain my problem but I'll try.  I'm working on a computer with Windows 7. I open a RAW image and edit it to my satisfaction, and then I "Open Image" in CS5 to do a litt

  • Expand/Contract Tree Issue

    Hi all, I have a tree, which is a collection of all the pages in my application. I am using 2 level tabs as well. I want my tree to expand only that node page which is currently being clicked from the tab i.e when i click the tab in two level tabs, t

  • HTMLDB 1.6 Download

    Hi, Please let me know the time frame for 1.6 download for Solaris and Windows ? Regards

  • Iphone notes are not syncing with outlook 2010

    Hi, my iPhone 4 notes are not synchronize with outlook 2010 in both way. I uninstall my itunes and office and reinstall but still the problem remain. I also check itunes addin in outlook 2010 which is active.  I checked in itunes info tab all setting

  • Generating XML String

    I may have missed something obvious but the SAX & DOM bits of the XML Parser don't seem to supply any way of getting from a set of parsed (or created) Document Java objects to a marked up XML string. Is this something we have to do ourselves by navig