Newbie question: SQL operations automatically reordered so a DELETE comes first?

Hi -
I have two objects that are related to each other by a one-to-many relationship. In my test case
there's a single A object that is related to a single B object. I want to sever the relationship
between the two objects (a SQL UPDATE behind the scenes) and then delete one of them (a SQL
DELETE).
What I'm seeing is that the SQL DELETE is issued before the SQL UPDATE. I'm running Kodo 2.3.2.
Here's the Java code:
// sever A's relationship to B, which issues a SQL UPDATE
objectA.getBs().remove(objectB);
// sever B's relationship to A
objectB.setA(null);
m_pm.makePersistent(objectB);
// delete object A, which issues a SQL DELETE
m_pm.deletePersistent(objectA);
If this Java code is in a single transaction, the DELETE occurs before the UPDATE and fails because
of a foreign key constraint. If the deletePersistent call is moved to a separate transaction, all
work is completely successfully.
Is this behavior by design? Did I miscode something?
Thanks in advance,
Les

Thanks Abe. I actually thought I was ordering the operations but I can see now that I wasn't
thinking about the order that the objects joined the transaction.
And thanks for posting a quick reply; that's a big help.
Les
"Abe White" <[email protected]> wrote in message news:aoi7p0$euu$[email protected]..
Kodo will performs database operations on a per-object basis, and orders each
object's database operations according to when that object joined the
transaction.
In your case, objectA is joining the transaction as soon as you call
objectA.getObjectBs ().remove (objectB);
So even though the explicit deletion of objectA doesn't happen until later,
Kodo places it at the point where objectA joined the transaction. To work
around this, just change your code:
objectB.setObjectA (null);
objectA.getObjectBs ().remove (objectB);
pm.deletePersistent (objectA);
Note that internal builds of Kodo have support for automatic foreign key
analysis and INSERT/UPDATE/DELETE ordering, but the feature probably won't
be debuted publicly for a couple of months.

