Quote in a  concatenated query

Hi ALL,
I am not thinking straight here. Is anyone out there to help ?. if I want to create a temp collection with the following query, with a character field ( :P_name) how do I get around this single quote issue ? If typed in KING the error is ORA-00904: "KING": invalid identifier
if I put quote around KING then it is OK.
Thanks
Zeng
l_query :='SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO FROM EMP A WHERE A.ENAME = ';
r_query :=' ORDER BY A.EMPNO';
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B
'TEST_EMP', l_query || :P_ENAME || r_query
end;

That won't work - you'll encounter a syntax error.
You could try this (although frankly, it's even uglier than my original suggestion):
l_query :='SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO FROM EMP A WHERE A.ENAME = '''||:itemname||'''';
Yuck...
Alternatively, if you want to go completely crazy, you could try using the q function, like so:
l_query :=q'^SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO FROM EMP A WHERE A.ENAME = '^'||:itemname||q'^'^';Yikes!

Similar Messages

  • How do you "quote" from someone's query?

    I would like to know how you guys copy parts of someone's narrative and then include it when you respond to a problem or question.
    I've copied and pasted before, but it doesn't look the same as when you folks do it.
    No biggie here. Would just like to know how you do it.

    Your contacts should list whether someobody is your mum or not. That's how Siri knows.
    Check your contacts and edit the ones you don't want

  • Single quote in the query

    Hi,
    I am inserting a string literal that contains one or more single quotes. I know i have to use two single quote ('') to represent one single quote in my insert query and four single quotes('''') to show two single quotes. However, when i do a select from the table, all single quotes are escaped with a backslash in front of it (\'). This cause some problem when i display the string in html page. How can i skip the back slash and keep only the single quote in my select query? Thanks
    Kim Titu

    Kim,
    To insert single quote or double quote string try using the ascii values as below -
    CHR(34) ==> " (double quote)
    CHR(39) ==> ' (single quote)
    Example:
    Insert into emp(EMPNAME) values(CHR(39)||'TEST'||CHR(39));
    Now,
    Select EMPNAME from emp;
    will give you the result - 'TEST'
    Regards,
    Murali Mohan

  • How to construct a sql query when field having single quote

    Hi all,
    I have been working on web application , here is my requirement:
    I'm constructing sql statement dynamically from dynamic user input (form data). In one of the field having single quote.
    while executing the query it is getting problem because of single quote .. so how do i resolve my problem.
    single quote should be there. (I'm using Ms-Access as my database).
    Thanks in advance
    abel

    Use PreparedStatement. Always. It not only eases setting Java objects in a SQL query, but also protects you against SQL injections.
    Prepare yourself: [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html].

  • Error while querying plsql table.

    create table emp(eno number, ename varchar2(20), sal number(10,2), dno number);
    create table dept(dno number, dname varchar2(10));
    DECLARE
    TYPE EmpTabTyp1 IS TABLE OF emp%ROWTYPE INDEX BY BINARY_INTEGER;
    emp_tab1 EmpTabTyp1;
    l_str_name varchar2(20);
    begin
    select eno, ename, sal bulk collect into emp_tab1 from emp;
    select et1.ename into l_str_name from dept dp , TABLE(CAST(emp_tab1 EmpTabTyp1)) et1 WHERE dp.dno = et1.dno
    end;
    Getting below error:
    ERROR at line 8:
    ORA-06550: line 7, column 131:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 7, column 3:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 8, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
    following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted de
    Thanks,
    Vinodh

    ora_1978 wrote:
    create table emp(eno number, ename varchar2(20), sal number(10,2), dno number);
    create table dept(dno number, dname varchar2(10));
    DECLARE
    TYPE EmpTabTyp1 IS TABLE OF emp%ROWTYPE INDEX BY BINARY_INTEGER;
    emp_tab1 EmpTabTyp1;
    l_str_name varchar2(20);
    begin
    select eno, ename, sal bulk collect into emp_tab1 from emp;
    select et1.ename into l_str_name from dept dp , TABLE(CAST(emp_tab1 EmpTabTyp1)) et1 WHERE dp.dno = et1.dno
    end;
    Getting below error:
    ERROR at line 8:
    ORA-06550: line 7, column 131:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 7, column 3:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 8, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
    following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted deThanks,
    VinodhYou cant query a PL/SQL table. You can query only a collection database object that is created and stored in the database.
    A simple reason is that PL/SQL code is processed by different engine and SQL code is processed by different engine. And your PL/SQL table is local to the PL/SQL code and is not available for the SQL engine.
    Edited by: Karthick_Arp on Apr 19, 2012 6:14 AM

  • Quote in contains() literal

    Hi All,
    Sure I'm missing something, but I'm having a problem
    with specifying a double and single quote in literal in
    query like this:
    select e.extract('/experimentDocument/data/rawData/fileDscr/notes/HTML/
    BODY/P/text()') from EXPDOC e where
    existsNode(value(e),'/experimentDocument/data/rawData/fileDscr/notes/HTML/
    BODY/P[contains(.,"note")]') = 1;
    The abovementioned query yelds the correct result which is:
    E.EXTRACT('/EXPERIMENTDOCUMENT/DATA/RAWDATA/FILEDSCR/NOTES/HTML/BODY/P/TEXT()')
    There is "note" space available for each file description.
    The question is: how to specify an literal, which already contains a double or single quotation mark? In my case what if I'm searching for the text: <There is "note" space>?
    I was not be able to find anything in doc
    and in XPath spec on this metter. Note, that changing double quote separator to single qoute in contains(.,'some text') does not work because it interferes with
    single quote separator in outer expression.
    Another related question: which characters are special inside such a string literal in contains() function and hence should be treated specially? My experiments shows that standard entity like <&><quot><;> does not work.
    Any help would be appreciated.
    Thanks in advance
    Boris

    Post Author: Manuel de Kleine
    CA Forum: Formula
    Chris,You could use single quotes:IF ... = '3/16" White' THEN '4001 - Foamcore Mounting'

  • JDBC receiver adapter for AS400-query time out due to Escape Symbol

    Hello,
    I am uisng JDBC receiver adapter for AS 400, When I execute query, the query needs to have arguments in the open and close single ticks ('    12345' )
    My XML pay load looks like this, which is RFC sender. Look at dcudcstmr in <i><b>(' 838912')</b></i>.  When receiver gets this message the ' (single quotes are disappeared.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns1:MT_Cma_Customer_Select_Request xmlns:ns1="http://freemanco.com/xi/Get_Customer">
    - <Statement>
    - <LawsonCustomer action="SQL_QUERY">
      <access>select f1.DACMCMPNY from sap.sapcustvew f1, sap.sapcustvew f2 where f2.dcudcstmr in <i><b>(' 838912')</b></i> and (f1.dcudcstmr=f2.dcudcstmr or f2.komaster=f1.dcudcstmr)</access>
      </LawsonCustomer>
      </Statement>
      </ns1:MT_Cma_Customer_Select_Request>
    On the Receiver JDBC adapter I have tried with different combinations of Escape Symbol for Aposrophe as follows
    <b>   \
       '</b>
    As you know this is related to epcape character, I get following error all the time. Looks like the query is not able to execute in the specified time. My question is how do I get single quote as part of query.
    <b>select f1.DACMCMPNY from sap.sapcustvew f1, sap.sapcustvew f2 where f2.dcudcstmr in ( 100001) and (f1.dcudcstmr=f2.dcudcstmr or f2.komaster=f1.dcudcstmr) 2007-09-20 15:56:42 Error Unable to execute statement for table or stored procedure. 'LawsonCustomer' (Structure 'Statement') due to java.sql.SQLException:
    [SQL0666] Estimated query processing time 13766 exceeds limit 8000. 2007-09-20 15:56:42 Error MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'LawsonCustomer' (structure 'Statement'): java.sql.SQLException:
    [SQL0666] Estimated query processing time 13766 exceeds limit 8000. 2007-09-20 15:56:42 Error Exception caught by adapter framework: Error processing request in sax parser: Error when executing statement for table/stored proc. 'LawsonCustomer' (structure 'Statement'): java.sql.SQLException:
    [SQL0666] Estimated query processing time 13766 exceeds limit 8000. 2007-09-20 15:56:42 Error Delivery of the message to the application using connection JDBC_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'LawsonCustomer' (structure 'Statement'): java.sql.SQLException:
    [SQL0666] Estimated query processing time 13766 exceeds limit 8000.. Setting message to status failed. 2007-09-20 15:56:42 Error The message status set to FAIL. 2007-09-20 15:56:42 Error Returning synchronous error message to calling application: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'LawsonCustomer' (structure 'Statement'): java.sql.SQLException:
    [SQL0666] Estimated query processing time 13766 exceeds limit 8000</b>
    Any feedback or helpfull tips appreciated.
    Thank you,
    Balaji

    Raj,
    Thank you for the reponse. I am using UDF on sender to generate sql statement as you see in sender XML message. After the message reaching receiver, gets executed but no response from AS400 becasue of missing single quotes in the sql query executed.
    Sender XML sends
    <access>select f1.DACMCMPNY from sap.sapcustvew f1, sap.sapcustvew f2 where f2.dcudcstmr in <u><b>(' 838912')</b></u> and (f1.dcudcstmr=f2.dcudcstmr or f2.komaster=f1.dcudcstmr)</access>
    Receiver executes as
    select f1.DACMCMPNY from sap.sapcustvew f1, sap.sapcustvew f2 where f2.dcudcstmr in ( <b><u>838912</u></b>) and (f1.dcudcstmr=f2.dcudcstmr or f2.komaster=f1.dcudcstmr)
    As you see the single quotes are missing. Like I said in previous posting I tried with following Escape Symbol for Aposrophe.
    Let me know if you need more information.
    Thank you,
    Balaji

  • Error Executing Database Query (Encountered [nullstring])

    The attached code gives the following error message. I did
    have nullstrings being submitted as the "notes" and "internal
    notes," but I removed them in an (unsuccessful) attempt to solve
    this problem. Can this be fixed? Thanks!
    quote:
    Error Executing Database Query.
    Syntax error: Encountered "" at line 9, column 43.
    The error occurred in
    C:\ColdFusion8\wwwroot\Example\init.cfm: line 6
    4 : </head>
    5 : <body>
    6 : <CFQUERY NAME="init" DATASOURCE="Example">
    7 : CREATE TABLE programs(
    8 : ID int,
    SQLSTATE 42X01
    SQL CREATE TABLE programs( ID int, program_ID int, name
    varchar(20), long_name varchar(50), creator_email varchar(50),
    notes varchar(50), internal_notes varchar(50), is_public bool );
    INSERT INTO programs( ID, program_ID, name, long_name,
    creator_email, is_public ) VALUES( 0, 1, "Basic", "Basic
    (pre-selected)", "[email protected]", true ); SELECT * FROM
    programs;
    VENDORERRORCODE 30000
    DATASOURCE Example
    Resources:
    * Check the ColdFusion documentation to verify that you are
    using the correct syntax.
    * Search the Knowledge Base to find a solution to your
    problem.
    Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
    rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
    Remote Address 127.0.0.1
    Referrer
    Date/Time 20-Feb-08 11:53 PM
    Stack Trace
    at
    cfinit2ecfm949254281.runPage(C:\ColdFusion8\wwwroot\Example\init.cfm:6)
    at
    cfinit2ecfm949254281.runPage(C:\ColdFusion8\wwwroot\Example\init.cfm:6)
    [ginormous Java stacktrace omitted]

    I whittled my SQL down to the first query and added the
    transaction block, but the error remains. Thanks for your time!
    quote:
    Error Executing Database Query.
    Syntax error: Encountered "" at line 9, column 51.
    The error occurred in
    C:\ColdFusion8\wwwroot\Example\init.cfm: line 7
    5 : <body>
    6 : <CFTRANSACTION>
    7 : <CFQUERY NAME="init" DATASOURCE="Example">
    8 : CREATE TABLE programs(
    9 : ID int,
    SQLSTATE 42X01
    SQL CREATE TABLE programs( ID int, program_ID int, name
    varchar(20), long_name varchar(50), creator_email varchar(50),
    notes varchar(50), internal_notes varchar(50), is_public bool );
    VENDORERRORCODE 20000
    DATASOURCE Example
    Resources:
    * Check the ColdFusion documentation to verify that you are
    using the correct syntax.
    * Search the Knowledge Base to find a solution to your
    problem.
    Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
    rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
    Remote Address 127.0.0.1
    Referrer
    Date/Time 22-Feb-08 10:02 AM
    Stack Trace
    at
    cfinit2ecfm949254281.runPage(C:\ColdFusion8\wwwroot\Example\init.cfm:7)
    at
    cfinit2ecfm949254281.runPage(C:\ColdFusion8\wwwroot\Example\init.cfm:7)

  • Change query dynamically in DB Adapter

    Hi,
    Please answer these questions.
    1. How to change query dynamically in DB Adapter?
    2. I have 2 db adapters, if i got error in 1 db adapter then how to rollback?
    Regards,
    kpr

    Hi,
    <div class="jive-quote">How to change query dynamically in DB Adapter?</div>
    Unfortunately there is no way to pass the query dynamically in DB Adapter. The reasoning behind that is that the DB adapter configuration wizard creates multiple assist files for each operation including the xsd which can not be created for any query dynamically.
    <div class="jive-quote">I have 2 db adapters, if i got error in 1 db adapter then how to rollback?</div>
    Either use XA datasources or throw a rollback fault in the catch block.
    Regards,
    Neeraj Sehgal

  • I need to know the proper syntax for my SELECT query, please.

    Hello All,
    Quick one for you:
    Let's say that I have several columns in a table with names such as subject_1, subject_2, subject_3, etc. The table's name is subject_names.
    The number in each of the three column name examples is also a value passed along a query string, the user can select choices, 1, 2 or 3. That query string's variable is $qs.
    So, what I want is a SELECT query that uses the query string value as follows (KEEP IN MIND, I know this is not the proper syntax):
    "SELECT subject_[$qs]
    FROM subject_names";
    I have tried all sorts of cominations of quotes (single and double), dots, brackets, braces and parenthesis. I just want to know how to include such a variable within this code.
    Any and all help is sincerely appreciated!
    Cheers,
    wordman

    Well, I did give you the syntax though.
    $query = 'SELECT ' . $qs . ' FROM tbl_name';
    I put spaces between the periods this time to make it more clear.
    If you put the actual word 'subject' in there and just want your form to name it's options as the numbers available you could do this:
    $query = 'SELECT subject_' . $qs . ' FROM tbl_name';
    In PHP you can use either single or double quotes around your query string, I always just use single quotes. I see a lot of other use double quotes.
    Double quotes would look like:
    $query = "SELECT subject_' . $qs . ' FROM tbl_name";
    Or when using double quotes you can actually just place the variable right in the string without having to concatenate multiple strings like above.
    Since you mentioned that you are good with passing variables I probably don't have to mention that you need to set the value attribute of your option tags (if you are using a select) to the value you want them to pass.
    Ex:
    <select name="choices">
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
    </select>
    If you have that part all figured out then you can use the syntax above for your query string.
    Good luck.

  • Data pump using table query

    I am trying to perform a data pump export on a table using a query within a parfile and I am getting some odd behaviour. The database version is 10.2.0.4.3 and the OS is AIX 5.3. The query looks like this.
    QUERY="POSDECLARATIONQUEUE:where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' and 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252')"
    This works but gets 0 rows. If I run the query against the instance in an SQLPlus session as below then I get 0 rows returned.
    select * from POSDECLARATIONQUEUE where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' AND 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252');
    If I take out the single quotes from around the columns within the query against the instance within SQLPlus, I get over 2000 rows returned.
    SQL> select count(*) from POSDECLARATIONQUEUE where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and A.SITE = 10252);
    COUNT(*)
    2098
    If I remove the single quotes from the parfile query then I get the following error within the data pump export.
    UDE-00014: invalid value for parameter, 'schemas'.
    The SCHEMAS option is not specified within the parfile and the TABLES option only specifies the table POSDECLARATIONQUEUE.
    Can someone assist with this, I just can't seem to be able to get the syntax right for it to work within data pump.
    Kind Regards.
    Graeme.
    Edited by: user12219844 on Apr 14, 2010 3:34 AM

    It looks like your query might be a little wrong:
    This is what you have:
    QUERY="POSDECLARATIONQUEUE:where SESSIONID in (select 'B.SESSIONID' from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where 'B.SESSIONID' = 'C.ID' and 'C.ACCOUNTID' = 'A.ID' and 'A.SITE' = '10252')"
    This is what I would have thought it should look like:
    QUERY=POSDECLARATIONQUEUE:"where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and A.SITE = 10252)"
    You want double " arount the complete query, and you don't need the single ' around all of the =. The single ' are treating those values as strings and it says
    'B.SESSIONID' = 'C.ID'
    is the string B.SESSIONID equal to the string C.ID
    In your query that you used in sql was
    B.SESSIONID = C.ID
    which says is the value stored B.SESSIONID equal to the value stored at C.ID
    Which is what you want.
    Dean

  • Query to find the maximum and second maximum

    i have a table temptab of 3 columns
    col1 col2 col3
    1 a 08-JAN-08
    1 a 09-JAN-08
    1 a 10-JAN-08
    1 b 10-JAN-08
    1 c 11-mar-08
    1 c 10-mar-08
    i want to select 1st maxm and 2nd maxm of col3 group by (col1,col2)
    o/p will be like
    1 a 10-jan-08 08-jan-08
    1 b 10-jan-08 null
    1 c 11-mar-08 10-mar-08
    select first.col1, first.col2, first.MAX_DATE, second.SEC_DATE from (select a.col1, a.col2, max(a.col3) as MAX_DATE
    from tab1 a group by a.col1, a.col2) first,
    (select b.col1, b.col2, max(b.col3) as SEC_DATE from tab1 b,
    (select a.col1, a.col2, max(a.col3) as MAX_DATE from tab1 a
    group by a.col1, a.col2) c
    WHERE c.col1 = b.col1
    AND c.col1=b.col1
    AND c.MAX_DATE > b.col3
    group by b.col1, b.col2) second
    where first.col1 = second.col1
    and first.col2 = second.col2;
    this is not working..
    please give a query which will do this.

    1. Your query have 3 subqueries where mine only one. Feel free to make your choice regarding the performance.
    2. You cannot have a column named date, unless you use double-quotes
    3. Your query doesn't work as well when you have not any second highest value
    4. Your query return a cartesian product of your table.
    Please check the results of your query (after applying the required modications) with the mine above, and make your choice :
    SQL> with tbl as
      2  (select 1 col1, 'a' col2, to_date('08-JAN-08','DD-MON-YY') col3 from dual union all
      3   select 1 col1, 'a' col2, to_date('09-JAN-08','DD-MON-YY') col3 from dual union all
      4   select 1 col1, 'a' col2, to_date('10-JAN-08','DD-MON-YY') col3 from dual union all
      5   select 1 col1, 'b' col2, to_date('10-JAN-08','DD-MON-YY') col3 from dual union all
      6   select 1 col1, 'c' col2, to_date('11-mar-08','DD-MON-YY') col3 from dual union all
      7   select 1 col1, 'c' col2, to_date('10-mar-08','DD-MON-YY') col3 from dual )
      8  --end of data sample
      9  select t1.col1 ,t1.col2 ,t1.col3,t2.col3
    10  from (select col1,col2,max(col3) col3
    11        from tbl
    12        group by col1,col2 ) t1,
    13       (select col1, col2, col3
    14        from (select col1, col2, col3,
    15                     row_number() over (partition by col1, col2 order by col3 desc) rn
    16              from tbl)
    17       where rn <= 2) t2
    18  where t1.col3 !=t2.col3;
          COL1 C COL3            COL3
             1 c 11-MAR-08       10-JAN-08
             1 a 10-JAN-08       09-JAN-08
             1 b 10-JAN-08       09-JAN-08[i] <-- obviously wrong, there is no 09-JAN-08 for 1b
             1 c 11-MAR-08       09-JAN-08[i] <-- obviously wrong, there is no 09-JAN-08 for 1c
             1 c 11-MAR-08       10-JAN-08[i] <-- obviously wrong, there is no 10-JAN-08 for 1c
             1 a 10-JAN-08       11-MAR-08[i] <-- obviously wrong, there is no 11-MAR-08 for 1a
             1 b 10-JAN-08       11-MAR-08[i] <-- obviously wrong, there is no 11-MAR-08 for 1b
             1 a 10-JAN-08       10-MAR-08[i] <-- obviously wrong, there is no 10-MAR-08 for 1a
             1 b 10-JAN-08       10-MAR-08[i] <-- obviously wrong, there is no 10-MAR-08 for 1b
             1 c 11-MAR-08       10-MAR-08[i] <-- obviously wrong, duplicate row
    10 rows selected.Nicolas.

  • Stacking quotes - need another pair of eyes

    Oracle 11.2.0.1 SE-One, 64-bit
    Oracle Linux 5.6 x86-64
    Given the following procedure, and focusing on the call to dbms_scheduler
    create or replace
    PROCEDURE dw.fix_job_timezone(
        p_jobschema_in IN VARCHAR2 default null)
    IS
    type sched_jobs_tbl_type
    IS
      TABLE OF dba_scheduler_jobs.job_name%TYPE INDEX BY binary_integer;
      t_sched_jobs sched_jobs_tbl_type;
      v_job          VARCHAR2(128);
    BEGIN
      SELECT
        job_name
      bulk collect INTO
        t_sched_jobs
      FROM
        dba_scheduler_jobs
      WHERE
        owner = p_jobschema_in
      ORDER BY
        job_name ;
      FOR i IN t_sched_jobs.first .. t_sched_jobs.last
      LOOP
        v_job := '"' || p_jobschema_in || '"."'||t_sched_jobs(i) || '"';
        dbms_output.put_line('Processing '||v_job);
        dbms_scheduler.set_attribute_null (v_job, 'START_DATE'); 
      END LOOP;
    END;If the owner of the above procedure connects and calls dbms_scheduler directly:
    SQL> show user
    USER is "DW"
    SQL> exec DBMS_SCHEDULER.set_attribute_null ('"ESTEVENS"."EDS_SQLNAV_JOB1"', 'ST
    ART_DATE');
    PL/SQL procedure successfully completed.Yet, when calling the above procedure:
    SQL> exec dw.fix_job_timezone('ESTEVENS');
    Processing "ESTEVENS"."EDS_SQLNAV_JOB1"
    BEGIN dw.fix_job_timezone('ESTEVENS'); END;
    ERROR at line 1:
    ORA-27486: insufficient privileges
    ORA-06512: at "SYS.DBMS_ISCHED", line 4398
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2892
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 3028
    ORA-06512: at "DW.FIX_JOB_TIMEZONE", line 78
    ORA-06512: at line 1
    SQL>Maybe a problem with the enclosing quotes, or lack of?
    Change the key line to
    dbms_scheduler.set_attribute_null ('v_job', 'START_DATE');  And we get
    SQL> exec dw.fix_job_timezone('ESTEVENS');
    Processing "ESTEVENS"."EDS_SQLNAV_JOB1"
    BEGIN dw.fix_job_timezone('ESTEVENS'); END;
    ERROR at line 1:
    ORA-27476: "DW.V_JOB" does not exist
    ORA-06512: at "SYS.DBMS_ISCHED", line 4398
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2892
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 3028
    ORA-06512: at "DW.FIX_JOB_TIMEZONE", line 78
    ORA-06512: at line 1Or
    dbms_scheduler.set_attribute_null ('''||v_job||''', 'START_DATE');  And get
    SQL> exec dw.fix_job_timezone('ESTEVENS');
    Processing "ESTEVENS"."EDS_SQLNAV_JOB1"
    BEGIN dw.fix_job_timezone('ESTEVENS'); END;
    ERROR at line 1:
    ORA-27452: '||v_job||' is an invalid name for a database object.
    ORA-06512: at "SYS.DBMS_ISCHED", line 4398
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2892
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 3028
    ORA-06512: at "DW.FIX_JOB_TIMEZONE", line 78
    ORA-06512: at line 1
    dbms_scheduler.set_attribute_null ('v_job', 'START_DATE'); 
    And getERROR at line 1:
    ORA-27476: "DW.V_JOB" does not exist
    ORA-06512: at "SYS.DBMS_ISCHED", line 4398
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2892
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 3028
    ORA-06512: at "DW.FIX_JOB_TIMEZONE", line 78
    ORA-06512: at line 1
    I’ve been chasing my tail to get the right combination of single-quotes and possibly concatenation, but it has eluded me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    EdStevens wrote:
    ... If the owner of the above procedure connects and calls dbms_scheduler directly:
    SQL> show user
    USER is "DW"
    SQL> exec DBMS_SCHEDULER.set_attribute_null ('"ESTEVENS"."EDS_SQLNAV_JOB1"', 'ST
    ART_DATE');
    PL/SQL procedure successfully completed.Yet, when calling the above procedure:
    SQL> exec dw.fix_job_timezone('ESTEVENS');
    Processing "ESTEVENS"."EDS_SQLNAV_JOB1"
    BEGIN dw.fix_job_timezone('ESTEVENS'); END;
    ERROR at line 1:
    ORA-27486: insufficient privileges
    ORA-06512: at "SYS.DBMS_ISCHED", line 4398
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2892
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 3028
    ORA-06512: at "DW.FIX_JOB_TIMEZONE", line 78
    ORA-06512: at line 1
    Remember that privileges granted through roles don't count in AUTHID DEFINER stored procedures.
    Your procedure doesn't specify AUTHID, so it defaults to DEFINER; therefore, the privilges to do anything in the procedure must be granted directly to the procedure owner (or to PUBLIC), and not merely to some role that the procedure owner has.
    Maybe a problem with the enclosing quotes, or lack of?I don't think so. If the quotes were wrong, I would expect a compile-time error, not a run-time error. Also, regardless of when you got the error, I would expect the error message for misplaced quotes to be something about syntax, like "keyword not found where expected', rather than something about privileges.
    You're already doing the smart thing:
    {code}
    dbms_output.put_line('Processing '||v_job);
    dbms_scheduler.set_attribute_null (v_job, 'START_DATE');
    END LOOP;
    {code}displaying v_job pefore running it. If you can run that same command in an EXEC command (as the procedure owner), then it's definitely an AUTHID DEFINER problem, and you need the privileges granted directly to you.

  • Can anyone explain this query.?

    Can anyone explain this query.?
    select nvl(s.p_id,q.p_id),nvl(s.p_type,q.p_type),nvl(s.p_line,q.p_line),
    nvl(s.sales2004,0),nvl(s.sales2005,0),nvl(q.quota2004,0),nvl(q.quota2005,0)
    from sales s
    full outer join quota q on(s.p_id = q.p_id and s.p_type=q.p_type and s.p_line=q.p_line)

    from sales s full outer join quota qTable quota is outer joined to table sales , if there are no matching records in table quota then also the query retuns the sales record with null values for the corresponding quota record columns
    NVL() has been used to handle such cases

  • Execute query  run fine with numeric data not give result on string data

    Hi master
    Sir I use under blow code for execute query
    sir when I use numeric data then run fine but when I use character data then not give any result
    with numeric run fine
    DECLARE
         DD VARCHAR2(15);
    BEGIN
         DD:=10;
    set_block_property('emp', default_where, 'where DEPTNO='||DD);
    go_block('emp');
    execute_query;
    set_block_property('emp', default_where, '');
    END;
    With character not give any result
    DECLARE
         DD VARCHAR2(15);
    BEGIN
         DD:='SALESMAN';
    set_block_property('emp', default_where, 'where RTRIM(EMPNO)='||DD);
    go_block('emp');
    execute_query;
    set_block_property('emp', default_where, '');
    END;
    Please give me any idea

    bro it is not working on string format coz of the missing quotes. e.g. 'smith' or smith. so the quoted string will be compared. in set_block_property u have to include extra quotes on the variable. e.g.
    set_block_property('emp',default_where,'where ename='''||:emp.ename||'');
    or with conditional statement
    set_block_property('emp',default_where,'where ename='''||:emp.ename||''' and dname='''||dept.deptno||'');
    there i included two extra qoutes before joining ename and in the an extra quote to complete to string. if u would like to debug at runtime to show if the qouted string condition is proper then assign the where clause to a variable and message it up.
    like
    myvariable:='where ename='''||:emp.ename||'';
    message(myvariable);
    message(myvariable);
    set_block_property('emp',default_where,myvariable);
    after the string is quoted properly the execute query will work fine, also use the function upper or lower to compare strings.
    zaibi.

Maybe you are looking for

  • Playing a DRM (FMRMS) protected .flv with a space in the filename fails on OS X

    As the subject says, when trying to play a DRM encrypted .flv with a space in the filename it fails on OS X it works on Windows and I am 99% sure it works on Linux as well. I changed my files to not include a space but it appears now that if there is

  • Apple TV not accept airplay on new iPhone 5

    Every time I try to stream my music from my iphone 5 to my Apple TV does not work, it's making a sond like the song is skipping. I've try everything restore iPhone and Apple TV nothing worked so far The iphone works perfectly on my friends Apple TV b

  • Tabs won't load. The web page loads then instantly starts to re load and continues like this.

    When Firefox opens it loads a blank tab. As soon as I click on any web site it loads for a milli-second then the pages on a reload cycle and doesn't stop so the page never loads at all. I doesn't matter if you reinstall Firefox, reboot the computer d

  • JDBC-IDoc through XI

    Dear All, I am using JDBC and IDoc Adapter for a typical scenario in XI.Please tell me how the channel will get INVOKE while there is updation in Database Table(JDBC Side) in following cases Deletion Updation Insertion thanks, RP

  • Remote Class cast Exception

    Greetings, I took my first steps into the RMI world. I managed to get a tutorial example working. Now I did my own RMI system, but I can`t get rid of this problem. - rmiregistry is running OK - my RMIServer is running OK but my RMIClient Throws: java