Strange results with Insert statement having select query

Hi all,
I am facing a strange issue with Insert statement based on a select query having multiple joins.
DB- Oracle 10g
Following is the layout of my query -
Insert into Table X
Select distinct Col1, Col2, Col3, Col4, Function(Col 5) from Table A, B
where trunc(updated_date) > = trunc(sysdate-3)
and join conditions for A, B
Union
Select Col1, Col2, Col3, Col4, Function(Col 5) from Table C, D
trunc(updated_date) > = trunc(sysdate-3)
and join conditions for C, D
Union
.... till 4 unions. all tables are residing in the local Database and not having records more than 50,000.
If I execute above insert in a DBMS job, it results into suppose 50 records where as if I execute the select query it gives 56 records.
We observed following things-
a) no issue with size of tablespace
b) no error while inserting
c) since query takes lot of time so we have not used Cursor and PLSQL block for inserting.
d) this discrepancy in number of records happens frequently but not everytime.
e) examined the records left out from the insert, there we couldn't find any specific pattern.
f) there is no constraint on the table X in which we are trying to insert. Also tables A, B, C....
I went through this thread -SQL insert with select statement having strange results but mainly users are having either DB Links or comparison of literal dates, in my case there is none.
Can somebody explain why is the discrepancy and what is the solution for it.
Or atleast some pointers how to proceed with the analysis.
Edited by: Pramod Verma on Mar 5, 2013 4:59 AM
Updated query and added more details

>
Since I am using Trunc() in the where clause so timing should not matter much. Also I manually ruled out records which were updated after the job run.
>
The first rule of troubleshooting is to not let your personal opinion get in the way of finding out what is wrong.
Actually this code, and the process it represents, is the most likely CAUSE of the problem.
>
where trunc(updated_date) > = trunc(sysdate-3)
>
You CANNOT reliably use columns like UPDATED_DATE to select records for processing. Your process is flawed.
The value of that column is NOT the date/time that the data was actually committed; it is the date/time that the row was populated.
If you insert a row into a table right now, using SYSDATE (8am on 3/5/2013) and don't commit that row until April your process will NEVER see that 3/5/2013 date until April.
Here is the more typical scenario that I see all the time.
1. Data is inserted/updated all day long on 3/4/2013.
2. A column, for example UPDATED_DATE is given a value of SYSDATE (3/4/2013) in a query or by a trigger on the table.
3. The insert/update query takes place at 11:55 PM - so the SYSDATE values are for THE DAY THE QUERY BEGAN
4. The data pull begins at 12:05 am (on 3/5/2013 - just after midnight)
5. The transaction is COMMITTED at 12:10 AM (on 3/5/2013); 5 minutes after the data pull began.
That data extract in step 4 will NEVER see those records! They DO NOT EXIST when the data pull query is executed since they haven't been committed.
Even worse, the next nights data pull will not see them either! That is because the next pull will pull data for 3/5/2013 but those records have a date of 3/4/2013. They will never get processed.
>
Job timing is 4am and 10pm EST
>
Another wrinkle is when data is inserted/updated from different timezones and the UPDATED_DATE value is from the CLIENT pc or server. Then you can get even more data missed since the client dates may be hours different than the server date used for the data pull process.
DO NOT try to use UPDATED_DATE type columns to do delta extraction or you can have this issue.

