Running script manually vs within cron = different results

Running Solaris 9 SPARC
Logging in as user oracle (or as root) and running a shell script manually (executing from the command line) everything works, when running the very same shell script from within the oracle crontab file things fail.
I believe I have added to the shell script what is necessary in the way of environment variables, etc. ORACLE_HOME, PATH and export(ed) both
What could the difference be.

Impossible to tell from the information you've gathered so far.
Not working with databases significantly, I don't know what troubleshooting options are best available. Is there some sort of error code that tells you why the operation fails? (permissions? DB error? etc...)
You might run the shell script in the reduced environment under truss, and then truss cron right before it execs the job. I'd recommend:
truss -f -ae -t exec <job> or
truss -f -ae -t exec -p <cron's PID>
That will give you a display of exactly how cron is executing the script. As an example, here's an 'ls' that I invoked:
# truss -f -ae -t exec ls
2165: execve("/usr/bin/ls", 0xFFBFFE1C, 0xFFBFFE24) argc = 1
2165: argv: ls
2165: envp: TERM=xterm SHELL=/sbin/sh SSH_CLIENT=10.245.6.6 4034 22
2165: SSH_TTY=/dev/pts/1 USER=root PATH=/usr/sbin:/usr/bin
2165: MAIL=/var/mail//root PWD=/lib/svc TZ=US/Pacific SHLVL=1
2165: HOME=/ LOGNAME=root
2165: SSH_CONNECTION=10.245.6.6 4034 10.1.1.7 22 _=/usr/bin/truss
2165: OLDPWD=/lib/svc/method
And via cron:
2176: execve("/usr/bin/sh", 0xFFBFDBE0, 0x0002CFAC) argc = 3
2176: argv: sh -c /usr/bin/ls
2176: envp: HOME=/ LOGNAME=root PATH=/usr/sbin:/usr/bin
2176: SHELL=/usr/bin/sh TZ=US/Pacific
2178: execve("/usr/bin/ls", 0x00039F58, 0x00039F60) argc = 1
2178: argv: /usr/bin/ls
2178: envp: HOME=/ LOGNAME=root PATH=/usr/sbin:/usr/bin
2178: SHELL=/usr/bin/sh TZ=US/Pacific
Note that although I put a binary in crontab (/usr/bin/ls), cron doesn't exec it directly. Instead it passes it to /usr/bin/sh to exec. Also we see the reduced environment. I'd have to explicitly reduce my environment to replicate that...
# truss -f -ae -t exec env -i TZ=US/Pacific PATH=/usr/sbin:/usr/bin SHELL=/usr/bin/sh LOGNAME=root HOME=/ /usr/bin/ls
2200: execve("/usr/bin/env", 0xFFBFFDA4, 0xFFBFFDC8) argc = 8
2200: argv: env -i TZ=US/Pacific PATH=/usr/sbin:/usr/bin
2200: SHELL=/usr/bin/sh LOGNAME=root HOME=/ /usr/bin/ls
2200: envp: TERM=xterm SHELL=/sbin/sh SSH_CLIENT=10.245.6.6 4034 22
2200: SSH_TTY=/dev/pts/1 USER=root PATH=/usr/sbin:/usr/bin
2200: MAIL=/var/mail//root PWD=/lib/svc TZ=US/Pacific SHLVL=1
2200: HOME=/ LOGNAME=root
2200: SSH_CONNECTION=10.245.6.6 4034 10.1.1.7 22 _=/usr/bin/truss
2200: OLDPWD=/lib/svc/method
2200: execve("/usr/bin/ls", 0xFFBFFDC0, 0x00023338) argc = 1
2200: argv: /usr/bin/ls
2200: envp: HOME=/ LOGNAME=root SHELL=/usr/bin/sh
2200: PATH=/usr/sbin:/usr/bin TZ=US/Pacific
done!
But that's just a way of looking at differences. Being able to ask the sql script for what error is affecting it may get you the information more directly.
Darren

