Invalid SQL Query with DBMS_JOB.SUBMIT inside

Probably a simple thing, but I can't seem to find the problem in here. I get an error that INVALID SQL STATEMENT. I guess I'm messing something up with the lots of ' chars. If anyone could point out where did I failed I'd be really grateful.
create or replace
trigger TR_REFRESH_SCHEMAS
  after create or alter
  on schema
declare
  tableName         user_tables.table_name%TYPE;
  table_count       number(2);
begin
  select ora_dict_obj_name
  into tableName
  from dual;
  select  count(table_name)
  into    table_count
  from    user_tables
  where   table_name = tableName;
  if (table_count != 0) then
    execute immediate
      'BEGIN'                     ||
        'DBMS_JOB.SUBMIT'         ||
        '('                       ||
          'job        => '        || table_count      || ','        ||
          'what       => '        || 'INSERT_SCHEMA(' ||  tableName || ');,' ||
          'next_date  => '        || sysdate          || ','        ||
          'interval   => '        || null             ||
        ');'                      ||
      'END;'                      ||
      'COMMIT;'
  end if;
  exception
    when no_data_found then
      raise_application_error(-20020, 'Table ' || tableName || ' not found!');
    when others then
      raise_application_error(-20002, 'Error (' || SQLCODE || '): ' || SQLERRM);
end;

