Display the string with single quote

Hello..

I have a doubt.

Below the statement works very well to get the result in single quotes as 'Hello world'
   SELECT '''Hello World'''
   FROM dual;
Now my question is why we get error when we try to do the same.

   SELECT ''Hello World''
   FROM dual;
Please let me know the reason, if an organization is to have an idea.

Thank you
Suri

To print a single quotation mark, use two single quotes (IE he "s to print from) and to print a string to write the string inside the single quotation mark as"Hello Word ".
You want to print "Hello World" your sql will be

SELECT '''Hello World'''
   FROM dual;

You get the following error as search oracle of KEYWORD Analyzer after "that a chain is closed using the" quote

SELECT ''Hello World''
   FROM dual;
ORA-00923: FROM keyword not found where expected

Tags: Database

Similar Questions

  • Insert into DB using SQLservice: can't take the text with single quotes:

    I use Execute sql JDBC service statement.

    I'll explain with simple code:

    insert into mytable (id, desc) values (1, 'this is the document of the customer');

    This works perfectly.

    But if I have apostrophes in the desc-

    insert into mytable (id, desc) values (1, 'this is the document the customer' );

    It is throwing error at a standstill operation errors.

    I know that in Oracle, to escape the single quotes that write us

    insert into mytable (id, desc) values (1, "it is of customer" s document ");

    But, we can not control here in Adobe as the desc is from field on a form when the user enters it.

    I'm guessing that it might be a known issue & can someone tell me the solution.

    Thank you

    KC

    Use a parameter query to avoid this problem.

    insert into mytable (id, desc) values (?,?);

    The two parameters (? brands) can be replaced by actual values using XPATH Expression.

    If you do this, you query runs without raising any errors.

    Nith

  • How do to concatenate the strings having single quote and ampersand

    Hi all

    I have a task to concatenate two columns under SID - SNAME.

    Input parameter is: sid. We can pass multiple parameters: sid

    CREATE TABLE TABLE1 (NUMBER SID, SNAME VARCHAR2 (100));

    Insert into TABLE1 (SID, SNAME) values (1, 'SURF UP');

    Insert into TABLE1 (SID, SNAME) values (2, 'GNLV STYLE & KEY');

    Insert into TABLE1 (SID, SNAME) values (3, 'ESSENTIALS NORTH & SOUTH');

    Insert into TABLE1 (SID, SNAME) values (4, "Of Ora");

    Select * from TABLE1;

    SID SNAME
    1Of THE SURF's UP
    2KEY & GNLV STYLE
    3ESSENTIALS NORTH & SOUTH
    4ORA

    Expected results

    1. with the setting entry: sid in (1,2)

    Output: 1 - SURF to the TOP, 2 - GNLV STYLE & KEY

    2. with the setting entry: sid in (1,2,3,4)

    Output: 1 - SURF to the TOP, 2 - GNLV STYLE & KEY, 3 - ESSENTIALS NORTH & SOUTH, 4 - ora

    I tried to use the below query,

    Select (select RTRIM (xmlagg (xmlelement (c, sid |')))) -' || SNAME | (",")) .extract ('/ / text()'), ',')

    AS concatenated FROM table1 where «,» | : para. ',' like '%', | SID | %') as double concat;

    What I get for output is as below:

    1 SURF & apos; S upwards, 2 - GNLV STYLE & amp; TREND

    I'm not handling apstrophe and ampersand correctly.

    Can you please help me.

    Thank you

    What I get for output is as below:

    1 - SURF to the TOP, 2 - GNLV STYLE & TREND

    I'm not handling apstrophe and ampersand correctly.

    Yes. This is what happens when you use a method that is not understood.

    The answer to your question is dependent on the version and already well covered in the FAQ.

    See 'Channel aggregation' in Re: 4. How can I convert rows to columns?

    If you are on 11.2 and beyond, use LISTAGG function.

    Regarding your present attempt, since you are extracting text() nodes on an aggregate of XMLType, the result is still a valid XMLType and therefore shows the XML characters reserved in their forms with escape sequence.

    If you want to stick with the XML approach, from 11.1, is the right way to handle this situation:

    SQL> select rtrim(
      2           xmlcast(
      3             xmlagg(
      4               xmlelement(e, sid ||' - '||sname||',')
      5             )
      6             as varchar2(4000)
      7           )
      8         , ','
      9         ) as concatenated
    10  from table1
    11  where ',' || '1,2,3' || ',' like '%,'|| sid || ',%' ;
    
    CONCATENATED
    --------------------------------------------------------------------------------
    1 - SURF'S UP,2 - GNLV STYLE & KEY,3 - ESSENTIALS NORTH & SOUTH
    

    In earlier versions, use either:

    select rtrim(
             dbms_xmlgen.convert(
               extract(
                 xmlagg(
                   xmlelement(e, sid ||' - '||sname||',')
                 )
               , '//text()'
               ).getstringval()
             , 1
             )
           , ','
           ) as concatenated
    from table1
    where ',' || :para || ',' like '%,'|| sid || ',%' ;
    

    Mun

    select rtrim(
             utl_i18n.unescape_reference(
               extract(
                 xmlagg(
                   xmlelement(e, sid ||' - '||sname||',')
                 )
               , '//text()'
               ).getstringval()
             )
           , ','
           ) as concatenated
    from table1
    where ',' || :para || ',' like '%,'|| sid || ',%' ;
    
  • With single quotes varchar column

    Hello

    How to extract a varchar column with single quotes in the DB

    For example, I want the result as below

    SELECT id, name of the cust

    1, 'ABC '.

    Kind regards
    Abdul
    select id
          ,''''||name||''''
      from cust
    
  • How to concatenate the string with a digital command?

    Hello

    How to concatenate the string with a digital command?

    Thank you.

    I think I forgot to add the semicolon, what you can do is, drag the CONCATENATE function and add semicolon.

  • Unable to [out] the value of the parameter put_line with single quotes (apostrophe)

    Hello

    I want to store a common code in a sql file and where the different clauses as a parameter, so the structure is:

    Main.SQL Script:
    set m_sWhere = ' owner = "SCOTT" ';
    @MyReport.sql '& m_sWhere '.

    MyReport.sql
    OK: SELECT * FROM MyTable WHERE & 1
    ERR: dbms_output.put_line ('MyWhere: & 1');

    I am not able to print the where the clause. I already tried to set the where clause with other delimiters (e.g. #SCOTT #) and replace # by ' in the MyReport but failed as well.

    All advice welcome.

    Published by: netaktiv on 11.02.2012 08:35

    Hello

    netaktiv wrote:
    Hello

    I want to store a common code in a sql file and where the different clauses as a parameter, so the structure is:

    Main.SQL Script:
    set m_sWhere = ' owner = "SCOTT" ';
    @MyReport.sql '& m_sWhere '.

    Sorry; It is unclear what you are trying to do, and what you're doing.
    I think the only single-quoptes in m_swhere are those before and after SCOTT:

    DEFINE  m_sWhere = owner='SCOTT'
    

    That's what you need to be able to use this variable in an SQL statement. SQL * more will replace & 1 with its value. If you were typing the statement directly, just type a single before and after SCOTT quote, if you want only a single quote before and after SCOTT in m_swhere. You use 2 single quotes in a row inside string literals, but the string literal only you need here is the literal 5 characters 'SCOTT', containing sound ", a 'C', 'o', two ' t and single quotes to zero."

    MyReport.sql
    OK: SELECT * FROM MyTable WHERE & 1
    ERR: dbms_output.put_line ('MyWhere: &1');)

    I am not able to print the where the clause. I already tried to set the where clause with other delimiters (e.g. #SCOTT #) and replace # by ' in the MyReport but failed as well.

    You do not want channels OK: or ERR: in the script.
    Dmbs_output.put_line, like any procedure, only works in PL/SQL.
    If you want to display text in a SQL * more script, use the SQL * FASTER command, like this:

    PROMPT  MyWhere: &1
    

    If you really must use dbms_output.put_line, then you will need to use a string literal, and single quotes can be tricky.
    In Oracle 10 (and more) use Q-rating:

    BEGIN
        dbms_output.put_line ( Q'{MyWhere: &1}' );
    END;
    /
    

    {Quotes will not be a problem unless they occur immediately after a right '}'.

  • help request pivot with single quotes inside a string literal

    Hi all

    I have a little trouble with a pivot query. Oracle (10g R2) is:

    ORA-00604: an error occurred at recursive SQL level1
    ORA-01003: no instruction not analyzed

    My problem is pretty clear. When I do a pivot query to display a list of records where the countries are the column headers and rows headers is months that the system hesitates when she returns a country with an apostrophe in it. for example

    COUNTRY_NAME = ' KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF»

    I know that I have to catch the literal single quote and manipulate. I am just having unsuccessfully in management of it and I'm a little out of ideas. Can someone tell me a nice solution?

    The complete procedure is listed below: the


    PROCEDURE getCountryInvPlan)
    iINV_PLAN_DEPOT_ID in NUMBERS
    iITEM IN VARCHAR2,
    RC IN OUT pkg_DMT_INV_PLAN.t_rc,
    oErrorMsg OUT VARCHAR2)
    IS
    v_sql VARCHAR2 (32767).
    BEGIN


    v_sql: = 'select MONTH_BUCKET ';
    FOR rec IN
    (select distinct (COUNTRY_NAME) in the DMT_INV_PLAN_DEPOT_COUNTRY where INV_PLAN_DEPOT_ID = iINV_PLAN_DEPOT_ID)
    LOOP
    v_sql: = v_sql
    || ', MAX (DECODE (COUNTRY_NAME, "'))
    || recomm. COUNTRY_NAME
    || ((', PATIENT_DEMAND)) ' "»
    || recomm. COUNTRY_NAME
    || '"';
    END LOOP;
    v_sql: = v_sql
    || ', ' DECODE(MONTH_CLOSED,0,''OPEN'',1,''CLOSED'') AS MONTH_STATUS
    || ' FROM (SELECT DMT_INV_PLAN_DEPOT_COUNTRY. MONTH_BUCKET, DMT_INV_PLAN_DEPOT_COUNTRY. COUNTRY_NAME, DMT_INV_PLAN_DEPOT_COUNTRY. PATIENT_DEMAND, DMT_INV_PLAN_ITEM. DMT_INV_PLAN_DEPOT_COUNTRY MONTH_CLOSED, DMT_INV_PLAN_ITEM '
    || "where DMT_INV_PLAN_DEPOT_COUNTRY.". INV_PLAN_DEPOT_ID = DMT_INV_PLAN_ITEM. INV_PLAN_DEPOT_ID '
    || ' AND DMT_INV_PLAN_DEPOT_COUNTRY. ITEM_DESCRIPTION = DMT_INV_PLAN_ITEM. ITEM_DESCRIPTION '
    || ' AND DMT_INV_PLAN_DEPOT_COUNTRY. MONTH_BUCKET = DMT_INV_PLAN_ITEM. MONTH_BUCKET '
    || ' AND DMT_INV_PLAN_DEPOT_COUNTRY. INV_PLAN_DEPOT_ID = ' | iINV_PLAN_DEPOT_ID
    || ' AND DMT_INV_PLAN_DEPOT_COUNTRY. ITEM_DESCRIPTION = "' | iITEM | " ') '
    || 'GROUP by MONTH_BUCKET order MONTH_BUCKET MONTH_CLOSED';
    RC OPEN FOR v_sql;

    oErrorMsg: = v_sql;

    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    oErrorMsg: = "NO DATA FOUND";

    WHILE OTHERS
    THEN
    oErrorMsg: = "ERROR";
    oErrorMsg: = v_sql;
    END getCountryInvPlan;

    Maybe you can try this:

    -- Etc --
    || ',MAX(DECODE(COUNTRY_NAME,'''
    || REPLACE(rec.COUNTRY_NAME,'''','''''')
    || ''',PATIENT_DEMAND)) "'
    || rec.COUNTRY_NAME
    || '"';
    -- Etc --
    

    8 2

  • Select statement with single quotes in the insert statement

    Dear Sir

    What's the trick to cover this issue:

    Insert into TEST_TABLE (SQL_SCRIPT_ID, SQL_SCRIPT)
    values ("1", "select count (*) from the SOURCE where SOURCE.") VALID = 'Y')

    because of the single quotes, I get an error and can not insert, the script works, is there a workaround somehow?

    Thank you 1 million,

    Erik

    Published by: 845498 on June 13, 2012 04:15
    create table testsql(script_id number,sql_script varchar2(1000));
    
    insert into testsql (script_id, SQL_SCRIPT)
    values (1, 'select count (*) from SOURCE where SOURCE.VALID = ''Y''');
    
  • Search for a similar string in the 2D array and displays the result with another column

    Hello

    One who can help, I have a chart 2D of txt file that have as many lines and 5 columns and I want to do a search and display the other results of the column.

    For example.

    Column 0                      1                           2                                  3                           4

    12345 qwer asdf 12qwe tjhrtyert

    werr 23568 wef fgertge fsefff

    If I manage to find 12345 and I want to display 12qwe, what should I do in labview? Help, please!

  • To display the string on the one button dialog

    I would like to format the display of the string through the dialog box only one button.  How do I do that?  I want the text to ensure that the different color and style.  I'm a string constand feeding the node of a single button dialog box.  I was teo may change the color of the text on the block diagram, but when it is displayed, the color did not appear.

    You cannot format the text for the dialog a button. You must create your own dialog box. Examples are provided with LabVIEW.

  • Replace the string with the formatted text

    Hello all - I'm back to my beloved project...

    I want to replace a string by a TextSelction (formatted text) and began with the famous feature of Jang FindAndReplaceString.
    Since my replacement comes from another document (sourceDoc), I edited to targetDoc activeDoc and introduced a second document (sourceDoc).
    The replacePara actually comes from a stone where he had been placed to avoid switch backwards between the documents in a book (where to find and replace) and source documents. In another function, I learned that information on the table requires the sourceDoc must remain open.

    • Of course, everything works fine until I want to insert the replacelement:
      erase line 26 is the string
    • Given that I do not insert a string, I skip lines 28 and 29 and try try line 30
    • On line 30 DocumentSource is Document object and replacePare object TextSelection. However, sourceDoc.replacePara is not set and
    • (as a result?) line 31 past the current contents of the Clipboard.

    Of course, there is a fog around me... and I need some sunshine.

    function FindAndReplacePara (targetDoc, findString, sourceDoc, replacePara, loopMax) {
      var tr = new TextRange();
      var restoreTR, frame = 0, loopCounter = 0, replacementCounter = 0;
      var findParams = new PropVals();
      var firstPgf = targetDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
      
      tr.beg.obj = tr.end.obj = firstPgf;             //  set up the starting text range as the very beginning
      tr.beg.offset = tr.end.offset = 0;              // of the flow. We'll move straight from beginning to end.
      trSaved = tr                                    // to come back after work
    
      findParams = AllocatePropVals(2);
      
      findParams[0].propIdent.num = Constants.FS_FindText;
      findParams[0].propVal.valType = Constants.FT_String;
      findParams[0].propVal.sval = findString;
      
      findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;
      findParams[1].propVal.valType = Constants.FT_Integer;
      findParams[1].propVal.ival = Constants.FF_FIND_CONSIDER_CASE;
    
      FA_errno = Constants.FE_Success;                // errno global, to be used to track the progress of the find and replace
      tr = targetDoc.Find(tr.beg, findParams);        // and do an initial find to get started.
      
      while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) { //find and replace loop as long as we keep finding
        targetDoc.TextSelection = tr;                 // set up the text range to clear the original text
        targetDoc.Clear(0);                           // clear it
        
    //    targetDoc.AddText(tr.beg, replacePara);       // insert the new text at the original beginning of the text range
    //    tr.beg.offset += replacePara.length;          //  lets jimmy the text range in memory to place it directly after
        targetDoc.TextSelection = sourceDoc.replacePara;        // paste the whole replacement paragraph
        targetDoc.Paste (0);                          // <-- Current contents of clipboard is pasted !!!!
        if(FA_errno === Constants.FE_Success) {       // increment our return counter
          replacementCounter++;
        }
        FA_errno = Constants.FE_Success;              // ...  find the next instance. We'll reset FA_errno again just in case
        tr = targetDoc.Find(tr.beg, findParams);      // something screwy happened while we were replacing text.
      }
      targetDoc.ScrollToText(trSaved);                // we're done. Restore the document to it's original area of display
      return replacementCounter;
    } // --- end FindAndReplacePara
    

    Hi Klaus,

    Thanks for the explanation. I remember something like that GetTabRange of the way back. You have been quite patient and persistent with this project, indeed.

    So, as we are dealing with ranges of text here, I think that the only simple approach is to perform a copy and paste. There is no way to save a 'formatted' in a variable. The only super precise way would be to get a data structure of each text range TextItems in the sourceDoc, then meticulously recreate every element of the targetDoc. It would be very complicated, I think, so copy and paste seems the most logical. I wonder, though, if Miss me something, because I think that maybe you would have tried already so yes (?)

    In any case, I would do something like that, from line 30 of your original code sample (code untested here):

    App. ActiveDoc = sourceDoc;

    sourceDoc.TextSelection = replacePara;

    sourceDoc.Copy (0);

    App. ActiveDoc = targetDoc;

    targetDoc.Paste (0);

    ... etc.

    Does make sense, or am I barking the wrong tree, as they say?

    Russ

  • How to convert the string with numbers in the table of Boolean 2D

    Hello

    I have input a string with comma separated numbers 1,192 (starting at 1).

    This string must be converted to a table 2D-boolean. Each number that appears should be true, not true rest.

    The 2D table consists of 4 times of 0.47 Boolean values.

    1.48--> [0.47] numbers [0]
    49.96--> [0.47] numbers [1]
    Numbers 97.144--> [0.47] [2]
    145.192--> [0.47] numbers [3]

    If a '1, 49, 97 145' input string put all [0] [0.3] true.

    How can it be easy/fast resolved?

    Thanks for help

    Break the string of numbers in a table of numbers.  (Spreasheet String to Array).

    In a loop For, index with each issue of this table.  Use in the range and Coerce to see if it is in the range of numbers.  (You can put this in a loop For as auto good indexing through the ranges).  If it's in the range, then use subset replace table to activate the corresponding item in a real.  If this is not the case, do nothing.  Maintain the table of Boolean in a shift register.

    Repeat this step for each number in your table.

    (What is a class assignment?)

  • How to convert the string with numbers in U8 with ascii

    Hello

    I have a string with only numbers 0. 9 paper.

    Now, I want to convert to table-U8.

    He works here, but now the problem: How can I change each character to its ascii value?

    Example:

    entry: 123 (string)

    output: x 31, x 32, x 33 (U8-array)

    Thanks for the help

    It's very easy

    String to Byte Array Function
    Have the Palette: string/array/path Conversion functions

    Converts a string to an array of unsigned bytes. Each byte in the array has the ASCII value of the character corresponding to the string.

  • How do to convert the string (with the Hex data) in number?

    Hello

    I use TestStand 3.5 to automate a few test cases associated with boot loader.

    The requirement is that I need to read the value in some places for specific address. The values of these addresses are stored in a hexadecimal format.

    We have a step customized in TestStand through which we can read these values by address, but she returns as the type "String".

    For example, the value to 0 x 0000008 is 000001 B 2, and he returned in Locals.Value_Read as "000001 B 2" in the string.

    Is it possible, I can convert the string "000001 B 2" to a number?

    I tried to use the function-> val (locals. Value_Read), but it is return 0 as TestStand figures that the input string is not representing the valid number.

    Please help me with this.

    Thank you and best regards,

    Niraj.

    Try: Val ("0 x" + Locals.Value_Read)

  • How to convert numbers to the string with an optimal number of numbers?

    Hello.

    I'm doing something that seems just, and I wonder how much trouble I have with this.  I'm sure there is a way to get LabVIEW for this.

    I have a table of numbers (double), and I use the 'Worksheet picture String' function to generate a string that I can write to a file.

    The problem I have is I want to make the chain to omit useless zeros after the decimal point, but I don't want to limit the accuracy of the numbers that requires it.

    For example, if my data is as follows:

    0.02

    0.4476

    -0.0244570001

    I would like for the string I can be exactly like what I wrote above.  However, depeding on the format string that I use, that's what I get:

    format string: %.10f

    0.0200000000

    0.4476000000

    -0.0244570001

    format string: %f (it seems that by default 6 figures)

    0.020000

    0.447600

    -0.024457

    format string: %.4f

    0,0200

    0.4476

    -0.0244<= all="" trailing="" digits="" for="" this="" number="" have="" been="">

    Anyone know what the format string should be to get the string I want to (what is this

    0.02

    0.4476

    -0.0244570001

    Thanks in advance,

    Alejandro

    Hello Alejandro:

    Try %#f

Maybe you are looking for