Similar Messages

  • Run Script Logic/Package from a different Application

    Hi Experts,
    I have a scenario here that I need to run a package from a different application. For example, I'm in Finance application and I need to run a package which is in the LegalApp application, is it possible to call that package or perhaps run the logic it was calling without having switch back to LegalApp.
    Thanks,
    Marvin

    To run a package that runs logic on another application, you could copy a package such as "Default Formulas" and put the name of the target application in the new package's name.  Then go to Modify Package --> Advanced.  Edit the package to set the application as below.  The LegalApp (for example) is set on the third Task command.  Default logic is called on fifth.
    PROMPT(RADIOBUTTON,%CHECKLCK%,"Select whether to check work status settings when running logic.",1,{"Yes, check for work status settings before running logic","No, do not check work status settings"},{"1","0"})
    PROMPT(SELECTINPUT,,,,%CATEGORY_DIM%%ENTITY_DIM%%TIME_DIM%)
    TASK(Execute formulas,USER,%USER%)
    TASK(Execute formulas,APPSET,%APPSET%)
    TASK(Execute formulas,APP,LegalApp)
    TASK(Execute formulas,SELECTION,%SELECTIONFILE%)
    TASK(Execute formulas,LOGICFILE,)
    TASK(Execute formulas,CHECKLCK,%CHECKLCK%)

  • Analytic function should produce different results

    Hi All
    My question is derived by a usage of the analytic functions with "sliding window". Let's say you have a table as
    GROUP_ID SEQ VALUE
    1 1 1
    1 1 2
    2 2 3
    2 3 4
    Then the query
    select sum( value ) over ( partition by group_id order by group_id, seq ) from a_table
    should produce different values for different runs because rows 1,2 have the same value of SEQ. One run may produce 2 then 1 another one may produce 1 then 2.
    I need to prove it if the statement above is true. Oracle caches data so if run it several times you will see the same result.
    Thanks.

    Why are you using group_id twice, in partition and order by? And why would several "runs" on the same data provide different results?
    C.

  • Different results whether insert run alone or in begin...end

    I have an insert statement below. If I put in .sql file and run with @ in plsql i get 1300 rows evenly distributed to different "unique_id"(first column). If I take this exact same statement and enclose in DECLARE, BEGIN, EXCEPTION, END block with no other code changes, I get 1300 rows but they all have the same "unique_id" of 36. I'm confused. Oracle 8i on windows 2000 and SQLPlus from my desk with XP.
      insert
        into x_group_list (x_group_list.unique_id,
                          x_group_list.supervisor_sys_id,
                          x_group_list.employee_sys_id,
                          x_group_list.pay_policy_sys_id,
                          x_group_list.punch_based_entry,
                          x_group_list.cost_date_format,
                          x_group_list.pay_period_sys_id,
                          x_group_list.pay_period_short_name,
                          x_group_list.pay_period_start_date,
                          x_group_list.pay_period_end_date,
                          x_group_list.pay_period_status,
                          x_group_list.serial_number,
                          x_group_list.last_name,
                          x_group_list.first_name,
                          x_group_list.middle_name,
                          x_group_list.department_id,
                          x_group_list.department_sys_id,
                          x_group_list.workgroup_id,
                          x_group_list.location_sys_id,
                          x_group_list.location_offset,
                          x_group_list.validate_until_current_time,
                          x_group_list.approval_sys_id,
                          x_group_list.timecard_error_flag,
                          x_group_list.lock_timecard,
                          x_group_list.emp_pay_period_exists,
                          x_group_list.grp_schedule_include,
                          x_group_list.grp_gte_include,
                          x_group_list.being_used_by,
                          x_group_list.date_modified)
        select NVL(superrank, 99999),
               mysuper,
               employee.employee_sys_id,
               employee.pay_policy_sys_id,
               pay_policy.punch_based_entry,
               0,
               mypolicy,
               'SHORTNAME',
               (mydetailend - 10080),
               mydetailend,
               'H',
               employee.serial_number,
               employee.last_name,
               employee.first_name,
               employee.middle_name,
               mydep_id,
               mydep,
               'Junk',
               employee.location_sys_id,
               0,
               pay_policy.validate_until_current_time,
               0,
               1,
               0,
               'Y',
               0,
               0,
               mysuper,
               sysdate
          from employee, pay_policy,
               (select policy_pay_period_detail.system_id mypolicy,
                       min(policy_pay_period_detail.pay_period_end_date) mydetailend
                  from policy_pay_period_detail
                 where policy_pay_period_detail.pay_period_closed = 0
                 group by policy_pay_period_detail.system_id),
               (select mydep, mydep_id, mysuper, superrank
                  from (select rownum deprank, department_sys_id mydep, department_id mydep_id
                          from department
                         where department_sys_id in
                               (select distinct department_sys_id mydep
                                  from employee
                                 where employee_status = 'A')),
                       (select rownum superrank, employee_sys_id mysuper
                          from employee
                         where employee_status = 'A'
                           and approve_all_departments = 'Y'
                           and employee_sys_id > 1)
                 where mod(deprank, 36)+1 = superrank)
        where employee.employee_status = 'A'
          and mydep = employee.department_sys_id
          and employee.pay_policy_sys_id = pay_policy.pay_policy_sys_id
          and pay_policy.pay_period_sys_id = mypolicy;thanks,
    Herb
    Message was edited by:
    HerbLane

    What I'm reading (since I haven't used SEQUENCE before) says that I can't use it in a subquery. fyi: Oracle 8i The Complete Reference.
    My biggest concern is figuring out why it is running differently whether inside BEGIN..END or not. I just want to be sure that I'm not using something incorrectly (or the possibility of a defect which is less likely). We have too many scripts here that could give incorrect results because they are written in a simmilar fashion.

  • How to solve that error in primavera p6 version 8.4 installation???????upgarding Data Base((missing permissions: DBMS_REPUTIL. Run the manual script first -- manual_script_before_upgrade.sql)

    please advice how to solve that problem (in steps):
    after completing p6 installation and during upgrading the old Data Base from p6 v8.3 to P6 v8.4 I'm facing that error
    ((missing permissions: DBMS_REPUTIL. Run the manual script first --> manual_script_before_upgrade.sql)

    for more help this image is much helpful
    1. Open cmd prompt >> Type sqlplus / as sysdba; >> connect sys/oracle@XE as sysdba;
    2. Type @ <path>\manual_script_before_install.sql
    thanks for      Pablo Oyarzo - Oracle    for his help as the above answer related to him

  • Same code gives different results in Matlab Script in Labview and Matlab

    I am implemeting a Matlab code into a LabVIEW application using Matlab script. When I import the exactly same code to the Matlab Script in LabVIEW it gives a different result than it is in Matlab. This code is a simulation code including first kind bessel functions. Using LabVIEW 7.1 and Matlab R14 service pack 3.

    Labview 8.5
    Matlab R2009b
    Attached are the graphs produced by matlab script in labview and in matlab.
    The minimum of graph produced by matlab code is below 1 and that in labview is above 1.
    Thanks a lot for your reply.
    Sorry, I haven't quantified the "sometimes" yet. 
    Attachments:
    matlabsResult.jpg ‏29 KB
    LV.png ‏84 KB

  • Looking for an SQL query to retreive callvariables + ECC from a RUN SCRIPT RESULT (Translation to VRU)

    Hi Team,
    I am looking for an SQL query to check the data (ECC + CallVariable) received following a RUN SCRIPT RESULT when requesting an external VRU with a Translation Route to VRU with a "Run External Script".
    I believe the data are parsed between the Termination Call Detail + Termination Call Variable .
    If you already have such an SQL query I would very much appreciate to have it.
    Thank you and Regards
    Nick

    Omar,
    with all due respect, shortening a one day's interval might not be an option for a historical report ;-)
    I would recommend to take a look the following SQL query:
    DECLARE @dateFrom DATETIME, @dateTo DATETIME
    SET @dateFrom = '2014-01-24 00:00:00'
    SET @dateTo   = '2014-01-25 00:00:00'
    SELECT
    tcv.DateTime,
    tcd.RecoveryKey,
    tcd.RouterCallKeyDay,
    tcd.RouterCallKey,
    ecv.EnterpriseName AS [ECVEnterpriseName],
    tcv.ArrayIndex,
    tcv.ECCValue
    FROM Termination_Call_Variable tcv
    JOIN
    (SELECT RouterCallKeyDay,RouterCallKey,RecoveryKey FROM Termination_Call_Detail WHERE DateTime > @dateFrom AND DateTime < @dateTo) tcd
    ON tcv.TCDRecoveryKey = tcd.RecoveryKey
    LEFT OUTER JOIN Expanded_Call_Variable ecv ON tcv.ExpandedCallVariableID = ecv.ExpandedCallVariableID
    WHERE tcv.DateTime > @dateFrom AND tcv.DateTime < @dateTo
    With variables, you can parametrize your code (for instance, you could write SET @dateFrom = ? and let the calling application fill in the datetime value in for you).
    Plus joining two large tables with all rows like you did (TCD-TCV) is never a good option.
    Another aspect to consider: all ECC's are actually arrays (always), so it's not good to leave out the index value (tcv.ArrayIndex).
    G.

  • Different results on consecutive runs of OFT for Web Applications

    I am using Oracle Functional Testing for Web Applications to test share point site [using: OS = WinXP SP3, default browser = IE8.0.6]
    I’ve recorded simple scenario - browsing through two pages (home page > menu link > page 1)
    there is no user input involved – just browsing)
    problem:
    I am running the same test multiple times and I get different results – sometimes (less often) I get clear ‘Passed’ results but more often I get warnings about missing items, Severe content differences)
    upon comparing Master and Tested HTML I see that test fails because no content is being logged under Tested:HTML node (the content displays properly in right browser pane)
    any hints?

    You probably need a close no save step at the end of your action.
    In the save for web dialog, when you record the action, save to the folder you
    want the batch dialog to put the images. Then set the batch dialog as below.
    MTSTUNER

  • Running scripts in different schema

    Assume you have a workspace user DEMO and parsing schema TEST and PROD.
    I create from Workshop/utilities/DDL you select schema PROD for getting DDL for tables, Triggers...
    Now you want to run this script against schema PROD (to create the Objects from PROD at TEST). But at Workshop/scripts you see the scripts owned by TEST, but you can't select a schema fur running the script.
    As workaround I edited the script: create table TEST.x instead of create table x, but I got: ORA-01031: insufficient privileges.
    If I go to Workshop/SQL_Commands select the schema TEST and put in the content of the script (create table TEST.x) it works.
    I confused as I create a DDL for y selecting TEST as schema and want run it as "create table PROD.y" - IT WORKS.
    In which context is a script executed ?
    The difference between schema TEST and PROD is that PROD was created with the workspace and TEST was added later (as new created schema).
    It looks like a bug?

    thank you scott, I understand. I assumed/found the "primary" schema (b) as the way as it worked. The default schema (a) I now tested - it works.
    That means per user there is only 1 schema assigned for running scripts (default or the first schema sssigned to workspace.
    But If I have a workspaced with assigned many schemata and some users, having there own default schema but accessing different schemata, there is no way to run a script at a specific schema.
    A workaround could by if a developer can change his default schema, but he can't
    ( I believe thats okay!).
    A developer sometimes has to create, upload,execute scripts ...
    For my example with schemata DEMO, PROD,TEST I hade to create 3 developers and relogin for executing scripts in the 3 different schemata.
    I think there is an enhancement request for having
    a) connect command in a script OR
    b) selecting schema as in object browser
    Thanks - hope you had merry christmas

  • Do IMAQ Cast Image or IMAQ Linear averages give different results when using different computers that are running under Windows XP ?

    Hello
    I'm currently developping an image processing algorithm using Labview 7.1 and the associated IMAQ Vision tools. After several tests, I found a weird result. Indeed, I put the labview algorithm - including the IMAQ VI on the library to get sure that I use all the time the same VI - on my memory stick and used it on two different computers. I tested the same picture (still in my memory stick) and had two very different results.
    After several hours trying to understand why, I found that there were a difference between the results given by both computers at the very begining of the algorithm. Indeed, I used a JPEG file.
    To open it, I first create an Image with IMAQ Create (U8). Then, I open it.
    Then in my first sub-VI, I use IMAQ Cast Image to be sure that the picture is a U8 grayscale picture.
    Right after that, I use the IMAQ Linear Averages. The results of this VI are different on the two computers.
    I tried several time on the same picture : one computer always give me the same result but the two computers give me a different result. So there is no random variable on the results.
    So my question is : Do IMAQ Cast Image or IMAQ Linear averages give different results when using different computers that are running under Windows XP ?
    My bet is on IMAQ Cast Image but I'm not quite sure and I do not undestand why. The labview and IMAQ are the same on both computers.
    The difference between the two computer are above :
    Computer 1 :
    Pentium(R) 4 CPU 3.20GHz with a RAM of 1Go. The processor is an Intel(R).
    The OS is windows XP Pro 2002
    Computer 2 :
    Pentium(R) 4 CPU 2.80GHz with a RAM of 512Mo. The processor is an Intel(R).
    The OS is windows XP Pro 2002.
    If anybody can help me on this problem, it would be really helpful.
    Regards
    Florence P.

    Hi,
    Indeed it's a strange behaviour, could you send me your VI and your JPEG file, (or another file that reproduces) so that I could check this inthere ?
    I'll then try to find out what's happening.
    Regards
    Richard Keromen
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Découvrez, en vidéo, les innovations technologiques réalisées en éco-conception

  • Cron job : how to run scripts as cron job

    Hi friend,
    Sorry one very small question ..
    Can someone tell me how can i run scripts as cron job .. on HP UX.
    thanks
    ashish

    Hi Ashish,
    open one telnet session.
    crontab -e
    then give the periodicity day and time
    like below
    05 00 * * 1-6  /usr/local/bin/database_backup.sh
    and now create the script file with the command or script to execute.
    Regards
    Ashok Dalai

  • Getting different result while running Dashboard SP Using Temporary table?

    Hi Experts
    I am getting different result when I run my dashboard procedure I am using temporary table with "ON COMMIT PRESERVE ROWS", below is the information
    I am running my attendance dashboard procedure which will display the employee attendance status based IN and OUT punches the status like AA-full day absent, GG-Full day Present, AG-First half absent,GA-Second half absent. Now when I run the first time my procedure for first time I am getting status AA even though IN and OUT timings are correct and if run it again then it is displaying the status for same employee as GG
    I didn't understand the problem where it is effecting the status

    ChakravarthyDBA wrote:
    It is procedure which will display the employee status, back end I am storing the procedure result in Temporary table with "ON COMMIT PRESERVE ROWS", when I run the procedure first time it is showing wrong information when I run it again second time then it is showing correct information. I don't know why the status is changing.
    first time employee status is AA --Full day absent and Second time is GG--Full day present (in both cases IN and OUT timings are correct only)
    is it effecting due to temporary table?
    So, you have a GTT and you're doing "something" with it and that "something" isn't what you expect.
    I've about summed up what you've posted and given us to work with. If you have specific examples please do share. Without them we're going to be of very little use to you.
    If you aren't getting the results you expect, it stands to reason that
    1) you don't understand the outputs you are supposed to be getting
    2) you have a bug in the code developed
    Please stop and think about this, pretend you are the one trying to help out. You've been given little to no information about a system you've never seen before. You need to explain your situation as you would if you brought someone in to your shop to show them this problem you are having ... the rules don't change just because it's not face-face interaction.
    Cheers,

  • Different results on timestamps in SQL developer

    Hi
    I have this table with a TIMESTAMP column in it.
    CREATE TABLE my_table ("TID" TIMESTAMP (6) NOT NULL ENABLE);
    I use this query in SQL developer:
    SELECT tid from my_table;
    There is one row in the table, that has a timestamp in the hour of the change to european summertime.
    The timestamp of this row is displayed differentliy in SQL developer:
    - when the query is run by 'run stamement' (Ctrl+enter) the result is
    11-03-27 03:17:00,000000000
    - when the query is run as a script (F5) the result is
    11-03-27 02:17:00,000000000
    Notice the difference in the hours of the timestamp.
    Why this difference? (It only occurs for timestamps within the hour of 2 am to 3 am on that date - the hour that should'nt exist as the clock advances from 2 am to 3 am that night...)
    What is actually stored in the database? (the 3.17 am or 2.17 am value)
    Is there a conversion taking place when running as a script in SQL developer, but not when just running the single stamement?
    Regards Søren

    Hi Søren,
    This is rather an "edge" condition error, but I have posted an internal bug for it:
    Bug 13088622 - FORUM: RUN SCRIPT/STATEMENT TIMESTAMP VALUE DIFFERS DURING DT/ST CHANGEOVER
    Please provide some version information about your environment: SQL Developer, Java JDK, OS, etc.
    Regards,
    Gary
    SQL Developer Team

  • Different Results From V$Rman_Backup_job_details  and V$Rman_Status

    Does anyone know why I would get different results from V$Rman_Backup_job_details and V$Rman_Status on the same instance?
    Image of Quries: www.hydell.com/OracleBackupDifferences.png
    Dates Returned For Latest Backup
    V$Rman_Status = 10/13/2011
    V$Rman_Backup_job_details = 7/24/2011
    Which view is the best to use for monitoring backups?
    Thanks in advance for the help.
    Rob

    oracle.dba.89 wrote:
    Please show the script and that might help look into this. Also the timezone of the OS shows EST. And cron shows the scheduled time at 12hrs. It should run at 12:00 EST hours and not GMT.
    Also please post output for below queries. Are backups run from the same node? (If RAC)
    select value from dba_scheduler_global_attribute where attribute_name = 'DEFAULT_TIMEZONE';
    Hi,
    This is the backup script
    #Set Variables
    ORACLE_HOME=/projects1/oramroprod/oracle/product/10.2.0/db_4
    ORACLE_SID=MROPROD
    PATH=$PATH:$ORACLE_HOME/bin
    btype="FULL"
    RMAN_BACKUP_LOC=/data1/RMAN/MROPROD
    export ORACLE_HOME
    export ORACLE_SID
    export PATH
    export btype
    tag="$ORACLE_SID"_"$btype"
    #Print commands and their arguments as they are executed
    set -x
    SDATE=`date +%m%d%y`
    STIME=`date +%H%M%S`
    DD=`date +%d%m%y`
    #Create daily backup directories
    mkdir -p $RMAN_BACKUP_LOC/datafiles_backup/bkp_${DD}
    mkdir -p $RMAN_BACKUP_LOC/controlfile_backup/bkp_${DD}
    mkdir -p $RMAN_BACKUP_LOC/arch_backup/bkp_${DD}
    mkdir $RMAN_BACKUP_LOC/logs
    #Take backup
    rman target / nocatalog log=$RMAN_BACKUP_LOC/logs/rman_${btype}_backup_${SDATE}_${STIME}.log << EOF1
    change archivelog all crosscheck;
    run {
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
    backup as compressed backupset incremental level 0 database tag '$tag' format '$RMAN_BACKUP_LOC/datafiles_backup/bkp_${DD}/%d_%s_%p';
    backup as compressed backupset archivelog all not backed up 1 times FORMAT '$RMAN_BACKUP_LOC/arch_backup/bkp_${DD}/ARCH_%d_%s_%p';
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO  '$RMAN_BACKUP_LOC/controlfile_backup/bkp_${DD}/%F';
    delete noprompt obsolete;
    delete noprompt archivelog all completed before 'sysdate-2';
    EXIT;
    EOF1
    This is not RAC.
    SQL> select value from dba_scheduler_global_attribute where attribute_name = 'DEFAULT_TIMEZONE';
    VALUE
    GMT

  • SQL Query produces different results when inserting into a table

    I have an SQL query which produces different results when run as a simple query to when it is run as an INSERT INTO table SELECT ...
    The query is:
    SELECT   mhldr.account_number
    ,        NVL(MAX(DECODE(ap.party_sysid, mhldr.party_sysid,ap.empcat_code,NULL)),'UNKNWN') main_borrower_status
    ,        COUNT(1) num_apps
    FROM     app_parties ap
    SELECT   accsta.account_number
    ,        actply.party_sysid
    ,        RANK() OVER (PARTITION BY actply.table_sysid, actply.loanac_latype_code ORDER BY start_date, SYSID) ranking
    FROM     activity_players actply
    ,        account_status accsta
    WHERE    1 = 1
    AND      actply.table_id (+) = 'ACCGRP'
    AND      actply.acttyp_code (+) = 'MHLDRM'
    AND      NVL(actply.loanac_latype_code (+),TO_NUMBER(SUBSTR(accsta.account_number,9,2))) = TO_NUMBER(SUBSTR(accsta.account_number,9,2))
    AND      actply.table_sysid (+) = TO_NUMBER(SUBSTR(accsta.account_number,1,8))
    ) mhldr
    WHERE    1 = 1
    AND      ap.lenapp_account_number (+) = TO_NUMBER(SUBSTR(mhldr.account_number,1,8))
    GROUP BY mhldr.account_number;      The INSERT INTO code:
    TRUNCATE TABLE applicant_summary;
    INSERT /*+ APPEND */
    INTO     applicant_summary
    (  account_number
    ,  main_borrower_status
    ,  num_apps
    SELECT   mhldr.account_number
    ,        NVL(MAX(DECODE(ap.party_sysid, mhldr.party_sysid,ap.empcat_code,NULL)),'UNKNWN') main_borrower_status
    ,        COUNT(1) num_apps
    FROM     app_parties ap
    SELECT   accsta.account_number
    ,        actply.party_sysid
    ,        RANK() OVER (PARTITION BY actply.table_sysid, actply.loanac_latype_code ORDER BY start_date, SYSID) ranking
    FROM     activity_players actply
    ,        account_status accsta
    WHERE    1 = 1
    AND      actply.table_id (+) = 'ACCGRP'
    AND      actply.acttyp_code (+) = 'MHLDRM'
    AND      NVL(actply.loanac_latype_code (+),TO_NUMBER(SUBSTR(accsta.account_number,9,2))) = TO_NUMBER(SUBSTR(accsta.account_number,9,2))
    AND      actply.table_sysid (+) = TO_NUMBER(SUBSTR(accsta.account_number,1,8))
    ) mhldr
    WHERE    1 = 1
    AND      ap.lenapp_account_number (+) = TO_NUMBER(SUBSTR(mhldr.account_number,1,8))
    GROUP BY mhldr.account_number;      When run as a query, this code consistently returns 2 for the num_apps field (for a certain group of accounts), but when run as an INSERT INTO command, the num_apps field is logged as 1. I have secured the tables used within the query to ensure that nothing is changing the data in the underlying tables.
    If I run the query as a cursor for loop with an insert into the applicant_summary table within the loop, I get the same results in the table as I get when I run as a stand alone query.
    I would appreciate any suggestions for what could be causing this odd behaviour.
    Cheers,
    Steve
    Oracle database details:
    Oracle Database 10g Release 10.2.0.2.0 - Production
    PL/SQL Release 10.2.0.2.0 - Production
    CORE 10.2.0.2.0 Production
    TNS for 32-bit Windows: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
    Edited by: stevensutcliffe on Oct 10, 2008 5:26 AM
    Edited by: stevensutcliffe on Oct 10, 2008 5:27 AM

    stevensutcliffe wrote:
    Yes, using COUNT(*) gives the same result as COUNT(1).
    I have found another example of this kind of behaviour:
    Running the following INSERT statements produce different values for the total_amount_invested and num_records fields. It appears that adding the additional aggregation (MAX(amount_invested)) is causing problems with the other aggregated values.
    Again, I have ensured that the source data and destination tables are not being accessed / changed by any other processes or users. Is this potentially a bug in Oracle?Just as a side note, these are not INSERT statements but CTAS statements.
    The only non-bug explanation for this behaviour would be a potential query rewrite happening only under particular circumstances (but not always) in the lower integrity modes "trusted" or "stale_tolerated". So if you're not aware of any corresponding materialized views, your QUERY_REWRITE_INTEGRITY parameter is set to the default of "enforced" and your explain plan doesn't show any "MAT_VIEW REWRITE ACCESS" lines, I would consider this as a bug.
    Since you're running on 10.2.0.2 it's not unlikely that you hit one of the various "wrong result" bugs that exist(ed) in Oracle. I'm aware of a particular one I've hit in 10.2.0.2 when performing a parallel NESTED LOOP ANTI operation which returned wrong results, but only in parallel execution. Serial execution was showing the correct results.
    If you're performing parallel ddl/dml/query operations, try to do the same in serial execution to check if it is related to the parallel feature.
    You could also test if omitting the "APPEND" hint changes anything but still these are just workarounds for a buggy behaviour.
    I suggest to consider installing the latest patch set 10.2.0.4 but this requires thorough testing because there were (more or less) subtle changes/bugs introduced with [10.2.0.3|http://oracle-randolf.blogspot.com/2008/02/nasty-bug-introduced-with-patch-set.html] and [10.2.0.4|http://oracle-randolf.blogspot.com/2008/04/overview-of-new-and-changed-features-in.html].
    You could also open a SR with Oracle and clarify if there is already a one-off patch available for your 10.2.0.2 platform release. If not it's quite unlikely that you are going to get a backport for 10.2.0.2.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

Maybe you are looking for

  • Unable to load Java classes from byte arrays.

    I have an application started through JWS. It works fine except for one problem. The application allows the user to load an external class, typically received over a socket. These are not (and cannot) be signed. My application complains about not bei

  • Error while compiling form 6i

    Hi All, I am getting Memory fault error while compiling the form. I tried with two commands. I executed these commands from $AU_TOP/forms/US At first I tried with f60gen $AU_TOP/forms/US/XXTEST.fmb apps/opopop123 output_file =$XXEEG_TOP/forms/US/XXTE

  • When to use an interface?

    I'm a bit confused about when to make an interface for an object. I hardly make interfaces except when I develop a distributed application. I normally provide an API specification with the program I developed. Can anyone tell me when it is usefull to

  • Plz send me the differnce between XD01,VD01&FD01

    Hi Friends, Pls send me reply immediatly, pls telle me what is the difference between XD01, VD01,FD01 Thanking you, With regards Lux.

  • SAP B1  Radio Beacon vms 54.11

    Saludos. Alguno a utilizado SAP B1 con Radio Beacon(Warehouse), ya que tengo un problema de sincronizacion en el campo de onHand por un lado SAP me da una cantidad y Radio Beacon me da otra diferente. llegé a pensar que SAP calcula la existencia basa