PL/SQL: quoting problems (double quotes within PL/SQL, howto?)

Hello,
I have a big problem with that: I just cannot use execute immediate to do what I want.
The goal is that another user than sysdba needs to be able to open/close the wallet (we are sysdba and our client doesn't want us to be able to open the wallet, and we don't want the client to have sysdba), so I take advantage of the fact that procedures are executed by default with the privileges of the user which writes it. So, I try and create a PL/SQL procedure as sys and grant execute rights to the client user.
To open/close a wallet, the command is:
alter system set encryption wallet open/close identified by "thepasshere";
Note the double quotes... They are the problem here (passwords are mixed case and contain special characters). Right now, the only solution I came up with is:
create or replace procedure open_wallet (passwd in varchar2) is
begin
execute immediate 'alter system set encryption wallet open identified by "' || passwd || '";';
end;
But that's vulnerable to code injection... So, instead, I tried:
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar2(512);
begin
cmd != 'alter system set encryption wallet open identified by ":1"';
execute immediate cmd using passwd;
end;
which yields "ORA-00911: invalid character" - uh?
Now, if I try:
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar(512);
begin
cmd := 'alter system set encryption wallet open identified by :1;';
execute immediate cmd using passwd;
end;
it answers "ORA-28357: password required to open the wallet"
Aaargh! I see no way around that :(
Is there a solution at all?

Did you try including the double quotes in the password bind value? Either when you pass the value in or by adding it in the routine.
create or replace procedure open_wallet (passwd in varchar2) is
cmd varchar(512);
pass varchar(512);
begin
cmd := 'alter system set encryption wallet open identified by :1;';
pass := '"' || passwd || '"';
execute immediate cmd using pass;
end;

Similar Messages

  • How to replace single quote with double quote

    hai all,
    i have a problem,
    i am trying insert a string containing single quote into ms-access database.
    it is giving error.
    how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
    insert into database.
    in java.lang.String
    replace () will not work to replace quote with double quote.
    any otherway to solve this problem.
    please mail me to [email protected]
    thank you
    sambareddy
    inida

    java.lang.String.replace () will not work to replace quote with double quote.Really?
    String x = ...
    x.replace( "'", "\"" );

  • What 's the difference between quote ' and double quote "?

    what's the difference between quote' and double quote "?
    when we use each one?
    Exemple of use of each case?

    'c' is a char, ie. a primitive type representing a single character
    "c" is an instance of the String class length 1.

  • Problem with SQL statement - Missing double quote in identifier

    Hi
    I am unable to run the following query in TOAD.
    SELECT A.* FROM (SELECT VC.CAMPAIGN_NUMBER," +
                   "VC.CAMPAIGN_TITLE,VC.CAMPAIGN_DESC,VC.START_DATE,VC.END_DATE,VC.CAMPAIGN_TYPE,VC.APPLICABILITY," +
                   "VC.CAMPAIGN_PRIORITY FROM VM_CAMPAIGN VC WHERE VC.APPLICABILITY = 'Y' and VC.COUNTRY_CODE = ? " +
                   "and VC.LANGUAGE_CODE = ? AND VC.CAMPAIGN_TYPE = ? AND SYSDATE BETWEEN VC.START_DATE AND " +
                   "VC.END_DATE AND NOT EXISTS (SELECT 'X' FROM VM_CAMPAIGN_VIN VCV WHERE (VCV.VIN = ? AND " +
                   "VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER))UNION SELECT VC.CAMPAIGN_NUMBER,VC.CAMPAIGN_TITLE," +
                   "VC.CAMPAIGN_DESC,VCV.START_DATE,VCV.END_DATE,VC.CAMPAIGN_TYPE,VC.APPLICABILITY,VC.CAMPAIGN_PRIORITY " +
                   "FROM VM_CAMPAIGN_VIN VCV ,VM_CAMPAIGN VC WHERE VCV.VIN = ? AND " +
                   "VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER AND VC.COUNTRY_CODE = ? AND VC.LANGUAGE_CODE = ? AND " +
                   "VC.CAMPAIGN_TYPE = ? AND SYSDATE BETWEEN VCV.START_DATE AND VCV.END_DATE AND SYSDATE BETWEEN " +
                   "VC.START_DATE AND VC.END_DATE) A ORDER BY A.CAMPAIGN_PRIORITY DESC, A.END_DATE
    I am getting "Missing double quote in identifier"
    I am not sure how to rectify this SQL code. Any suggestions are welcome
    thanks in advance

    maybe this will work.
    SELECT A.*
      FROM (SELECT VC.CAMPAIGN_NUMBER,
                   VC.CAMPAIGN_TITLE,
                   VC.CAMPAIGN_DESC,
                   VC.START_DATE,
                   VC.END_DATE,
                   VC.CAMPAIGN_TYPE,VC.APPLICABILITY,
                   VC.CAMPAIGN_PRIORITY
              FROM VM_CAMPAIGN VC
             WHERE VC.APPLICABILITY = 'Y'
               And VC.COUNTRY_CODE =  '&country_code'
               And VC.LANGUAGE_CODE = '&language_code'
               AND VC.CAMPAIGN_TYPE = '&campaign_type'
               AND SYSDATE BETWEEN VC.START_DATE AND VC.END_DATE
               AND NOT EXISTS (SELECT 'X'
                                 FROM VM_CAMPAIGN_VIN VCV
                                WHERE (VCV.VIN = &VIN AND
                                       VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER))
            UNION
            SELECT VC.CAMPAIGN_NUMBER,
                   VC.CAMPAIGN_TITLE,
                   VC.CAMPAIGN_DESC,
                   VCV.START_DATE,
                   VCV.END_DATE,
                   VC.CAMPAIGN_TYPE,
                   VC.APPLICABILITY,
                   VC.CAMPAIGN_PRIORITY
              FROM VM_CAMPAIGN_VIN VCV,
                   VM_CAMPAIGN VC
              WHERE VCV.VIN = &VIN
                AND VCV.CAMPAIGN_NUMBER = VC.CAMPAIGN_NUMBER
                AND VC.COUNTRY_CODE = '&country_code'
                AND VC.LANGUAGE_CODE = '&language_code'
                AND VC.CAMPAIGN_TYPE = '&campaign_type'
                AND SYSDATE BETWEEN VCV.START_DATE AND VCV.END_DATE
                AND SYSDATE BETWEEN VC.START_DATE AND VC.END_DATE) A
    ORDER BY A.CAMPAIGN_PRIORITY DESC, A.END_DATE

  • SQL Loader: double quotes inside double quotes

    Hello,
    I need to find a solution for loading some data that contains double quotas. The csv contains data like:
    "1";"Name1";"Name2"
    "2";"Name3 "another thing here"";"Name4"
    "3";"Name33 "thing here"";"Name "name" Name"
    The data inside the " " must be loaded exactly as it is, that means that in the DB, for row2, column2 the data must be: Name3 "another thing here". I cannot remove the qoutes.
    the CTL:
    LOAD DATA
    CHARACTERSET AL32UTF8
    INTO table table_name
    APPEND
    FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
    TRAILING NULLCOLS
    Column1,
    Column2,
    Column3
    Could anyone help on this?

    try with this ctl
    LOAD DATA
    CHARACTERSET AL32UTF8
    INTO table table_name
    APPEND
    FIELDS TERMINATED BY ';' ENCLOSED BY '"'
    TRAILING NULLCOLS
    Column1,
    Column2,
    Column3
    )also refer to
    here and here
    for detailed explanations and instructions

  • String value changes single quote ' to double quote "

    I am creating a list with different bill codes within single
    quotes as follows
    <cfset corlist = " '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ' ">
    when I do an output
    for
    <cfoutput>AND idbillcode IN ( #corlist
    #)</cfoutput>
    I get the values as follows
    AND idbillcode IN ( '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ')
    However when I put the same string within a cfquery the
    single quotes get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800 '',''1950 '',''7001 '') which throws an error.
    Anybody has any clues.
    Thanks.

    However when I put the same string within a cfquery the
    single quotes
    get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800
    '',''1950
    '',''7001 '') which throws an error.
    Anybody has any clues.
    That is ColdFusion escaping the single quotes, by doubling
    them so that
    you can search for strings such as "singhpk's code does not
    work".
    (Note the single quote/apostrophe that would normally break
    this string
    if it was not escaped.
    To tell CF not to do this, one uses the
    preserveSingleQuotes() function.
    The documentation has all the details.

  • Change XML declaration from single quote to double quote

    Hi all,
    i have the following problem in my File Receiver Adapter. My XML File has the declaration <?xml version='1.0' encoding='utf-8'?> (With single quotes ') and want to change it to <?xml version="1.0" encoding="utf-8" ?> (With double quotes ")
    I use the XMLAnonymizerBean but this does not change the XML declaration.
    Any ideas how to change the declaration
    Thanks Max

    Hi Suraj,
    on the Modul Tab i have the following:
    1 | AF_Modules/XMLAnonymizerBean | Local Enterprise Bean | Anonymizer
    2 | CallSapAdapter                                | Local Enterprise Bean | 0
    Anonymizer | anonymizer.acceptNamespaces | http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Aviso_V1.0 ns0 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoHeader ns1 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoShipper ns2
    Anonymizer | anonymizer.quote                        | "
    That is all what i have on the module tab.
    I send the data as Text (not Binär). Thats all what i have in the adapter. Do you need any further information?
    Regards, Max

  • Replace Single Quote with double quote

    Hi All,
    I have a String s="help'me'to'replace";
    i want to replace single quote( ' ) in to double quote ( " )
    The final out put should be like this help"me"to"replace
    ( Actually this string i have to pass in to an XML )
    Please help any one

    s.replaceAll("'","\"");{code}
    or just one of the String#replace() methods.
    Edited by: sabre150 on Mar 17, 2009 11:48 AM                                                                                                                                                                                                                                                               

  • ReplaceAll() single quotes to double quotes

    i've been trying to use the replaceAll() method to change single
    quotes in a document to double quotes. All my attempts have
    failed.
    Thanks in advance,
    Enaknonnel

    Sorry, I was terse in my first post, but since you are just replacing one char
    with another, using replaceAll is overkill -- it is meant to take a regular expression
    search string. So keep it simple and use replace. I think you may have
    chosen replaceAll because of that reassuring "All" in its name, but do check
    the API: method replace replaces all occurrences.
    One more thing: posting something like "All my attempts have failed" is itself
    a failure. It tells us nothing concrete. A better post would have included
    a short example program that was your best attempt.

  • To display combination of single quotes and double quotes in textfield

    please send the code

    Do this:
    //put this into the head section
    <head>
    <script language="JavaScript">
    <!--
    function input(value){
    document.getElementById('textfield').value = value;
    //-->
    </script>
    </head>
    //put this into the body section
    <body>
    <input type="text" name="textfield" id=textfield value="">
    <br>
    input quotes for whatever reason
    </body>
    //read the following tread:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=136985

  • SQL Server Problems and Questions from an SQL dummy

    I am an SQL Dummy!
    In the old 2008 version of SQL I had to run a script to fix a rounding error in my Microsoft Accounting software (no longer supported)  I think I have version 10 now?
    SQL FIX for Fiscal Year won't close
    Need to use Sql Management Studio (as oppose to more obscure osql.exe)
    to run sql script
    b) Use Sql Management Studio to execute script below:
    SELECT *
    FROM dbo.CashPostingTable
    WHERE (amountcredit <> amountCreditCompanyCurrency OR amountDebit <>
    amountDebitCompanyCurrency) AND exchangeRate=100
    If you get any rows/data back, proceed to step c), if no result, a more
    serious problem - good lucks or buy help.
    c) Use Sql Management Studio to execute script below:
    UPDATE cashpostingtable
    SET amountCreditCompanyCurrency = amountCredit,
    amountDebitCompanyCurrency = amountDebit,
    companyAmountRemainder = accountAmountRemainder
    WHERE (amountcredit <> amountCreditCompanyCurrency OR amountDebit <>
    amountDebitCompanyCurrency) AND exchangeRate=100
    Management Studio no longer works.  Is there a way to do the same thing in the version I have?
    Thank you,
    Dean

     I am an SQL Dummy!
    In the old 2008 version of SQL I had to run a script to fix a rounding error in my Microsoft Accounting software (no longer supported)  I think I have version 10 now?
    SQL FIX for Fiscal Year won't close
    Need to use Sql Management Studio (as oppose to more obscure osql.exe)
    to run sql script
    b) Use Sql Management Studio to execute script below:
    SELECT *
    FROM dbo.CashPostingTable
    WHERE (amountcredit <> amountCreditCompanyCurrency OR amountDebit <>
    amountDebitCompanyCurrency) AND exchangeRate=100
    If you get any rows/data back, proceed to step c), if no result, a more
    serious problem - good lucks or buy help.
    c) Use Sql Management Studio to execute script below:
    UPDATE cashpostingtable
    SET amountCreditCompanyCurrency = amountCredit,
    amountDebitCompanyCurrency = amountDebit,
    companyAmountRemainder = accountAmountRemainder
    WHERE (amountcredit <> amountCreditCompanyCurrency OR amountDebit <>
    amountDebitCompanyCurrency) AND exchangeRate=100
    Management Studio no longer works.  Is there a way to do the same thing in the version I have?
    Thank you,
    Dean

  • Problems parsing double quote

    I have been trying to figure out my problem for several hours, but still didn't get it. Hope to get an idea from you guys. My code is as follows:
    var astr;
    var outCr ="|";
    var outLf = "\u0000";
    var cr = "\n";
    var lf ="\r";
    var ddQuote=""";
    var dtQuote='\"';
    astr = "<%=firstDesc%>";
    astr.replace(outCr,cr);
    astr.replace(outLf,lf);
    astr.replace(ddQuote, dtQuote);
    while (astr.indexOf(outCr) > 0) {
    z = astr.indexOf(outCr);
    astr = astr.substring(0, z) + cr + astr.substring(z+1,astr.length );
    while (astr.indexOf(outLf) > 0) {
    z = astr.indexOf(outLf);
    astr = astr.substring(0, z) + lf + astr.substring(z+1,astr.length );
    while (astr.indexOf(ddQuote) > 0) {
    z = astr.indexOf(ddQuote);
    astr = astr.substring(0, z) dtQuote astr.substring(z+1,astr.length );
    document.form1.description.value=astr;
    The value of firstDesc is a very big string from the database that contains carriage return, linefeed, single quote and double quote. It needs to be displayed in a HTML text area. Now everything works fine except the double quote. A firstDesc value containing double quote will not appear in the text area, and it even stop my jsp page and disable other buttons. But if I get rid of the code handling the double quote, everything works fine. What's the problem?

    maybe you should ask this question in a JavaScript forum.

  • Can't import csv fields starting with double quotes but lack ending ones

    Hi all,
    When I'm trying to used external table to import a csv file, specified as using comma as delimiter optionally enclosed by double quotes, some records are rejected because a field in the record has starting double quotes, but without ending ones.
    Assume the customer really want these starting double quotes, how do I change my external table specification such that these starting double quotes are treated as part of the field data and can be successfully inserted into db?
    Many thanks.

    I have no access to Oracle during weekends, so nothing can be tested. So here it goes:
    Suggestion: DELIMITED BY '","' and of course omitt ENCLOSED BY '"'
    You will have to update each row of the rows just loaded setting the first_field to substr(first_field,2) and the last_field to substr(last_field,-2)
    If all the fields are not enclosed in double quotes (TRUE for strings and FALSE for numbers and dates) the situation (syntax diagrams allow two delimiters only) is somehow more complicated, anyway you can specify DELIMITED BY ',' and update all varchar2 fields in each row of the rows just loaded setting the varchar2_field to substr(varchar2_field,2,length(varchar2_field) - 2).
    Regards
    Etbin
    After posting I noticed it's difficult to distinguish between single and double quotes:
    the first DELIMITED BY should read {single quote){double quote}{comma}{double quote}{single quote)
    the ENCLOSED BY should read {single quote){double quote}{single quote)
    Message was edited by: Etbin
    user596003

  • Single to double quotes

    I'm looking for a GREP (or maybe a script) which can change the single quotes to double quotes, but taking into account that French (and Dutch) have a lot of single quotes that don't have to be converted (collega's; l'enfant;d'été...). The idea is that some people use the single quotes in stead of the double ones ('lorem ipsum daedalus inter e d'été', etc). the quote before lorem has to be changed, not the ' after the letter d, and the ' after été has to be changed too.
    Any suggestions?

    This seems to work:
    '(?![\l\u])|(?<![\l\u])'
    For my test, I turned all found items to red.

  • Can I quote a single quote character so that I can use it in Replace()

    Hi. How can I quote a single quote character so that I can use it in the Replace() function below. I'm attempting to query first_name records that contain a '.
    select first_name, last_name
    from ttms.prospect
    where instr(first_name,"'") > 0
    ERROR at line 3:
    ORA-00904: "'": invalid identifier

    Hi,
    String literals are enclosed in single-quotes (not double-quotes).
    To use a single-quote within a string literal, use two of them:
    WHERE   INSTR (first_name, '''') > 0In Oacle 10 (and up) you can also use Q-Notation:
    WHERE   INSTR (first_name, q'[']') > 0but you may find this more confusing for short literals containing only one single-quote.
    Edited by: Frank Kulash on Mar 11, 2009 4:52 PM

Maybe you are looking for