I've tried all your recommendations without any success.
For the dbms_output.put_line:
- I've found there was a problem with the interval => null. In the final statement it looked like: DBMS_JOB.SUBMIT(1, INSERT_SCHEMA(TEST), 2012-08-31...., ); obviously wrong. Since the default value of interval is NULL I've taken out that parameter.
For the formatting:
- Thanks for pointing that out! It was surely a problem with that part, as I've seen when printing the statement.
execute immediate
      'BEGIN '                    ||
        'DBMS_JOB.SUBMIT'         ||
        '('                       ||
          'job        => '        || table_count        || ','        ||
          'what       => '        || 'INSERT_SCHEMA(''' ||  tableName || ''');,' ||
          'next_date  => '        || sysdate            ||
        ');'                      ||
      'END;'
    );With the qnotation:
- I get an immediate syntactical error when inserting your code right at the second 'q{' part. On the other hand the first parameter: job is a number type so to_char is meaningless in my opinion.
The result so far for a CREATE TABLE statement:
Error starting at line 1 in command:
create table TESTING
  id varchar2(20) not null,
  text number(8),
  dat blob,
  creat_e date
Error at Command Line:1 Column:0
Error report:
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-20002: Error (-6550): ORA-06550: line 1, column 77:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
   . ( ) , * % & = - + < / > at in is mod remainder not rem
   <an exponent (**)> <> or != or ~= >= <= <> and or like like2
   like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 1, column 102:
PLS-00103: Encountered the symbol "-" when expecting one of the following:
   <an identifier> <a double-quoted delimited-identifier>
   current delete exists prior
Th
ORA-06512: at line 32
00604. 00000 -  "error occurred at recursive SQL level %s"
*Cause:    An error occurred while processing a recursive SQL statement
           (a statement applying to internal dictionary tables).
*Action:   If the situation described in the next error on the stack
           can be corrected, do so; otherwise contact Oracle Support.

Similar Messages

  • How could I replace hard coded value in my sql query with constant value?

    Hi all,
    Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
    PROCEDURE class_by_day_get_bin_data
         in_report_parameter_id   IN   NUMBER,
         in_site_id               IN   NUMBER,
         in_start_date_time       IN   TIMESTAMP,
         in_end_date_time         IN   TIMESTAMP,
         in_report_level_min      IN   NUMBER,
         in_report_level_max      IN   NUMBER
    IS
      bin_period_length   NUMBER(6,0); 
    BEGIN
      SELECT MAX(period_length)
         INTO bin_period_length
        FROM bin_data
         JOIN site_to_data_source_lane_v
           ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
         JOIN bin_types
           ON bin_types.bin_type = bin_data.bin_type 
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
       SELECT site_to_data_source_lane_v.site_id,
             site_to_data_source_lane_v.site_lane_id,
             site_to_data_source_lane_v.site_direction_id,
             site_to_data_source_lane_v.site_direction_name,
             bin_data_set.start_date_time,
             bin_data_set.end_date_time,
             bin_data_value.bin_id,
             bin_data_value.bin_value
        FROM bin_data
        JOIN bin_data_set
          ON bin_data.bin_serial = bin_data_set.bin_serial
        JOIN bin_data_value
          ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
        JOIN site_to_data_source_lane_v
             ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
            AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) lane_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'LANE'
                  AND report_parameters.report_parameter_name  = 'LANE'
             ) report_lanes
          ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) class_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'CLASS'
                  AND report_parameters.report_parameter_name  = 'CLASS'
             ) report_classes
          ON bin_data_value.bin_id = report_classes.class_id
        JOIN edr_rpt_tmp_inclusion_table
          ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data_set.start_date_time >= in_start_date_time
         AND bin_data_set.start_date_time <  in_end_date_time
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       =  bin_period_length;
    END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
    bin_data.bin_type            =  2But I dont want any hard coded number or string in the query.
    How could I replace it?
    I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
    bin_type     CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
    Thanks.
    Edited by: user10641405 on May 29, 2009 1:38 PM

    Declare the constant inside the procedure.
    PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
                                        in_site_id             IN NUMBER,
                                        in_start_date_time     IN TIMESTAMP,
                                        in_end_date_time       IN TIMESTAMP,
                                        in_report_level_min    IN NUMBER,
                                        in_report_level_max    IN NUMBER) IS
      bin_period_length NUMBER(6, 0);
      v_bin_type     CONSTANT NUMBER := 2;
    BEGIN
      SELECT MAX(period_length)
        INTO bin_period_length
        FROM bin_data
        JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                           site_to_data_source_lane_v.data_source_id
        JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time >=
             in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time <
             in_end_date_time + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type = v_bin_type
         AND bin_data.period_length <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
      INSERT INTO edr_class_by_day_bin_data
        (site_id,
         site_lane_id,
         site_direction_id,
         site_direction_name,
         bin_start_date_time,
         bin_end_date_time,
         bin_id,
         bin_value)
        SELECT site_to_data_source_lane_v.site_id,
               site_to_data_source_lane_v.site_lane_id,
               site_to_data_source_lane_v.site_direction_id,
               site_to_data_source_lane_v.site_direction_name,
               bin_data_set.start_date_time,
               bin_data_set.end_date_time,
               bin_data_value.bin_id,
               bin_data_value.bin_value
          FROM bin_data
          JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
          JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
                                 bin_data_value.bin_data_set_serial
          JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                             site_to_data_source_lane_v.data_source_id
                                         AND bin_data_set.lane =
                                             site_to_data_source_lane_v.data_source_lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'LANE'
                   AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
                                                                                         report_lanes.lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'CLASS'
                   AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
                                                                                            report_classes.class_id
          JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
                                              TRUNC(edr_rpt_tmp_inclusion_table.date_time)
         WHERE site_to_data_source_lane_v.site_id = in_site_id
           AND bin_data.start_date_time >=
               in_start_date_time - numtodsinterval(1, 'DAY')
           AND bin_data.start_date_time <
               in_end_date_time + numtodsinterval(1, 'DAY')
           AND bin_data_set.start_date_time >= in_start_date_time
           AND bin_data_set.start_date_time < in_end_date_time
           AND bin_data.bin_type = v_bin_type
           AND bin_data.period_length = bin_period_length;
    END class_by_day_get_bin_data;

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to write sql query with many parameter in ireport

    hai,
    i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
    but i don't know to create query if more than 1 parameter.i also have parameter such as
    $P{entity},$P{id},$P{ic}.please help me for this.
    thanks

    You are in the wrong place. The ireport support forum may be found here
    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • How the SQL Query Parsing is processing inside SQL/PLSQL engine?

    Hi all,
    Can you explain how the SQL Query Parsing is processing inside SQL/PLSQL engine?
    Thanks,
    Sankar

    Sankar,
    Oracle Database concepts - Chapter 24..
    You will find the explanation required under the heading parsing.
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm

  • Extract Sql Query with Actual Parameters from Report

    Hi
    I am able to extract query from Crystal Report using the following code :
    ReportDocument.ReportClientDocument.RowSetController.GetSqlStatement(new GroupPath, out tmp);
    But the sql query retrieve comes in the following format :
    select name , trans_code, account_code from command_query.accounts
    where account_code = {?Command_query_Prompt0}  and effective_date < '{?Command_query_prompt1 }'
    The parameters which I m using in the reports are :
    Account_Code and Effective_Date .
    Why does my extracted sql translates it into {?Command_query_Prompt0} and '{?Command_query_prompt1 }' .
    Is there any way to map this to the actual parameter values ?
    OR
    Can we extract the query after assigning the values ?
    Any help is appreciated ... 
    Thanks
    Sanchet

    hi,
    You can create nested sql query with conditional parameters,
    For example
    Select Code From OITT Where Code IN (Select ItemCode From OITM
    Where ItemName LIKE '[%0]' + '%%')
    Edited by: Jeyakanthan A on Jun 9, 2009 12:31 PM

  • Hosting company does not support SQL query with OUTFILE clause

    From my mysql database, I want to allow the user to run a query and produce a csv / text file of our membership database.   Unfortunately,  I just found out my hosting company does not support the SQL query with OUTFILE clause for MySQL database.
    Are there any other options available to produce a file besides me running the query in phpadmin and making the file available to users.
    Thanks.  George

    Maybe this external Export Mysql data to CSV - PHP tutorial will be of help
    Cheers,
    Günter

  • Sql query(PL/SQL function body return SQL query) with in(x,y,z) condition

    Hello,
    I've set up a region definition of type "SQL Query(PL/SQL function body return SQL query). In my query I make use of an "in" condition. When I populate :P755_INC_BARG_UNIT with a value of 0F (no quotes), I get the correct count. However, when I set :P755_INC_BARG_UNIT to 0F, 0E I get an invalid count. What do I have to set the page item to?
    When running the query in TOAD, and setting :P755_INC_BARG_UNIT to the string inside the brackets (0F, 0E) I get the proper count.
    The code I use is shown below. Any help would be appreciated,
    Alex.
    DECLARE
    v_sql VARCHAR2(32767);
    BEGIN
    SELECT count(*) "cnts",
    ''Faculty data file IDs missing in appt table'' "err_type"
    FROM hradmin.et_faculty_salary fs left outer join
    hradmin.appointments appt
    ON trim(fs.empl_id) = appt.emp_emp
    and appt.ear_activ <> ''Z''
    and appt.ear_type = ''F''
    and (appt.ear_class in (''A'',''B'',''C'',''D''))
    and appt.ear_bargunit in ( :P755_INC_BARG_UNIT )
    WHERE appt.emp_emp is null
    RETURN v_sql;
    END;

    Alex,
    try something like:
    DECLARE
    v_sql VARCHAR2(32767);
    BEGIN
    v_sql := <YOUR_SQL_STATEMENT_WITH_P755_INC_BARG_UNIT_IN_IT>;
    v_sql :=  REPLACE(v_sql, ':P755_INC_BARG_UNIT',:P755_INC_BARG_UNIT);
    RETURN v_sql;
    END; But before doing it read this:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:210612357425
    After reading you will be able to find the best solution yourself.
    Lev

  • SQL Query with wrong result

    Hello.
    I have a query with LEFT OUTER JOIN that I think returns invalid results. Here are the problem details:
    CREATE TABLE DOGERR(
    IdDog INTEGER,
    SfPdg CHAR(1),
    IdVpl INTEGER,
    SfVpGot INTEGER,
    SfZrr CHAR(1)
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (1, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (2, 'S', 1, 1, '7');
    INSERT INTO DOGERR(IdDog, SfPdg, IdVpl, SfVpGot, SfZrr) VALUES (3, '$', 1, 2, 'C');
    COMMIT;
    CREATE UNIQUE INDEX DOGERR_PK ON DOGERR(IdDog);
    And now the query:
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    This query should (by my understanding) return only one row in wich the joined subquery columns should be NULL. And indeed query returns only one row on Oracle Database 10g Release 10.2.0.1.0 - Production and on Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = NULL, SFVPGOTJOIN = NULL, SFZRRJOIN = NULL
    But on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production it returns TWO rows:
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    IDDOG = 3, SFPDG = "$", IDVPL = 1, SFVPGOT = 2, SFZRR = "C", IDVPLJOIN = 1, SFVPGOTJOIN = 1, SFZRRJOIN = "7"
    And now the interesting part: any of the following modified versions of query works even on Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production, although modifications should not modify the result set:
    -- Removed unnecessary WHERE conditions
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3;
    -- Removed unnecessary OR condition in subquery
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin, T.SfZrr AS SfZrrJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    -- Removed columns from joined subquery from SELECT part
    SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGotJoin
    FROM DOGERR D
    LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
    T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
    WHERE
    D.IdDog = 3
    AND D.SfVpGot = 2
    AND D.SfZrr = 'C';
    NOTE: the query itself is a little stupid but this is just to demonstrate the problem. We have faced this problem at a customer with our real-world query.
    So, my question is: why different results ?
    Thanks.
    David

    hi,
    welcome to the forum,
    don't have a solution, but I thought I'd let you know that the first SQL statement only returns 1 row on 10gR2
    SQL> SELECT D.IdDog, D.SfPdg, D.IdVpl, D.SfVpGot, D.SfZrr, T.IdVpl AS IdVplJoin, T.SfVpGot AS SfVpGo
    tJoin, T.SfZrr AS SfZrrJoin
      2  FROM DOGERR D
      3  LEFT OUTER JOIN (SELECT * FROM DOGERR WHERE SfPdg = 'S' OR SfPdg = 'S') T ON
      4  T.IdVpl = D.IdVpl AND T.SfVpGot = D.SfVpGot AND T.SfZrr = D.SfZrr
      5  WHERE
      6  D.IdDog = 3
      7  AND D.SfVpGot = 2
      8  AND D.SfZrr = 'C';
         IDDOG S      IDVPL    SFVPGOT S  IDVPLJOIN SFVPGOTJOIN S
             3 $          1          2 C
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

  • SQL Query with MS-Access Database

    Hi,
    I have linked my oracle database with MS-Access via a DB LINK. i can access the data from MS-ACCESS, but i have a problem that when i specify the column name or define a where clause in my query it gives me the error ORA-00904: invalid identfier ..
    This query fetch the data without any problem SELECT * FROM TBLREPORT@M_ACCESS but when i run SELECT EMP_ID FROM TBLREPORT@M_ACCESS it gives me the error i mentioned above. (Column name have No problem or mistake of spelling even CASE)
    also when i try to put where clause in the query it gives me same error SELECT * FROM TBLREPORT@M_ACCESS WHERE EMP_ID = '100' (Error)
    is there any change in SQL query for ACCESS database ??
    any clue
    Regards
    Rehman

    Are column/table names in access case sensitive? Issue
    DESC TBLREPORT@M_ACCESS If column EMP_ID actual name shows up in mixed/lower case, enclose it in double quotes and use the exact case. E.g., if column name shows up as Emp_Id, use:
    SELECT "Emp_Id" FROM TBLREPORT@M_ACCESSSY.

  • Apex 4.2 Report region sql query with "apex_item.text" renders wrongly

    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name=&quot;f01&quot; size=&quot;20&quot; maxlength=&quot;2000&quot; value=&quot;111&quot;  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?
    I need that function "apex_item.text", i cannot remove it.
    Edited by: CharlesRoos on 13.02.2013 15:28
    Edited by: CharlesRoos on 13.02.2013 15:29
    Edited by: CharlesRoos on 13.02.2013 15:29

    CharlesRoos wrote:
    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name="f01" size="20" maxlength="2000" value="111"  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?Ensure that the Display As Column Attribute for the C1 column is Standard Report Column.

  • SQL Query with variable range

    Hi
      I want to give range to a user to enter in a variable through sql query . If there are 200 records , if user wants to display from 5-45 , 75-110 , 130-145. how it can be done through SQl Query
    Thanks
    Edited by: Matt on Aug 31, 2010 6:23 PM - modified title - please use a meaningful title in future

    Dear Saini,
    This query will allow you to choose the values only when you know them.
    SELECT T0.[DocEntry], T0.[ItemCode] FROM INV1 T0 WHERE T0.[LineNum] >[%0]   and T0.[LineNum] <[%1]
    If you run it in the query Generator in SAP Business One a little window will pop up and will ask you to choose the 2 variables.
    You can choose different variables every time you run it. At least you won't have to save many queries with different values.
    If you want 2 different groups, e.g. from 10 to 20 and from 30 to 40, then you can add another part in the where clause:
    SELECT T0.[LineNum], T0.[ItemCode], T0.[DocEntry] FROM INV1 T0 WHERE T0.[LineNum]  >= [%0] and  T0.[LineNum]  <= [%2] and T0.[LineNum]  >= [%4] or  T0.[LineNum]  <= [%6]
    Please, let me know if this query helps.
    Regards,
    Marcella Rivi
    SAP Business One Forums Team

Maybe you are looking for

  • Is a 512MB, Celeron PC good enough to run Oracle Forms

    Hi: I was curious and would like to know if anybody knows if a 512 MB RAM, Intel Celeron DELL PC is sufficient to run 3 Oracle Forms sessions for a Call Center application. Does anybody out there have a similar app out there and would be willing to s

  • I've had my ipad 2 stolen in nz.

    I've had my ipad 2 stolen in nz.  Does anyone know if apple can stop the thieves using it if I provide a serial number?  Apple chat were going to rob me of $49 to ask this question!

  • Java jvm server mode memory leak out of memory crash

    Hi, I am using java version "1.6.0_13" on a windows 2003 server. I am running apache-tomcat-6.0.18 PermSize:256M HEAP:1G If tomcat is started with java with client mode vm, the site works very well! Requests are processed without problems and memory

  • Rebuilding iphoto is not working

    My photos suddenly dissapeared. I have tired averything possible to rebuild it but nothing works. Any ideas? thanks

  • JDBC Connection Pool to DB2 database - Problem

    When trying to create a new JDBC Connection Pool in WebLogic using BEA Type 4 driver for DB2, I get the following error: [BEA][DB2 JDBC Driver]A commitment command has been received on a protected conversation. The commit and rollback commands are no