Similar Messages

  • Report with stored proc running multiple stored procedures with insert statement

    Hi,
    I wonder if this is possible in SSRS ... I use the 2012 version (Data Tools).
    I have a report that triggers a stored procedure. See below.
    Within this SP there are 2 insert statements getting data from 2 other SP's.
    When I make a dataset referring to the main SP below, SSRS does not show me any fields at all.
    Is this because it's a SP with insert statements and nested SP's?
    At the end of the SP I make a select so it should see all the fields.
    The parameters @month and @costcenter are multivalue params. I use a special function to convert the multivalues, selected in the report, into a string to pass it correctly to the query (comma separated).
    USE [TestDB]
    GO
    /****** Object:  StoredProcedure [dbo].[_Pink_SP_StandingsRegisterDataset]    Script Date: 15-4-2014 13:31:30 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[_Pink_SP_StandingsRegisterDataset]
    @year INT,
    @month NVARCHAR(50),
    @costcenter NVARCHAR(500),
    @GLaccount NVARCHAR(9)
    AS
    BEGIN
    /* Remove existing content*/
    DELETE FROM _Pink_TB_StandingsRegister
    /* Add records part 1 */
    INSERT INTO _Pink_TB_StandingsRegister
    EXEC _Pink_SP_StandingsRegister @year, @month, @costcenter, @GLaccount
    /* Add records part 2 */
    INSERT INTO _Pink_TB_StandingsRegister
    Type,
    Row,
    Year,
    Month,
    YearDatetable,
    MonthDatetable
    EXEC _Pink_SP_StandingsRegisterDatetable @year
    /* Select all records */
    SELECT *
    FROM _Pink_TB_StandingsRegister
    END
    GO

    Hi bijntjede2e,
    After testing a similar scenario in my own environment, it works well in Reporting Services. In my test, the stored procedure returns all the fields from _Pink_TB_StandingsRegister table in the dataset. Then I select some values from year, month, costcenter
    and Glaccount parameters, it inserts some values in the _Pink_TB_StandingsRegister table. So we can use this stored procedure as the dataset in the report.
    In order to solve the problem more efficiently, I need to clarify some information.
    Are you pass multiple values parameter to one stored procedure correctly? We can refer to the following thread:
    http://social.technet.microsoft.com/Forums/en-US/dbdfa101-cccc-4e9f-aa50-566dc5ebcc27/ssrs-2008-r2-report-dataset-call-a-stored-procedure?forum=sqlrep
    What results are you get when executing the stored procedure in SQL Server Management Studio? Is it works well? We should double those stored procedures.
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Strange result from insert into...select query

    Hello guys,
    I need your preciuos help for a question maybe simple, but that I can't explain by myself!
    I have a query of "insert into...select" that, as I have explained in the title, returns a strange result. In facts, If I execute ONLY the SELECT statement the query returns the expected result (so 2 rows); instead If I execute the entire statement, that is the "insert into...select", the query returns 0 rows inserted!!
    Following an example of the query:
    INSERT
    INTO TITOLI_ORI
    COD_TITOLO_RICCONS ,
    D_ESTRAZIONE ,
    COD_SOCIETA ,
    COD_PIANO_CONTABILE ,
    COD_CONTO_CONTABILE ,
    COD_RUBRICATO_STATISTICO_1 ,
    COD_NDG ,
    NUM_ESEGUITO ,
    CUR_IMPORTO_RICCONS ,
    CUR_IMPORTO_BICO ,
    FLG_MODIFICATO ,
    CUR_NON_ASSEGNATO ,
    FLG_QUOTATO ,
    COD_CATEG ,
    TIP_COPERTURA ,
    TIPTAS_TITOLO
    SELECT NEWID,
    '28-feb-2111',
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' as CUR_IMPORTO_BICO,
    0 as FLG_MODIFICATO,
    NULL as CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('VALUE1 ')
    AND TRC.COD_RAGGR_IAS NOT IN ('VALUE2')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('VALUE3')
    AND TRC.DES_MOV_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_CAT_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_INTER_TIT = RTRIM('VALUE5')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'V6'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'V7'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('VALUE8 '))
    Thanks a lot

    Right, I have executed this steps:
    - I have changed the query with the select count(*)
    - Changed the insert into with the select count(*)
    - Executed the insert into
    These are the result:
    SQL> select count(*) from TITOLI_ORI2;
    COUNT(*)
    1
    BUT:
    SQL> select * from TITOLI_ORI2;
    A
    0
    The insert into that I've modified is this:
    INSERT INTO bsc.TITOLI_ORI2
    select count(*)
    FROM
    (SELECT bsc.NEWID,
    TO_DATE('28-feb-2111','DD-MON-YYYY') as data,
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' AS CUR_IMPORTO_BICO,
    0 AS FLG_MODIFICATO,
    NULL CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM bsc.S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM bsc.S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN bsc.S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('HFT ')
    AND TRC.COD_RAGGR_IAS NOT IN ('GPO')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('DISPONIBILI')
    AND TRC.DES_MOV_TIT = RTRIM('CONSEGNARE ')
    AND TRC.COD_CAT_TIT = RTRIM('OBBLIGAZIONE ')
    AND TRC.COD_INTER_TIT = RTRIM('334058')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN bsc.S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN bsc.S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'ME'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'IS'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('P044C11 '))
    Another time the strange result returns!!
    And I've created the table TITOLI_ORI2 as create table TITOLI_ORI2 (a number); to contain the number result of the query.

  • Error With Insert Into From Select

    Hello,
    I have a problem with this query in pl sql developer with oracle 10G:
    insert into ca_nrj_rem(imsi,id_gamme_vente,domaine,date_topage,id_produit)
    (select a1.* from (select d.imsi, 1, 4, trunc(sysdate - 1), 'NRJ003'
    from ca_evenement_vsim a, ca_forfait b, ca_forfait c, ca_vsim_associe d
    where a.id_action = 'CP1'
    and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'ancienCode') = b.code_forfait
    and b.code_gamme = 2
    and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'nouveauCode') = c.code_forfait
    and c.code_gamme = 6
    and date_trace > sysdate - 6
    and a.vsimid = d.vsimid
    and d.date_fin is null
    group by d.imsi, trunc(sysdate - 1)) a1, ca_nrj_rem n
    where a1.imsi=n.imsi(+) and n.imsi is null);
    The select statement return X (163) values but the insert statement inserts Y (540) values
    Can you help me please ?
    Thanks You

    user511447 wrote:
    The select statement return X (163) values but the insert statement inserts Y (540) valuesNot possible if the select statements are identical.
    You'll have to provide more evidence and example output (format it on the forum by putting {noformat}{noformat} before and after it), so we can see exactly what you are doing.
    Are you sure that the table you are inserting into has no rows initially or that you are counting the rows correctly?
    Show us exactly what you are doing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Dynamic From statement in select query and/or outer join not working

    Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
    Select (dynamic columns) INTO <wa>
    FROM a inner join b on af1 = bf1
    inner join c on af2 = cf2......
    WHERE (dynamic conditios)
    ORDER BY ( dynamic sort condition).
    Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
    I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
    Kindly give me pointers.
    Thanks

    Hey thanks for the reply, but the problem is not solved.
    I am already using  ( fileds, value) like table in my where condition and the select statement was working properly.
    the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
    But I am getting a runtime error as below:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
         caught in
        procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The running ABAP program wanted to execute a SELECT statement whose
        WHERE condition was (partly) specified dynamically. The part that is
        specified in an internal table at runtime is compared to a field of the
        right table of an LEFT OUTER JOIN. Such comparisons are not supported by
         all database systems and are therefore not allowed.

  • Fill a text box or other in a form with output of a select Query

    Hi
    Does anyone know if you can fill an object with an output from a select query on a form. I am trying to display a piece of data on a form , that is related to the data on the form. I do not need to edit this peice of data.
    The version of PORTAL i am using does not support forms created on views.
    Is this possible!!
    Thanks

    Hi
    I found what I was looking for at the following forum thread.
    http://forums.oracle.com/forums/message.jsp?id=471864
    Thanks to Steve Yeager

  • Trouble with city, state in Mysql Query

    Hello,
    I am having trouble with a query I am trying to setup.  Basically, I want the user to type in their city.  Then I want the system to ask them which city,state combo is theirs.  So if they enter "Washington" the system will return:
    Select your city/state:
    Washington, NJ
    Washington, PA
    Washington, DE
    City and state are stored as two fields in my mysql DB.  I was considering using 'select distinct' but I wasnt sure how it would work in relation to two fields.  So how would I go about making sure washington, nj only appears once (its in a database where there will be multiple washington, NJ listed).
    So anyone have any ideas or code samples they have used to do something like this?
    Thanks in advance,
    Mark

    davella wrote:
    City and state are stored as two fields in my mysql DB.  I was considering using 'select distinct' but I wasnt sure how it would work in relation to two fields.  So how would I go about making sure washington, nj only appears once (its in a database where there will be multiple washington, NJ listed).
    DISTINCT works the same way for single field or multiple fields.  It returns all distinct combinations of the values in the columns you have listed.
    SELECT  DISTINCT City, State
    FROM     Table
    WHERE  City = 'Washington'
    (Data) City, State
    Washington, NJ
    Washington, PA
    Washington, NJ
    Washington, DE
    Washington, NJ
    Washington, PA
    So for your two columns it would distinct combinations of the "City" and "State" values.  But why are there multiple "Washington, NJ" records? Are they actually different cities or duplicate records?
    (Results)
    Washington, NJ
    Washington, PA
    Washington, DE

  • OPEN CURSOR using a WITH clause in the select query

    Hi,
    I am using Oracle 9i. I have a requirement where I have a REFCURSOR as an OUT parameter for my procedure. I have declared the TYPE and created the procedure.
    In the procedure, I am using OPEN <cursor_name> FOR <query>;
    Ideally this works in most of the cases that I have tried earlier. However, in the current case I am using a WITH clause in my query to get the results.
    I need help in understanding if the above mentioned syntax would not allow me to use the WITH clause in the query.

    What error do you get , seems to work ok for me on 10g
    SQL> begin
      2  open :cv for 'with x as (select * from emp)  select * from x';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :cv
         EMPNO
    ENAME
    JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521
    WARD
    SALESMAN        7698 22-FEB-81       1250        500         30
          7566
    JONES
    MANAGER         7839 02-APR-81       2975                    20
         EMPNO

  • Problem With Insert statement using field symbols with unicode enabled

    I was writng a function module for dyanamic operations on the table. We are using the field symbols, function module is unicode enabled.
    Assign statements are working fine, with which we created work are <fs_wa_header> and internal table <fs_tb_item> dynamically based on the table name (IM_TB_HENAME) which we get as import parameter.
    we have query which is giving us dump.
    INSERT  (IM_TB_HENAME)  FROM <FS_WA_HEADER>.

    Hi
    INSERT (IM_TB_HENAME) FROM <FS_WA_HEADER> is good for inserting a line in the database, so IM_TB_HENAME has to have the name of dictionary table.
    U should write:
    INSERT  <FS_WA_HEADER> INTO (IM_TB_HENAME).
    But I believe you can't use the variable IM_TB_HENAME, you should use another field-symbols:
    ASSIGN (IM_TB_HNAME) TO <FS_TB_ITEM>.
    INSERT  <FS_WA_HEADER> INTO <FS_TB_ITEM>.
    Max

  • Newbie: help with join in a select query

    Hi: I need some help with creating a select statement.
    I have two tables t1 (fields: id, time, cost, t2id) and t2 (fields: id, time, cost). t2id from t1 is the primary key in t2. I want a single select statement to list all time and cost from both t1 and t2. I think I need to use join but can't seem to figure it out even after going through some tutorials.
    Thanks in advance.
    Ray

    t1 has following records
    pkid, time, cost,product
    1,123456,34,801
    2,123457,20,802
    3,345678,40,801
    t2 has the following records
    id,productid,time,cost
    1,801,4356789,12
    2,801,4356790,1
    3,802,9845679,100
    4,801,9345614,12
    I want a query that will print following from t1 (time and cost for records that have product=801)
    123456,34
    345678,40
    followed by following from t2 (time and cost for records that have productid=801)
    4356789,12
    4356790,1
    9345614,12
    Is this possible?
    Thanks
    ray

  • Strange problem with SQL-Statement

    Hi guys,
    i encountered a strange problem trying to execute a statement
    like this:
    Insert Into Data Set Text = 'Exception-Type: {0} Message: {1}';
    I'm using createStatement and executeUpdate.
    But the message stored looks like:
    Exception-Type: 0{} Message: 1{}
    I'm using MySQL 3.23. if I use ODBC everthing is o.k.!?
    Any suggestions
    Thanks

    I found a solution,
    i've thought it through once again. the sql-parsing
    mechanism seemed to be the right direction.
    i guess the odbc mysql implementation does a sql-statement
    conversion, so the string is stored correctly into the
    database. the jdbc-implementation doesn't.
    if i replace { with \{ it works. the backlash can be used
    to masquerade some characters in mysql.
    my application is database independent (or it should be)
    so i wonder if this works with oracle , db2 etc.
    mike

  • Problem with date format in select query

    Hi
    I am caught by a stupid problem, please help me
    I am writing a queries
    SELECT * FROM VOUCHERS WHERE VDATE = '07-AUG-08'
    SELECT * FROM VOUCHERS WHERE VDATE = '07-AUG-2008'.
    both are working fine in SQL Developer but returning error when called from JDBC Driver.
    First query doesn't return any record while it is supposed to
    Second returns error: ORA-01858: a non-numeric character was found where a numeric was expected
    What i remember, at least second query was working previously but what happend, i dont know
    i didn't change Oracle default datetime format or any other defaults
    Message was edited by:
    W-S

    It is a common issue most people don't realize what Oracle does with a query like this. You're comparing strings to dates. Use TO_DATE to convert your string '07-AUG-08' to a date. If you don't, you tell Oracle to convert the string to a date by itself. It may work sometimes but like you've experienced, it is not a very robust or elegant approach.
    Try something like this:
    SELECT *
    FROM vouchers
    WHERE VDATE = TO_DATE('07-AUG-2008','DD-MON-YYYY').You can even provide a third parameter to TO_DATE, but it's less frequently used. I let you figure it out.
    And a tip: the "urgent" keyword might act against you.

  • Captivate 4 publishing issue?--very strange results with embedded swfs

    I have a captivate file with some swf's created in flash, and some simple swf's created in Captivate 4.  When I publish, the swf's created in Flash pause if you pause the player, but the captivate published swfs do not.  Also, I have a captivate published swf playing on my 3rd slide, and on the first slide in playback, you can hear a mouse click, like the flash has already started playing.  And sure enough when you get to the 3rd slide, the flash is in the middle of playing.  I have "sync to project" checked on all of them.  Is this a bug with captivate??   please help!

    Hi there,
    Just to add to Michael's excellent post. I would suggest that you check to see what the frame rate in Flash is set to. When inserting SWF animations into Captivate you need to make sure that your Flash projects (SWFs) have a frame rate of 30 fps.
    Another option would be to create test SWF in Flash using AS3 and insert this into a Captivate AS3 project. To set your Captivate project to AS 3 carry out the following steps:
    1. Choose Edit > Preferences
    2. Select the Publish Settings category of the Project preferences
    3. Choose AS3
    4. Click OK.
    Next, publish your CP file as a SWF (externalizing the animations as Michael suggested) and see if that makes any difference.
    Best - Mark
    Visit the macrofireball blog

  • Stuck on CONNECT_BY ... PRIOR statement / sub-select Query

    I am trying to generate a list of customisations made to our eBusiness system.
    I'm using this example as a starting point:
    SELECT *
       FROM applsys.jdr_paths jp1
      WHERE UPPER(jp1.path_name) = 'CUSTOMIZATIONS'
        AND jp1.path_docid BETWEEN 18000 AND 18700;
    _NAME                                                    PATH_DOCID PATH_OWNER_DOCID PATH_TYPE                        PATH_SEQ PATH_XML_V PATH_XML_E CREATED_BY                     CREATION_ LAST_UPDATED_BY                LAST_UPDA LAST_UPDATE_LOGIN
    customizations                                                18479             1650 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1
    customizations                                                18665            18663 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1
    customizations                                                18010            18009 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1I can then use this to extract the full path - for example, using the example above, the "PATH_OWNER_DOCID" = 18663:
    SELECT     LEVEL
             , SYS_CONNECT_BY_PATH(p.path_name, '/') PATH
             , p.path_docid
          FROM (SELECT jp.path_name
                     , jp.path_seq
                     , jp.path_docid
                     , jp.path_owner_docid
                  FROM applsys.jdr_paths jp) p
    CONNECT BY path_docid = PRIOR path_owner_docid
    START WITH p.path_docid = 18665;
    LEVEL     PATH                                                                  PATH_DOCID
    1     /customizations                                                          18665     
    2     /customizations/webui                                                  18663     
    3     /customizations/webui/pagesetup                                          18661     
    4     /customizations/webui/pagesetup/printmgmt                          18660     
    5     /customizations/webui/pagesetup/printmgmt/bpa                          10174     
    6     /customizations/webui/pagesetup/printmgmt/bpa/ar                  10173     
    7     /customizations/webui/pagesetup/printmgmt/bpa/ar/apps                  2     
    8     /customizations/webui/pagesetup/printmgmt/bpa/ar/apps/oracle          1What I'd really like to do is to include the bottom most path (i.e. the most detailed, full path (path_docid = 1 in the e.g. above) in the first SQL statement.
    That way, against each customisation, listed via this:
    SELECT *
       FROM applsys.jdr_paths jp1
      WHERE UPPER(jp1.path_name) = 'CUSTOMIZATIONS'
        AND jp1.path_docid BETWEEN 18000 AND 18700;I would like to include, possibly via a sub-select, the full path of the customisation - not all of the other lines leading up to the full path, just the full path itself.
    But I can't work out how to combine the 2 SQLs, assuming it can be done at all.
    Any advice much appreciated.
    Thanks!

    If understand your question right... Just a MAX would work.
    select (SYS_CONNECT_BY_PATH(object_name, '/'))
    from
    select object_name, rownum lv
           from all_objects
       where rownum <= 5
       ) t
        START WITH lv = 1
       CONNECT BY PRIOR lv = lv - 1
    (SYS_CONNECT_BY_PATH(OBJECT_NAME,'/'))                                         
    /WRH$_SERVICE_WAIT_CLASS_PK                                                    
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS                            
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK     
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL/WRH$_OSSTAT_PK
    5 rows selected.
    select max(SYS_CONNECT_BY_PATH(object_name, '/'))
    from
    select object_name, rownum lv
           from all_objects
       where rownum <= 5
       ) t
        START WITH lv = 1
       CONNECT BY PRIOR lv = lv - 1
    MAX(SYS_CONNECT_BY_PATH(OBJECT_NAME,'/'))                                      
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL/WRH$_OSSTAT_PK
    1 row selected.vr
    Sudhakar B.

  • Using Left with Charindex in a Select Query

    Hi
    I hope someone can help me.  I have a field that has text in it for example N00342-01/28 and I am trying to get it to only show N00342-01.  This could in the future be N132245-01/25 for example or N00342-132/28.  What I am trying to show is
    anything before the "/".
    The code I have created is this:
    SELECT        S.ItemNumber, S.DeliveryWeek, S.Pack_Centre, S.Schedule_Qty, S.Delivered_Qty, S.PartPallet, I.Production_Reference, LEFT('I.Production_Reference',
                             CHARINDEX('/', 'I.Production_Reference') - 1) AS IntouchRef, I.Pallet_Qty, I.Tool_Number, S.Firm
    FROM            dbo.Scheduled_Items AS S INNER JOIN
                             dbo.Item_Details AS I ON S.Pack_Centre = I.Pack_Centre AND S.ItemNumber = I.Item_Number
    When I run it I get this error:
    Does anyone know what I am doing wrong?
    Thanks
    Aaron

    SELECT        S.ItemNumber, S.DeliveryWeek, S.Pack_Centre, S.Schedule_Qty, S.Delivered_Qty, S.PartPallet, I.Production_Reference, LEFT('I.Production_Reference',
                             CHARINDEX('/', 'I.Production_Reference') - 1) AS IntouchRef,
    Hello Aaron,
    Remove the single Hyphen around I.Production Reference, this it's treaten as a fix text, not as a column.
    Just to test it:
    DECLARE @test AS TABLE(MyValue varchar(30))
    INSERT @test VALUES ('N132245-01/25')
    INSERT @test VALUES ('N003424-132/28')
    SELECT LEFT(MyValue, CHARINDEX('/', MyValue) - 1)
    FROM @test
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