Similar Messages

  • Newbie question: sql runs on sqlplus but not compile in pl/sql?

    I have the following two tables I would like to put a sql statement into pl/sql packages so I can use dbms_jobs automate it however, I keep getting compile time error. It seems to me that pl/sql does not like my sql that runs fine in sqlplus. Below is the error message and my test case?
    mdb_user@CMD> show error
    Errors for PACKAGE BODY DATA_QUALITY_REPORT_P:
    LINE/COL ERROR
    10/1 PL/SQL: SQL Statement ignored
    13/42 PL/SQL: ORA-00942: table or view does not exist
    create table S_ORG_EXT
    accnt_type_cd varchar2(100),
    cust_stat_cd varchar2(100)
    insert into s_org_ext
    select column_name,data_type from user_tab_columns where rownum <= 100
    select * from s_org_ext
    create table data_quality_report
    runid number not null,
    report_type number not null, --report type such as dup or not dup or other metrics
    org_level number not null, --organization level nsgn, sgn, shipto
    loc_level number not null,--locale level by city, by country, by region, grand_total
    name varchar2(100) not null,--the row output name of the agg
    value number not null,-- the row output value of the agg
    rundate date default sysdate
    create sequence data_quality_report_seq start with 1000
    INCREMENT BY 1
    NOCACHE
    NOCYCLE
    insert into data_quality_report
    select data_quality_report_seq.nextval,3,99,99,accnt_type_cd,cnt,sysdate from
    select accnt_type_cd, count (*) cnt from S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd order by 2 desc
    select * from data_quality_report
    truncate table data_quality_report
    CREATE or replace PACKAGE data_quality_report_p AS
    function pull_data return data_quality_report.runid%type;
    END data_quality_report_p ;
    create or replace package body data_quality_report_p as
    function pull_data return data_quality_report.runid%type is
    new_rid data_quality_report.runid%type;
    begin
    select data_quality_report_seq.nextval into new_rid from dual;
    insert into data_quality_report
    select new_rid,3,999999,999999,accnt_type_cd,cnt,sysdate from
    select accnt_type_cd, count (*) cnt from S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd order by 2 desc
    return new_rid;
    exception
    when no_data_found then
    DBMS_OUTPUT.PUT_LINE('Handling NO_DATA_FOUND exception.');
    when others then
    DBMS_OUTPUT.PUT_LINE('Handling OTHER exception.');
    end; --end pull_data
    end data_quality_report_p;
    /

    Hi,
    A very common cause for ORA-00942 in a stored procedure (here I'm including packages and functions) is that you have privileges only through a role. Roles don't count in stored procedures if they are compiled with the default "AUTHID DEFINER". Either
    (1) have whatever privileges you need (e.g. "INSERT ON data_quality_report" or "SELECT ON s_org_ext") granted directly to you (the package owner), or to the pseudo-user PUBLIC, and not merely to some role that you have, or
    (2) create the package in the same schema as the tables, or
    (3) create the package with "invoker's rights", like this
    CREATE OR REPLACE PACKAGE data_quality_report_p
    AUTHID CURRENT_USER       -- Added
    AS
        FUNCTION pull_data ...'AUTHID CURRENT_USER" goes right before the keyword "IS" (or "AS") in the package spec; you don't have to do anything to the package body.
    However, if you do this, then whoever runs the package will need to have those privileges, in addition to EXECUTE privileges on the package. Privileges granted through a role will be okay.
    Usually, (1) is the best solution. Have the table owner(s), or someone with the proper authority, grant privileges directly to you.
    By the way, there's no point in having an ORDER BY clause in a sub-query like you're doing, and there's no point in having ORDER BY in an INSERT statement. It's not causing the ORA_00932 error (or any other error), it's just wasting resources.
    Edited by: Frank Kulash on Mar 23, 2011 4:02 PM
    Change DEFINER to CURRENT_USER in a couple of places. (Bad mistake!)

  • *Silly* SQL Question - SQL Newbie

    Hello,
    Thanks for taking the time reading this.
    Im a SQL Newbie
    Question?
    I Have a PHONE_TABLE, which consist of
    a BUREAU Column and a STATUS Column.
    Within the STATUS column exist 'active' and 'inactive'
    I would like to know if it's possible to create a report that groups a Bureau and counts the # of active /inactive phones
    that displays
    \BUREAU/- - -\Active/ - - - -\Inactive/
    - - - - HR - - - - - 3 - - - - - - - --4 - - - - - - - -
    - - - - IT - - - - - 1 -- - - - -- - - 5 - - - - - - - - -
    - - MGMT - -- -- 3 - - - - -- - - 6 - - - - -- -
    Thanks for the help guys

    Try this:
    select bureau, sum(decode(status,'Active',1,0) ) active , sum (decode(status,'Inactive',1,0) )  inactive
    from PHONE_TABLE
    group by bureauHope this helps!
    Sam
    Please reward good answers by marking them correct or helpful!

  • SG200-08 Newbie Questions

    I have recently purchased the SG200-08 Smart Switch, but I have a few "newbie questions" about it as I get started using it.
    The on board firmware shows 1.0.1.0. Is that the latest firmware to the switch?
    Do I need to enable IPv6 Auto Configuration and DCHPv6 in my switch settings to be ready for IPv6 as my ISP rolls it out down the road?
    How do I go about changing the switch's username? I was able to easily change the password, but having issues getting the username to change.
    Do I need to do anything about the LLDP-MED settings? What exactly is that?
    How do I confugure the System Time Settings so the switch functions in my time zone (USA Central Time)?
    Thanks a bunch for any assistance!

    Hi Nathan,
    My guess is that NAT is already on - you have one public IP address from your ISP. Your router will use NAT (network address translation) to allow multiple clients (and either dynamically assign them private IPs via dhcp or you set them statically) to connect to the internet using the one public IP. It also sounds like your RV042G is assigning both ipv6 and ipv4 addresses, and theres nothing wrong with that. Unless you have specific information re: ipv6 from your isp, however, I would suggest not worrying about it until you hear from them. Are your macs connected to the router via the SG200 switch? If so, it looks like its passing ipv6 just fine.  UPnP is something completely different - thats with opening ports like you mentioned - its a way that your devices can communicate with the router to automatically enable the proper port forwarding for the device/application.
    Regarding the username, create a new user account. I don't think you can edit the cisco user, but try deleting it after creating and testing a new user account..
    I'm not familiar with the Polycom system, but I would leave the settings as default unless you are using true IP phones (rather than an ATA adapter). From a quick google of the polycom device, I don't think you will gain anything from LLDP/CDP as the handsets use regular cordless phone freqs. With my setup, we use cisco IP desk phones and cordless wifi phones, CDP makes life easy as the cisco access point, wifi phones, cisco switch, and cisco desk phones (connected via ethernet) see each other and know what they're dealing with automatically.
    I don't see the SNTP setting for unicast / broadcast that you're looking at. For the switch to get the time from a sntp server, under administration -> time -> sntp settings, add a server, and then back on time-> system time, enable sntp server as the main clock source. What are you using as your sntp source? Do you have an internal sntp server? You don't need to enable dhcp on the sntp server.
    May I also point you to the two manuals, I think they may be helpful:  RV042G  & SG200
    Hope thats helpful.
    Best,
    David
    Please rate any helpful posts.

  • Dumb newbie question -- shell vrs linux console

    This is probably a dumb newbie question, but what is the difference between the shell screen and the linux console screen? I used another system before Arch and I believe there was only the shell screen! Does it matter which one is used?  Thanks -- Larry

    The console is the 2D text rendering thing. The shell is Bash, just a program that handles your input and has the console as output.
    If on the other hand you mean the console at startup, and you call that the console while you call xterm, etc. shells then the answer is different. It's just a matter of configuration if you automatically start X or not. A lot people use gdm or kdm to get a graphical login screen after bootup, others just type "startx" in the console when they want to start X.
    You can switch to the console with Ctrl+Alt+Fn where n is a number between 1 and 6. You can switch between consoles with Alt+Fn, X is on the last console, so to go back to X do Alt+F7.

  • Newb question - ufsdump

    Hey guyz,
    Quick newb question:
    What is the function of the n modifier in "ufsdump 4uf /dev/rmt/0n /export/home"?
    Thanks.

    The tape device /dev/rmt/0 can be accessed through a number of "names". The exact name used indicates a exactly how the hardware should access the device.
    /dev/rmt/0n is the no rewind version. If you don't add the n then the tape will be automatically rewound on close.
    You have to use that version if you want to dump multiple things onto the tape one after the other.

  • Total Newbie Question ... Sorry :-(

    I know it's a windows thing, and I am now converted to Mac but I gotta know this because it's doing my head in. It's a complete stupid green gilled newbie question.
    When installing new programs on a Mac can you create shortcuts to the programs on the Dock? I did what I THOUGHT it would be, i.e I made an Alias and stuck it in the dock, but on rebooting my Mac later on, in place of the shortcuts where 3 question marks which when clicked on did absolutely nothing???
    Help?
    A.L.I
    Windows XP Pro Desktop, Macbook Pro, 60GB iPod Video   Mac OS X (10.4.5)   OS X

    You aren't installing something from a dmg file are you? The dmg is a disk image – kind of a virtual CD. So when you double click the dmg and then get the little disk/hardrive/custom icon on your desktop that is the same as if you had mounted a CD. You then need to drag the application off of that "CD" into your application folder. Then it is truly installed.
    You can then "eject" the icon your your desktop. This is what happens when you shutdown and without remounting the image your dock shortcut can't find the original.
    Just a thought.

  • Newbie Question. just installed IE7.. how do I set up a local host to preview sites?

    Sorry for the newbie question... but it's been a long time since I have done this
    Thanks!

    Just define your site in DW as always.  For a static site, that's all you need to do.

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • SQL operations are not allowed with no global transaction by default for X

    Hi All,
    I am getting the above mentioned error.
    java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA drivers. If the XA driver supports performing SQL operations with no global transaction, explicitly allow it by setting "SupportsLocalTransaction" JDBC connection pool property to true. In this case, a
    lso remember to complete the local transaction before using the connection again for global transaction, else a XAER_OUTSIDE XAException may result. To complete a local transaction, you can either set auto commit to true or call Connection.commit() or Connection.rollback().
    I am developing a web application. I have jsp, servlets, JDBC classes.
    I am using DataSource and Connection pools.
    I am on WLS 8.1 sp3 and Oracle 10.1.
    Part of My Config file looks as follows:
    <JDBCConnectionPool DriverName="weblogic.jdbcx.oracle.OracleDataSource" KeepLogicalConnOpenOnRelease="true" KeepXAConnTillTxComplete="false" Name="AUMDataSource" NeedTxCtxOnClose="false" NewXAConnForCommit="false" Password="{3DES}AKRkWgdzXN8WrXSRtSvJ6g==" Properties="user=pibsrmgr;portNumber=1521;SID=pibsrdod;serverName=pibsrdod.dtu.mlam.ml.com" RollbackLocalTxUponConnClose="true" SupportsLocalTransaction="false" Targets="myserver" TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:bea:oracle://pibsrdod.dtu.mlam.ml.com:1521" XAEndOnlyOnce="false" />
    <JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="jdbc/AUMDataSource" Name="AUMDataSource" PoolName="AUMDataSource" Targets="myserver" />
    Any help will be appreciated.
    Thanks
    ---Radhe

    Hi,
    Regarding Transactions , the following link can helpful to you .
    Regards,
    Prasanna Yalam

  • Domain name settings - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name? Any option?

    Setting up a mailserver and making sure it doesn't suddenly turn into a spambox is not something you do with the use of a few commands. I suggest to dive into the Solaris admin guide on docs.sun.com and read up on e-mail and network services.
    If that is asking too much of your time you'll be better off getting your ISP to handle all this for you.

  • Domain Name settings in Solaris - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name?

    Your questions are completely off-topic for the forum.
    These SunOS forums are for questions on <i>"how do I install my OS"</i>
    You particular question is in the <i>"how can I install Solaris while using the CD drive"</i> forum.
    So, if you had a question on how to edit the /etc/inet/hosts file to establish a FQDN on the computer, then it might be appropriate for the forum.
    Unfortunately, I don't have a clue on where to redirect you, except perhaps to the Sun Java Enterprise System suite of applications?

  • Newbie question - parameter selection -- update the table - basic flow?

    Greetings
    Newbie here trying to work my way through a 'simple' example for a demo.
    I'm currently using a workspace on the Apex web site and have uploaded a table with seven (7) columns of which the first three (3) make up the primary key. This is a copy of an actual Production table so I can't change the PK setup.
    What I'm trying to develop as a demonstration of OAE is a Page 1 parameter form that allows the user to input any portion of any or all of the PK values, press the GO button and have Page 2 be a multi-row form showing the results based on the values input on Page 1 and having the user be able to update any of the remaining non-PK columns. After pressing an 'Apply Changes' button to perform the update the user will press a 'New Query' button and go back to Page 1 with the original values cleared out.
    It sounds pretty straight forward but I know the 3-column PK creates some headaches.
    What I'd like is some guidance on what types of pages I need to create and how to clear out the parameter values.
    I was able to create a page with the parameters on it and get them assigned to the session variables but was not able to create the 2nd page that would even just report on the data based on the input parameters.
    I don't need the user to be able to add or delete rows, just update existing ones to correct data values.
    I'm continuing to go through the documentation and manuals but a little nudge in the right direction would certainly help.
    Many thanks for sharing your experiences.
    -gary

    Hi Ben and any others who elect to reply:
    Thanks to your guidance I've made some good progress. I have been able to create a parameter form that will accept part or all of my three (3) PK columns and put those in session variables. a 'GO' button is pressed and the 2nd page comes up which is based on a SQL query using the session variables from the first page and displays multiple rows of data. It even shows the correct data!
    I also modified the non-PK column attributes to make them updatable, at least I can over-type what shows up.
    The issue I'm struggling with now is how to get the COMMIT to happen to the database. I have an 'APPLY CHANGES' button on my report page and I thought I was relating that to a simple 'COMMIT' PL/SQL page process, but nothing gets committed.
    Do I need to code a manual version of a multiple row update (MRU)?
    If so, how do I do that?
    If not, what basic piece of understanding am I missing?
    Many thanks for your help.
    -gary

  • Order of the sql operation

    hi experts,
    I want to clear my basic concepts here.
    I want to know the order of the sql operation.
    actually the problem with me that i have read from different blog and websites
    about the order of operation of the sqkl queries , hence i am confused here.
    what i think the order of operation iis
    -----------MY assumptuion---------------------
          From
           |
          where
           |
          group
           |
          having
           |
          select
           |
          order by
    is my assupmtion is correct?
    if yes , then if suppose there is rownum clause in my selection criteria,at which timing
    will it apply?
    on some site i have seen below criteria
    1. The FROM/WHERE clause goes first.
    2. ROWNUM is assigned and incremented to each output row from the FROM/WHERE clause.
    3. SELECT is applied.
    4. GROUP BY is applied.
    5. HAVING is applied.
    6. ORDER BY is applied.
    is this correct or my assumption is correct?
    thanks a lot in advance..!!
    regards,
    prashant

    Hi Prashant,
    Instead of memorizing, why not check the query plan -
    -->-- Creating a test table
    CREATE TABLE test_tbl as
      SELECT 'A' name, 100 sal FROM dual UNION ALL
      SELECT 'A' name, 120 sal FROM dual UNION ALL
      SELECT 'B' name, 66 sal FROM dual UNION ALL
      SELECT 'C' name, 20 sal FROM dual UNION ALL
      SELECT 'C' name, 50 sal FROM dual UNION ALL
      SELECT 'C' name, 60 sal FROM dual UNION ALL
      SELECT 'D' name, 90 sal FROM dual UNION ALL
      SELECT 'D' name, 110 sal FROM dual;
    -->-- Query explain plan
    EXPLAIN PLAN for
    SELECT name, SUM(sal) sm
    FROM test_tbl
    GROUP BY name
    HAVING Sum(sal) > 150
    ORDER BY sm;
    -->-- Fetching the plan from cursor pool
    SELECT *
    FROM TABLE(dbms_xplan.display);
    -->-- Query plan
    PLAN_TABLE_OUTPUT                                                               
    Plan hash value: 3401269832                                                     
    | Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |          |     8 |   128 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY       |          |     8 |   128 |     5  (40)| 00:00:01 |
    |*  2 |   FILTER             |          |       |       |            |          |
    |   3 |    HASH GROUP BY     |          |     8 |   128 |     5  (40)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| TEST_TBL |     8 |   128 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):                             
         2 - filter(SUM("SAL")>150)                                                                                       
    Now, how to read the plan?
    Start reading the plan - with the line "Operation" indented towards extreme right. Line-4 in this case.
    Note: If two lines are indented similarly i.e. on same vertical line... read normally as-in order.
    Like this:
    | Id  | Operation            | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |            |     8 |   128 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY       |            |     8 |   128 |     5  (40)| 00:00:01 |
    |*  2 |   FILTER             |            |       |       |            |          |
    |   3 |    HASH GROUP BY     |            |     8 |   128 |     5  (40)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| TEST_TBL_1 |     8 |   128 |     3   (0)| 00:00:01 |
    |   5 |     TABLE ACCESS FULL| TEST_TBL_2 |     8 |   128 |     3   (0)| 00:00:01 |
    Read: line 4 and then line 5, since both are on same vertical level.
    Final sequence:
    1- (Line 4) Table Access : FROM clause
    2- (Line 3) GROUP BY
    3- (Line 2) Filtering : WHERE clause
    4- (Line 1) Sorting : ORDER BY clause
    5- (Line 0) SELECT
    Hope this helps.
    -- Ranit

  • Newbie Question:  How much computer do I need?

    Newbie Question:
    I would like to use MainStage 3 in a live performance environment to play bars, parties, etc.  I'm not looping, using it to playback recordings, processing outboard equipment or vocal processing.  I want to stop carrying Rolands, Nords, Korgs, etc and get to a controller and a rack with a Mac Mini in it.
    I tested a download of Mainstage 3 on my home Mac Mini (late 2012, 3.5 Ghz i5, 4GB RAM, 500GB drive) and it seemed to run fairly well.  $30 well invested so I trekked forward... I purchased a Mac Mini (late 2009,  2.52GHz Core 2 Duo, 6GB RAM, 128GB SSD) for $200.  I started to do more elaborate keyboard setups to see how the CPU would hold up.  It typically runs from 30% to 50% of capacity (CPU and Memory)  It actually boots and runs better than the i5.  I hear the occasion gitch, but it actually seems to be getting better in time (or I'm rock and roll deaf.
    I got a rack, an Airport Express, a Radial USB interface and a Nektar Panorama P6.  It's starting to get expensive, but I'm emboldened by the actual quality for the sound and the flexibility of arranging for live performance.  What used to take me two and three keyboards to play, I can now fit on one performance patch.
    OK, now the question... am I at the limits of this little Core 2 Duo?  Should I upgrade the i5 with more RAM and a bigger SSD and use that?  Should I get a new(er) i7 and bite the $1,500 bullet for the additional RAM and SSD?
    I see that most of you are running pretty nice Macbook Pros with i7 and lots of everything.  My needs are modest; am I OK? 
    BTW, I want to run a Mac Mini in a box because I don't want to carry a laptop out in the open.  If I was doing bigger shows I wouldn't care but I play some rowdy bars and constantly have folks hanging off me while I'm playing.  It's fun, but hard on gear.  If you can't drop it or dip it in beer, it won't last long where I work.
    Matt Donnelly

    Rule of thumb: newer and faster is better. But, depending the complexity of your needs you may be OK with an older Mac. Some glitches that happen in a live performance are due to loss of communication with USB or Firewire inputs, so make sure they're secure. I recently upgraded from a 2010 Mac Mini 2.6 dual core with 16 GB RAM, which was used live for nearly four years, to the latest Mac Mini 3.0 i7 with 16 GB RAM and a 500 GB SSD. I was getting an occasional stuck note with the older one. The new one is rock solid. Some of my patches may have up to a dozen channel strips mapped to three keyboards. The Mini is mounted in a rack next to a MOTU Ultralite Hybrid. It is a good idea to map a panic button on your keyboard to controller # 123(all notes off). Also, you might want to invest in a battery backup power supply(APC, Cyberpower, etc.-$40-$60) to protect your Mac against power loss, which can damage you hard drive.

Maybe you are looking for