How can I get the same result using single query?

There are 3 tables
1) tool_desc -
a master table for storing tool records,
columns tool_no, tool_chg,
# of records = 1.5 Millon
2) step_desc -
a master table for storing plan wise step records,
columns plan_id, step_key,
# of records = 3700 Million
3) step_tool - a transaction table storing tools to the steps,
columns plan_id, step_key, tool_no, tool_chg
For each step in the step_desc table, I need to randomly fetch 1 to 50 tools from tool_desc and insert them into step_tool table.
Using PL/SQL block, it is like the following -
begin
for x in (select plan_id, step_key from step_desc) loop
insert into step_tool(
plan_id,
step_key,
tool_no,
tool_chg)
select
plan_id,
x.step_key,
tool_no,
tool_chg
from
tool sample(0.1)
where
rownum <= trunc(dbms_random.value(1,51))
commit;
end loop;
end;
I need to do the same using a single query so that I can use the CTAS (create table as select) statement and load the data as a bulk.
Can I do that?

If they have parent child releation, you can use connect by prior clause,

Similar Messages

  • How can I get the avaiable datatypes using single query?

    Is there any sql query to determine available datatypes along with their size lime in the current version of Oracle ?

    If they have parent child releation, you can use connect by prior clause,

  • How can I get the same session with jdbc?

    HI
    After I create or use a JDBC connection,
    i do a query.
    How can I get the same session next time?
    thanks a lot!

    Hi qin,
    Unless I have misunderstood your question, a 'connection' and a 'session' are the same thing. When you obtain a database connection, you have created a database session. Once you close that connection, the session dies -- it no longer exists. You cannot obtain the same 'session' when you get another database 'connection' (after you closed the first one).
    Hope this answers your question.
    Good Luck,
    Avi.

  • How can i get the same itunes library on 2 macs

    how can i get the same itunes library on two different macs, without having to pay for icloud please.

    Copy everything from one computer to the other.

  • HT204053 If I have an apple ID for myself and my wife has just got a iPhone for the first time how can she get the same apps as I have for my iPhone and iPad

    If I have an apple ID for myself and my wife has just got a iPhone for the first time how can she get the same apps as I have for my iPhone and iPad by getting it off my iCloud?

    She can't from iCloud without setting up your iCloud account on her phone. But just sync the same apps from your iTunes Library on your computer to her phone.
    Your wife should setup her own iCloud account - which is separate to the iTunes Store accounts.

  • How can I get the same candy crush level on my phone and iPad?

    How can I get the same candy crush level on my phone and iPad?

    The only way to synchronize is connecting to FaceBook. I just set up my girl friend's iPhone to connect with FaceBook, which then updated the phone's level; then I downloaded the app (again) on her iPad and selected connect to Facebook. I'm not sure what the downfall of synchronizing through FaceBook is.... all I can tell you is it worked and now her iPad shows the same level as her iPhone. Good luck!

  • How can you get the schedule of a single reoccurring job with Restart ability in Redwood to pause when it has failed...?

    We need the Request Restart ability when scheduling a single reoccurring job in Redwood. Most of our jobs are scheduled in CHAINs which offers the Final Status Handler on Step level, and the schedule is "paused" when a job in the CHAIN has failed ( the next instance does not populate until the OP MSG has been Replied to) , and once the OPERATOR message is replied to, the CHAIN can resume running again ( desired ) . But we need this same ability when scheduling a single job not in a CHAIN. In our testing, we set up a job with Request Restart chosen on the Error , Killed and Unknown selections on the Restart Behavior Tab. But we found when a job is scheduled say once a day at 8AM, and when it fails, an OPERATOR msg appears allowing a Restart choice ( desired), but the next day's schedule also populates ( undesired) and we do NOT want the schedule to continue on yet because we need a chance to fix the error before the next insance runs for business reasons. So how can you get the schedule of a single reoccurring job with Restart ability in Redwood to pause when it has failed...?

    Hello Fran,
    You can wrap the job chain in a master job chain in the first step and set the final status handler there.
    You can also set the Restart Behavior to 'Stop Submit Frame', in that case you will have to resubmit the job once you are finished troubleshooting.
    Regards Gerben

  • How do I get the same results as "Variations"?

    Hi All
    I've just bitten the bullet and subscribed to Creative Cloud.
    I've brought many old actions across, and the ones that contain a "Variations" step fail.
    Having looked at many posts I appreciate that Variations is gone, and doesn't seem to be coming back any time soon.
    Many people point out that the same results can be achieved via levels, curves, colour balance etc.
    Looking at the variations step in an action (in an older PS version) shows a series of values, for example:
    Red Gamma: 3.086
    Green Gamma: 1.73
    Blue Gamma: 0.552
    Red White Point: 247
    Green White Point: 247
    Blue White Point: 247
    Red Black Point: -1
    Green Black Point: 0
    Blue Black Point: 3
    Saturation: 90
    How can these numbers be used to amend the actions and give the same result via other means?
    Thanks

    The variations are/were used in a product design context, to take a standard component and produce colour versions.
    (So no photos to upload, and commercially sensitive images)
    Variations was really convenient to use with the client - "a bit redder, bit darker" etc. and usually were the final step after a load of other Hue/Sat/Levels/Curves steps.
    There's a lot of them and the original reference objects are no longer available. 
    I've been doing some tests today with references taken from expanding the "variations" step within the old actions like those above.
    Using "Levels" and the Black Point, Gamma and White Point values in the relevant RGB channels gets close, (slightly off as it doesn't accept to 3 decimal places so rounds them).
    However it comes unstuck as some of the Black Point values are less than 0 and there are White Points greater than 255, (-1 in the example above but some white points are at 263).
    Also the Saturation value doesn't seem to relate to the usual method.
    I'd understand more (whilst not being entirely happy) if they'd canned it completely when moving to 64bit, but JJMack points out that it was available in CC5, which I don't have and would be unsupported now anyway.
    Those numbers must mean something.

  • How can I get the following result?

    Hi, I have table test:
    create table test(oper_date date, income number, expense number), there are several records in this table:
    20060101 100 10
    20060105 200 15
    20060106 150 12
    20060109 30 8
    I want to get the following result:
    20060101 100 10
    20060102 0 0
    20060103 0 0
    20060104 0 0
    20060105 200 15
    20060106 150 12
    20060107 0 0
    20060108 0 0
    20060109 30 8
    How should I write the sql?
    Please give some help!
    Thank you all!

    I used the script below:
    CREATE TABLE mhe_foo( oper_date DATE 
                        , income    NUMBER
                        , expense   NUMBER
    INSERT INTO mhe_foo VALUES(TO_DATE('20060101','YYYYMMDD'), 100, 10)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060105','YYYYMMDD'), 200, 15)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060106','YYYYMMDD'), 150, 12)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060109','YYYYMMDD'),  30,  8)
    SELECT v.oper_date
         , NVL(m.income,0)  AS income
         , NVL(m.expense,0) AS expense
    FROM   ( SELECT  mindt + level - 1 AS oper_date
             FROM    ( SELECT MIN(oper_date) mindt
                            , MAX(oper_date) maxdt
                       FROM   mhe_foo
             CONNECT BY mindt + LEVEL -1 <= maxdt
           ) v
         , mhe_foo m
    WHERE  v.oper_date = m.oper_date(+)
    ORDER BY v.oper_date
    DROP TABLE mhe_foo
    /I saved it as C:\T1\myscript.sql and ran it:
    SQL> @C:\t1\myscript
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    OPER_DATE     INCOME    EXPENSE
    01-JAN-06        100         10
    02-JAN-06          0          0
    03-JAN-06          0          0
    04-JAN-06          0          0
    05-JAN-06        200         15
    06-JAN-06        150         12
    07-JAN-06          0          0
    08-JAN-06          0          0
    09-JAN-06         30          8
    9 rows selected.
    Table dropped.
    SQL>MHE
    Message was edited by:
    maaher

  • I want to use the ethernet connection from my new iMac to my Time Capsule.  It seems only the Wifi is seen by either device.  Ive connected the Time Capsule to the iMac.  How can I get the iMac to use the wired connection

    I want to connect my iMac to my Time Capsule using Ethernet.  I have them connected via an Ethernet cable, but only WiFi seems to be working.  How can I specify the Ethernet connection instead of WiFi?  Thanks
    Welked

    Go to preferences, network and see if ethernet is indicated. Be sure it shows a green dot.  Also be sure it is at the top of the list (above WiFi).  If not click on the the wheel at the bottom and set service order.

  • How can I get the following results?

    Hi, I have a table:
    fphm,kshm
    2014,00000001
    2014,00000002
    2014,00000003
    2014,00000004
    2014,00000005
    2014,00000007
    2014,00000008
    2014,00000009
    2013,00000120
    2013,00000121
    2013,00000122
    2013,00000124
    2013,00000125
    And I want get the following results:
    2014,00000001,00000005
    2014,00000007,00000009
    2013,00000120,00000122
    2013,00000124,00000125
    And what should the sql is?
    Please give me some guide!
    Thank you all!

    Hi,
    Well, what did you say about his :
    SQL> select * from tbl;
          FPHM       KSHM
          2014          1
          2014          2
          2014          3
          2014          4
          2014          5
          2014          7
          2014          8
          2014          9
          2013        120
          2013        121
          2013        122
          FPHM       KSHM
          2013        124
          2013        125
    13 rows selected.
    SQL> select fphm, min(kshm),max(kshm)
      2  from
      3  (select fphm, kshm,
      4          kshm-rank() over (partition by fphm order by fphm,kshm) rk
      5   from tbl)
      6  group by fphm,rk
      7  order by fphm
      8  /
          FPHM  MIN(KSHM)  MAX(KSHM)
          2013        120        122
          2013        124        125
          2014          1          5
          2014          7          9
    SQL> insert into tbl values (2013,123);
    1 row created.
    SQL> select fphm, min(kshm),max(kshm)
      2  from
      3  (select fphm, kshm,
      4          kshm-rank() over (partition by fphm order by fphm,kshm) rk
      5   from tbl)
      6  group by fphm,rk
      7  order by fphm
      8  /
          FPHM  MIN(KSHM)  MAX(KSHM)
          2013        120        125
          2014          1          5
          2014          7          9
    SQL> Nicolas.

  • How can i get the same high definition i see on my iPad to mirror to my tv?

    I am using my LGTV to watch shows I am streaming on my iPad. The iPad is small, the picture quality is great. But when I use airstream to push it through my apple TV, the picture is blurry. I realize I am going from a small iPad screen to a large TV screen, but is there any way to sharpen the larger image?

    The content is the same, it would have nothing to do with going from iPad to ATV. There may be an issue with the network.
    Reboot both devices.
    If on wifi try ethernet
    Go to istumbler, netstumbler or similar to get a report of the network, look for signal strength and noise.

  • How can I get the same site on 2 machines?

    I have an iBook G4 and an iMac G5. currently the iBook is where my iWeb site is made and published. I want to have the same site in my iWeb on my iMac. I have tried making a copy of the site files from the iBook and pasting them in my iMacs iweb directory... but iWeb doesnt show my site. It thinks it doesnt have a site yet...
    Any help??
    Rome

    Your iWeb data is stored, not in your actual html files, but in a file called Domain.sites which is stored in your Home/Library/Application Support/iWeb folder. If you want to work on your site on another computer, copy this file to a thumb drive to move it around.
    You should backup this file whenever you make big changes to your site, because if it gets lost or damaged, you will have to start all over. Sadly, many many people learn this the hard way.
    I have an Automator app on my site that will help you backup your Domain file(s). Click here to download it or visit http://iweb.varkgirl.com for more info. The app will make a .zip file of your Home/Library/Application Support/iWeb folder and save it to a location of your choosing.
    Then check out Mozy for an online place to store your backups - I just found this and it seems great. They just recently released a Mac friendly version of their app - it automates the upload and encryption. You select the files you want to backup and it does the rest. You can set it to upload automatically after so many minutes of inactivity or once a day. It does it all in the background so you don't have to worry about it! 2GB of storage are free - plenty of room for most people's iWeb Domain.sites backups!

  • HT2731 The appleID on my phone is not the same as on my itunes account. How can I get the same on both my iphone and itunes?

    How can I match my apple ID for itunes and my apple ID on my cellphone?

    Do you have multiple accounts or have you updated your account on your computer's iTunes and the update hasn't copied over to your iPhone ? If you've updated your account then tap on your id in Settings > iTunes & App Stores on your phone and log out of it and then log back in with the updated version.
    If you have multiple accounts then you can log out of your account on your phone as above, or your computer's iTunes via the Store > Sign Out menu option, and you can then log in with the other account. But all content is tied to the account that downloaded it.

  • How can I update the table with a single query for...

    I have a table with columns C1 and C2.
    C1 C2
    A1 null
    A1 null
    A1 null
    A1 null
    A2 null
    A2 null
    A2 null
    A3 null
    A4 null
    A4 null
    I want to update my table with a single query so that I would have data like
    C1 C2
    A1 1
    A1 2
    A1 3
    A1 4
    A2 1
    A2 2
    A2 3
    A3 1
    A4 1
    A4 2
    The updated column C2 has the values like serial no grouped on the column C1.

    SQL> create table mytable
      2  ( c1 varchar2(2)
      3  , c2 number(2)
      4  )
      5  /
    Tabel is aangemaakt.
    SQL> insert into mytable (c1)
      2  select 'A1' from dual union all
      3  select 'A1' from dual union all
      4  select 'A1' from dual union all
      5  select 'A1' from dual union all
      6  select 'A2' from dual union all
      7  select 'A2' from dual union all
      8  select 'A2' from dual union all
      9  select 'A3' from dual union all
    10  select 'A4' from dual union all
    11  select 'A4' from dual
    12  /
    10 rijen zijn aangemaakt.
    SQL> select * from mytable
      2  /
    C1                                     C2
    A1
    A1
    A1
    A1
    A2
    A2
    A2
    A3
    A4
    A4
    10 rijen zijn geselecteerd.
    SQL> merge into mytable t1
      2  using (select c1
      3              , row_number() over (partition by c1 order by null) rn
      4              , rowid rid
      5           from mytable
      6        ) t2
      7     on (t1.rowid = t2.rid)
      8   when matched then
      9        update set c2 = rn
    10   when not matched then
    11        insert values (null,null)
    12  /
    10 rijen zijn samengevoegd.
    SQL> select * from mytable
      2  /
    C1                                     C2
    A1                                      1
    A1                                      2
    A1                                      3
    A1                                      4
    A2                                      1
    A2                                      2
    A2                                      3
    A3                                      1
    A4                                      1
    A4                                      2
    10 rijen zijn geselecteerd.Regards,
    Rob.

Maybe you are looking for