PL/SQL Escape Characters?

I've built a procedure that displays a list using htp's. The procedure contains a call to this function:
FUNCTION "GET_JOBNAME"(p_jobid in varchar2)
RETURN VARCHAR2
AS
p_jname varchar2(100);
BEGIN
select job_title into p_jname from jobs where job_id = p_jobid ;
RETURN(p_jname);
END;
I cannot get this function to work correctly. I think it is primarily because p_jobid is a varchar and therefore should have single quotes around itself in the query. However if I put single quotes around p_jobid like this:
select job_title into p_jname from jobs where job_id = 'p_jobid' ;
Then the query will search for a job_id equal to p_jobid not what is actualy inside the variable. Is there any kind of escape character that will allow JDev to ignore the single quotes and send them to the query properly?
Thanks.
Joshua

Actually, it looks about right. Can you run this function directly from JDeveloper to test it? Right-click on the function and choose run, then supply a value for p_jobid, for example:
P_JOBID := 'AD_VP';
You should then see the result in the Log window. If this works, it points to the way the function is called as the problem, rather than the function itself.
Any error messages or more information/code about how you are calling the function would be helpful.
-- Brian

Similar Messages

  • Official documents on escaping characters in SQL Server query statements

    Hi,
    Are there any official documents on how to escaping special characters in SQL Server query statements? I find a lot of online resources discussing about this, but there are no definitive conclusions on:
    Which characters should be escaped? (Some only said single-quote needs to be escaped, double-quote does not need. While others said both need to be escaped)
    How to escape characters? (Some said using two single-quote to escape a single-quote. Others said using a backslash, etc.)
    So I just wonder if there is an official document from Microsoft regarding this?
    Thanks
    Alan

    Depends on where you're using them
    If its string values then single quotes(') should be escaped by putting one more single quote before it.
    If its LIKE operator you can use ESCAPE keyword or use [] to escapre special characters 
    see
    http://visakhm.blogspot.in/2013/01/wildcard-character-based-pattern-search.html
    If inside SSIS expression you can escape characters like \ " etc by adding an extra \ before the characters
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Escape characters for SQL

    Help me out here! i'm having a problem updating our database with this call:
    update table
    set name = 'dave's store'
    where id = '2';
    The problem of course is that single quote in the name. i've check many sites and have tired everything.
    -i have tried to escape the quote with a back (and forward!) slash, and nothing.
    -i have padded the quote with another single quite (ie ''), but that doesn't work.
    -i have have nearly all combinations of single and double quotes, with and without escape characters!
    according to the documention, just the blackslash so be fine! any one have this problem as well?
    any help would be greatly appreciated! thanks.

    Very related question.
    Is there a way to make sure that all 'weird' characters in an SQL statement are escaped properly before the statement is executed?
    I'm hoping that there is a method like this:
    Statement stmt = stmt.escapeAllBadChars();
    Is there such a method anywhere?
    I can't find it anywhere :(
    If not, is there a list of all 'bad characters' anywhere?
    Thanks,
    Otis
    null

  • How can I use escaped-characters in an option

    I have the following code that is used to retrieve city-names including parent-child relations from a database and place them in an array:
    <%@ page contentType="application/x-javascript" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <sql:setDataSource dataSource="jdbc/KADOS" var="Raak" scope="session" />
    <sql:query var="bewaringSQL" dataSource="${Raak}">
    SELECT bewaringcode, vestigingsplaats FROM BEWARING order by vestigingsplaats
    </sql:query>
    bewaringen = new Array(
    <c:forEach items="${bewaringSQL.rows}" var="plaats" varStatus="s" >
    new Array( "<c:out value="${plaats.BEWARINGCODE}" />",
    "<c:out value="${plaats.VESTIGINGSPLAATS}" />" )
    <c:if test="${not s.last}">,</c:if>
    </c:forEach>
    i=0;
    <c:forEach items="${bewaringSQL.rows}" var="plaats" varStatus="s" >
    <sql:query var="bewaringGemSQL" dataSource="${Raak}" sql="SELECT KADGEMCODE, KGMNAAM FROM KADGEMEENTE where BEWARINGCODE=? order by KGMNAAM">
    <sql:param value="${plaats.BEWARINGCODE}" />
    </sql:query>
    tmp = new Array(
    <c:forEach items="${bewaringGemSQL.rows}" var="gem" varStatus="s" >
    new Array( "<c:out value="${gem.KGMNAAM}" />",
    "<c:out value="${gem.KADGEMCODE}" />" )
    <c:if test="${not s.last}">,</c:if>
    </c:forEach>
    bewaringen[2] = tmp;
    i = i+1;
    </c:forEach>
    function bewaringenList(selectCtrl, itemArray) {
    for (i=0; i<itemArray.length; i++) {
    selectCtrl.options[i] = new Option(itemArray[i][1]);
    selectCtrl.options[i].value = itemArray[i][0];
    function setList(selectCtrl, itemArray) {
    for (i=selectCtrl.options.length; i>=0; i--) {
    selectCtrl.options[i] = null;
    for (i=0; i<itemArray.length; i++) {
    optie = filter(itemArray[i][0]);
    selectCtrl.options[i] = new Option(optie);
    selectCtrl.options[i].value = itemArray[i][1];
    function filter( invoer) {
    retour = invoer;
    retour = retour.replace("'", "\'");
    return retour;
    The function 'bewaringenList' populates a <SELECT> with parent-names and
    "setList(document.VraagForm.gemSelect, bewaringen[this.selectedIndex][2]);" populates the depending <SELECT> with child-names.
    Some names contain single quotes (like "&#039;t Zandt") and are displayd in the select-box as "&#039t Zandt".
    I expected that the quotes could be replaced by escape-characters by 'filter(invoer)' but this does not work.
    Is there a generic way to show these characters?
    Ben

    I don't understand why but this filter solved the problem:
    function filter( invoer) {
    retour = invoer;
    retour = retour.replace("&#039;", "'");
    return retour;

  • Setting escape characters for a MySQL insertion

    Hello all. I'm trying to format an incoming string with escaped characters so I can insert them into a mysql database... a quick rundown would be
    ' replaced with \'
    " replaced with \"
    escaping newline characters with the literal text "\n" (without quotes)
    escaping arriage return characters with the literal text "\r" (without quotes)
    for some reason it's not working out. Here's the method I made to handle it:
      public static String mysqlEncode(String stringToEncode) {
        String returnString = stringToEncode;
        // Replace " with \"
        if (returnString.matches("\\\"")) returnString = returnString.replaceAll("\\\"", "\\\"");
        // Replace ' with \'
        if (returnString.matches("'")) returnString = returnString.replaceAll("'", "\\'");
        // Replace \ with \\
        if (returnString.matches("\\\\")) returnString = returnString.replaceAll("\\\\", "\\\\");
        // Replace newlines with \n
        if (returnString.matches("\\n")) returnString = returnString.replaceAll("\\n", "\\n");
        // Replace carriage returns with \r
        if (returnString.matches("\\r")) returnString = returnString.replaceAll("\\r", "\\r");
        return returnString;
      }and it keeps bombing out , I'm on my 3rd hour at this and it's really starting to irk me...
    questions:
    are my regular expressions formed correctly?
    is that if statement calling the .matches() method necessary?
    Thanks so much for your help.

    String sql = "SELECT * FROM MyTable WHERE author = ? AND text = ?";
    PreparedStatement pstm = connection.prepareStatement(sql);
    synchronized(pstm){  // if you're doing multithreading stuff (if single thread..you can ignore the synchronized
        pstm.clearParameters();
        pstm.setString(1, "Anne Rice");    //  1 = the first question mark in the String sql
        pstm.setString(2, "The Vampire Lestat's long fangs");
    ResultSet res = pstm.executeQuery();
    while (res.next()){
    }same thing for INSERT, UPDATE, etc..

  • Escape characters using Oracle JDBC

    We use Oracle JDBC driver to do some operations on an Oracle 9i database, and ran into some problems with escape characters. Basically we'd like to escape the _ and % characters.
    The following two example statements both work:
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' escape '\\' ");
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' {escape '\\' }");
    However, when we have multiple query terms and the "escape" clause doesn't immediately follows EACH "like" clause, we got errors saying the sql statement does not end properly. One such example is the following:
    ResultSet rs = stmt.executeQuery("select * from identifier_protein where upper(IDENTIFIER_ACCNO) like 'NM\\_%' and creator = 'ABC' {escape '\\'} ");
    If we put an "escape" clause following each "like" clause, then it works.
    My question is, is there a smart way of letting JDBC knows that you want to use an escape character everywhere in the query? We often do very complicated dynamic queries, frequently with table joins and boolean logic and subqueries with tons of query terms. Trying to add the escape clause to each "like" clause is very painful. Any help is highly appreciated. Thanks!
    BL

    I'd use PreparedStatements, if you're not already. Let the JDBC driver escape things properly for you. That's what the setString() and setDate() methods are all about.

  • Issue with escaping characters and php

    Greetings,
    We are working on a web page using php and Oracle. We have troubles dealing with the diferent escaping characters when inserting/retrieving data (magic quotes is on but adding the backslash doesn't help :( ).
    We would like to know the correct way of dealing with those characters ( ' " / /n ...).
    Thank you in advance,
    Sincerely,
    Oriol Nonell

    Do NOT use addslashes/stripslashes to escape your queries. I use this function to do the escaping:
    function escapeSQL($string, $wildcard=false)
    $result = str_replace("'","''",$string);
    if ($wildcard == true) $result = str_replace("%","%%",$result);
    return $result;
    It basically replaces ' with ''.
    If you set $wildcard to false, then '%' is considered to be an actual '%' (for 'like' expressions). If you set it to true, a % is escaped to %% too.

  • Web Logic 10.3 upgrade causes issues with escaped characters in JSP.

    We recently upgraded our application servers from Weblogic 9.2 to Weblogic 10.3 and we are having an issue with escaped characters in a JSP code. Here is an example of what we are seeing:
    var convertedBody1 = document.getElementById('body').value.replace(/\$FIRST_NAME\$/g, firstName);
    This code works in Weblogic 9.2. In Weblogic 10.3 we have to make the following changes:
    var convertedBody1 = document.getElementById('body').value.replace(/\$FIRST_NAME\$/g, firstName);
    Thanks, Tom

    Hi:
    I have resolved the issue with the following in the jspx page.
    Put an
    <jsp:scriptlet>
    response.setContentType(“text/html; charset=UTF-8”);
    </jsp:scriptlet>
    Inside the <f:view> on the jspx file.
    Please refer the link http://www.oracle.com/global/il/support/tip/nlss11061.html for more details. It is helpful.
    Thanks & Regards
    Sridhar Doki

  • VLD-1141, Template cannot contain escape characters.

    Hi All,
    I need help about mapping deployment. I am working on a mapping. I can deploy it before to 9i target location. But after upgrading target database to 10g, I get the error VLD-1141 when I deploy it. The detail is Template cannot contain escape characters.
    And the full error message is as following:
    VLD-1141: Internal error during mapping generation.
    java.lang.IllegalArgumentException: Template cannot contain escape characters.
    at oracle.wh.util.expr.WBLiteralExpression.<init>(WBLiteralExpression.java:34)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformGenerationDelegate.addContextExpressionsForGroups(GenericTransformGenerationDelegate.java:345)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformGenerationDelegate.prepareOutputContextPlSql(GenericTransformGenerationDelegate.java:1433)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformPlSqlDelegate.prepareOutputContext(GenericTransformPlSqlDelegate.java:147)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:239)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleCursorLoopInternal(PlSqlGenerationMediator.java:3206)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleCursorLoop(PlSqlGenerationMediator.java:3190)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleRowBased(PlSqlGenerationMediator.java:3115)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assemble(PlSqlGenerationMediator.java:538)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:770)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:316)
    at oracle.wh.service.impl.mapping.generation.WBDeployableMappingGenerator.generate(WBDeployableMappingGenerator.java:99)
    at oracle.wh.service.impl.generation.common.WBGenerationService.generateCode(WBGenerationService.java:433)
    at oracle.wh.service.impl.generation.common.WBGenerationService.generateCode(WBGenerationService.java:311)
    at oracle.wh.service.impl.generation.service.WhValidationGenerationTransaction.run(WhValidationGenerationTransaction.java:241)

    There are to bugs:
    Bug 5403652 - ERROR 'TEMPLATE CANNOT CONTAIN ESCAPE CHARACTERS' WHEN VALIDATING A MAPPING
    Bug 5561224 - MIGRATION OF MAPPING REQUIRES CHANGE IN CONFIG TO ALLOW VALIDATION
    against OWB 10.2.0.1
    but these bugs are fixed from 10.2.0.2
    The bug is related to pre/post mapping operators...
    If you are on 10.2.0.3 or your mapping does not have these operators then have no clue...

  • Displaying unicode or HTML escaped characters from HTTPService in Flex components.

    Here is a solution on the Flex Cookbook I developed for
    displaying data in Flex components when the data comes back from
    HTTPService as unicode of HTML escaped data:
    Displaying
    unicode or HTML escaped characters from HTTPService in Flex
    components.

    Hi again Greg,
    I have just been adapting your idea for encountering
    occasional escaped characters within a body of "normal" text, eg
    something like
    hell&ocirc; sun&scaron;ine
    Now, the handy String.fromCharCode(charCode) call works a
    dream if instead of the above I have
    hell&#244; sun&#353;ine
    Do you know if there is an equivalent call that takes the
    named entities rather than the numeric ones? Clearly I can just do
    some text substitution to get the mapping, but this means rather
    more by-hand work than I had hoped. However, this is definitely a
    step in a useful direction for me.
    Thanks,
    Richard
    PS hoping that the web page won't simply outguess me and
    replace all the above! Basically, the first line uses named
    entities and the second the equivalent numbers...

  • What is the best NLS config to be near the ACCESS or SQL Server characters set

    Hi all,
    I am working with an Oracle for Windows.
    I have serious problems with my actual characters set.
    What is the best NLS config to be near the ms-Access or SQL Server characters set behavior ?
    For exemple :
    I have a table with city names
    I want to find the nearest >= city name of a given criteria. so i do this SQL
    SELECT Nom FROM TLCommune WHERE Nom >= 'LIMOGES' ORDER BY Nom, Pays, Dept, Insee
    This SELECT give this result under SQL plus worksheet (same via VB and ADO)
    Why the cities from krosno to Limerick are listed regarding on the WHERE clause Nom >= 'LIMOGES' ?
    NOM
    krosno
    La Manche et la Mer d'Irlande
    Laesv
    Lancashire
    Landes
    Lappi (Lappland)
    Latviya
    Legnica
    Leicester and Rutland
    Leipzig
    Leningrad
    NOM
    Leon
    Lirida
    Leszno
    Liberec
    Libiria
    Libye
    Limburg
    Limburg (Limbourg)
    Limerick
    LIMOGES <--------------------------------------- the city in the nom >= 'LIMOGES' in the SQL statement
    LIMOGES-FOURCHES

    Hi,
    Try these steps:-
    * Open the GUI of Root bridge
    Go to Security/SSID Manager/create SSid/map it to the radio
    * Under Client Authentication setting
    Check the box Open authentication with no Addition ..
    * Then click Apply
    * Go to Ecryption Manager page
    Under Ecryption Modes
    Select Cipher ---TKIP
    Under Encryption Keys
    Select Encryption Key 2 ------Don't put any key ... Leave the box blank and key size be 128bit
    Then click Apply
    * Come back to SSID Manager page
    Under Client Authenticated Key Management ..
    Select Key Management:- Mandatory
    Check the box:- WPA
    Under WPA Pre-shared Key:- Type atleast 8 character key..
    Click Apply:-
    * Then we need to repeat the same settings on Other bridge except the station role will be non-root.
    Now to troubleshoot...
    * First make Bridge are able to talk to each when there is on security setup
    * Set a simple Pre-shared Key ... example 1234567890 on both bridge .. Bridge will not associate if key mismatch..
    Hope this will work for you.

  • Bug in replace all. escape characters are not working.

    Hi,
    My requirement is that whenever i see ":" (Colon) in the string then i want to replace it with (\:). So i tried
    String escapedTitle = "title:the world is not enough".replace(":", "\\:")
    and to my surprise, when i printed escapedTitle i got
    title\\:the world is not enough
    instead of
    title\:the world is not enough
    (note the back slash in the string)
    I want to ask why there is a different beehavious of escape characters? I am using JDK1.6.0_06

    Sorry for the last post. Please try this:
    public class test
    public static void main(String a[])
         String escapedTitle = "title:the world is not enough".replaceAll(":+", "\\:"); //or [:]+
         String escapedTitle1 = "title:the world is not enough".replaceAll(":+", "*"); // or [:]+
         System.out.println("Another String is "+ escapedTitle);
         System.out.println("Another String is "+ escapedTitle1);
         System.out.println(System.getProperty("java.vendor"));
         System.out.println(System.getProperty("java.version"));
    output is
    Another String is title:the world is not enough
    Another String is titlethe* world is not enough
    Sun Microsystems Inc.
    1.6.0_06
    Please let me know why i am not getting : as escaped (\:) with replaceAll method.
    i want string escapedTitle as Another String is title*\:*the world is not enough

  • Validation - template cannot contain escape characters

    Hi all, im new to Warehouse builder, i find the documentation lacking, the tutorials lacking and i can't find any books on warehouse builder either. Am I stupid ? :-)
    Anyway, i've set up 3 constants (varchar2) to pass as parameter values to a function im calling and when i try to validate the mapping im getting 'Template cannot contain escape characters'.
    Then im getting validation completed successfully..however, when i try to deploy im getting this:
    VLD-1141: Internal error during mapping generation.
    java.lang.IllegalArgumentException: Template cannot contain escape characters.
    at oracle.wh.util.expr.WBLiteralExpression.<init>(WBLiteralExpression.java:34)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformGenerationDelegate.addContextExpressionsForGroups(GenericTransformGenerationDelegate.java:345)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformGenerationDelegate.prepareOutputContextPlSql(GenericTransformGenerationDelegate.java:1433)
    at oracle.wh.service.impl.mapping.component.transforms.GenericTransformPlSqlDelegate.prepareOutputContext(GenericTransformPlSqlDelegate.java:147)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:239)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleCursorLoopInternal(PlSqlGenerationMediator.java:3206)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleCursorLoop(PlSqlGenerationMediator.java:3190)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assembleRowBased(PlSqlGenerationMediator.java:3115)
    at oracle.wh.service.impl.mapping.generation.PlSqlGenerationMediator.assemble(PlSqlGenerationMediator.java:538)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:770)
    at oracle.wh.service.impl.mapping.generation.WBMappingGenerator.generate(WBMappingGenerator.java:316)
    at oracle.wh.service.impl.mapping.generation.WBDeployableMappingGenerator.generate(WBDeployableMappingGenerator.java:99)
    at oracle.wh.service.impl.generation.common.WBGenerationService.generateCode(WBGenerationService.java:433)
    at oracle.wh.service.impl.generation.common.WBGenerationService.generateCode(WBGenerationService.java:311)
    at oracle.wh.service.impl.generation.service.WhValidationGenerationTransaction.run(WhValidationGenerationTransaction.java:241)
    I have no clue whatsoever what this is about, can anyone tell ?

    hi ,
    I also got the same error when i migrated MDL from owb 9.2 version.
    I was using OWB 10.2.01, and heard that it is a bug which is fixed in owb 10.2.0.3
    So i applied the patch and this error gone.
    In case if it help u.
    rojo

  • Template cannot contain escape characters

    I created a database function which takes a varchar2 variable as input and passes back a number as output.
    I am using pre mapping process to call this function and I created a constant with the value I want to pass to this function. When I try to validate my mapping I am getting this error
    Template cannot contain escape characters.
    Why am i gettign this error any ideas as to how to fix this. I know for sure the join of the constant to the input mapping process is causing this error but my constant variable just has
    'xxxxx_xxxx' no other characters.
    Thanks

    Hi
    Are you using the 10.2.0.1 production release, I think this is bug 5403652. It should be fixed in a patch after (10.2.0.2 onwards), you could also try set based only code generation and see if this bypasses the problem (there is a comment in the bug indicating it is a row based code gen bug).
    Cheers
    David

  • Reading in/writing out escape characters from/to file

    I am trying to read in a large file which has many escape/special charaters (e.g. /, double quote (" ") etc.). I need to read them as they are and then write them out in a separate file as they were in the original file (e.g. if there was a double quote in the original file, I would have to keep the double quote in the output file)
    Now my question is: how can we tell the BufferedReader and FileWriter not to treat those characters to be escape characters?
    Thanks

    Now my question is: how can we tell the
    BufferedReader and FileWriter not to treat those
    characters to be escape characters?AFAIK, you don't need to do anything special. BR and FW already do that the right way.
    Did you try the standard approach?

Maybe you are looking for