Maybe you are looking for

  • Mobileme cals not showing in ical

    i have synced all my stuff with mobileme and it is working mobileme to iphone. however, my calendars are not showing in ical. i thought that the mobileme cals would be listed in ical but its not happening. i have tried many times to resync etc but ca

  • Viewing PDF Portfolio using Adobe Acrobat XI Pro in Sharepoint Foundation 2013

    When opening a PDF Portfolio, created using Adobe Acrobat XI Pro, in Sharepoint Foundation 2013 the pages are blank in the default Layout view but you can see the contents in File view. How do we correct that so the files appear in both views? Local

  • ASP Page to query report

    Hi there, So a long time ago we had a developer who set up an asp page that loads through some of our applications.  The asp page points to a specific report, depending on where it is called from within our application and also the parameters for tha

  • Problems vith Hard disk 2

    Hallo! As Barry Menphill knows well I had problems with an hard disk. DiskWarrior recovered and I backed up (correct?) all my files (by luck!) but I can't see the disk on desktop, DiskWarrior can't install new directories and I can't initialize the d

  • Batch Rename and now files will not open

    i hope someone can help me. i moved some .dng files from an external drive to my mapbook pro using batch rename in bridge CS5. The files moved to my desktop ine, but now they will not open. When I try to open them  the digital convertor opens up. Whe