Mergeing multiple procedures in one package?

Hello gurus,


I m moving data from a diagram i, e la source (SRC) schema to the schema an another i, e target (trg) table, only selected columns of a few tables (i, e for 4 tables)


I m, writing procedures to achieve and maintain this procedure a planner on a daily basis to load



I m 4 procedures of writing for each of the table... is the procedure that I got
 

   create or replace procedure mov_tbl1
   is 
    cursor tbl1_cur as
      select  src.col1,
                 src.col2,
                 src.col3,
                 src.col4
         from source.tbl1 src
          where col1 = ' xyz'
       
    tbl1_cur_rec   tbl1_cur%rowtype;
        
      begin 
            for  tbl1_cur_rec  in tbl1_cur
            loop 
                insert into tgt.tabl1(col1,col2,col3,col4)
                      values (   tbl1_cur_rec.col1,
               tbl1_cur_reccol2,
               tbl1_cur_rec.col3,
               tbl1_cur_rec.col4);
                     commit
                  exception 
                     when others then 
                        rollback;
              end loop;
      end;

   ---for table 2
create or replace procedure mov_tbl2
   is 
    cursor tbl2_cur as
      select  src.col1,
                 src.col2,
                 src.col3,
                 src.col4
         from source.tbl2 src
          where col3 = ' abc'
       
    tbl2_cur_rec   tbl2_cur%rowtype;
        
      begin 
            for  tbl2_cur_rec  in tbl2_cur
            loop 
                insert into tgt.table2(col1,col2,col3,col4)
                      values (   tbl2_cur_rec.col1,
               tbl2_cur_reccol2,
               tbl2_cur_rec.col3,
               tbl2_cur_rec.col4);
                     commit
                  exception 
                     when others then 
                        rollback;
              end loop;
      end;

   
same procedures for table 3 and table 4...

Here's my question...
  

1.How can i build a single package for all these four procedures in one package ???
2. ANd i don't want to call each procedure every time ...so can i do it by passing parameters ???  how can i accomplish that ??

 
I m back to writing packets... all help is greatly appreciated... Thank you so much gurus!

First your code does not compile because the exception block is inside the loop while begin and end are on the outside.
You must decide whether a row error should invalidate the full load or if the wrong single line must be rejected, but all other lines have been downloaded.
I guess you need that last so I change the code as follows:

create or replace procedure mov_tbl1
   is
    cursor tbl1_cur as
      select  src.col1,
                 src.col2,
                 src.col3,
                 src.col4
         from source.tbl1 src
          where col1 = ' xyz'
       -- the record variable declaration is implicit in FOR LOOP
      begin
            for  tbl1_cur_rec  in tbl1_cur
            loop
              begin
                insert into tgt.tabl1(col1,col2,col3,col4)
                      values (   tbl1_cur_rec.col1,
               tbl1_cur_reccol2,
               tbl1_cur_rec.col3,
               tbl1_cur_rec.col4);
                     -- REMOVED COMMIT, Commit outside or at the end.
                  exception
                     when others then
                       null; -- May be is better to (somehow) log the error ...
              end;
            end loop;
      end;

On the package, create you it in this way:

create or replace package p is
procedure upd (tab1 in boolean, tab2 in boolean, tab3 in boolean, tab4 in boolean);
end;
/

create or replace package p is
procedure upd (tab1 in boolean, tab2 in boolean, tab3 in boolean, tab4 in boolean) is
begin
  if tab1=true then
     mov_tbl1;
  end if;

  if tab2=true then
     mov_tbl2;
  end if;

  if tab2=true then
     mov_tbl2;
  end if;

  if tab2=true then
     mov_tbl2;
  end if;
end;

procedure mov_tbl1   is
    cursor tbl1_cur as
      select  src.col1,
                 src.col2,
                 src.col3,
                 src.col4
         from source.tbl1 src
          where col1 = ' xyz'
       -- the record variable declaration is implicit in FOR LOOP
      begin
            for  tbl1_cur_rec  in tbl1_cur
            loop
              begin
                insert into tgt.tabl1(col1,col2,col3,col4)
                      values (   tbl1_cur_rec.col1,
               tbl1_cur_reccol2,
               tbl1_cur_rec.col3,
               tbl1_cur_rec.col4);
                     -- REMOVED COMMIT, Commit outside or at the end.
                  exception
                     when others then
                       null; -- May be is better to (somehow) log the error ...
              end;
            end loop;
      end;

procedure mov_tbl2   is ...

procedure mov_tbl3   is ...

procedure mov_tbl4   is ...

end;
/

You can call the procedure upd (calling others) this way:

begin
  p.upd(true,false,true,false);
end;
/

Update only table1 and table3.

Max
http://oracleitalia.WordPress.com

Tags: Database

Similar Questions

  • IDCS6 MACOSX JS: data merge multiple txt files one after the other

    Hello everyone.

    I have a situation where I have to data merge multiple text files to a single file indesign real "base". Databases formats are the same, the point of difference is a code in the second field of the database that refers to a postal box (not a zip/postal code, a code of 'distribution center' that has possibilities of 56 or greater). I would prefer data merge a file and then somehow split the PDF via Acrobat, but the length of postal areas resulting is incompatible and something that cannot be done if the document "split" feature in acrobat.

    The database starts as one massive file but using a one line code, can be divided into postal areas in separate text files.

    My last question: is it possible data merge several files at the same time (for example one after the other) and to give them their names based on the names of the input text file?

    OLE Kvern had a script to merge the data to a file without the user interface. I changed the last line slightly so that it generates a PDF file based on [high quality]:

    if(app.documents.length != 0){
            var myDocument = app.activeDocument;
            app.dataMergeOptions.removeBlankLines = true;
            //Select a source file.
            var myDataFile = File.openDialog("Select a data file")
            var exported = "file location(redacted for the sake of this post)"
            if(myDataFile != ""){
                    myDocument.dataMergeProperties.selectDataSource(myDataFile,);
                    myDocument.dataMergeProperties.exportFile(exported,"[High Quality Print]",);
            }
    
    }
    

    I guess that the answer has to do with the variable "myDataFile" and rather than just being open a dialog box, it could be somehow by selecting a table of text files, but it is where I am out of my depth.

    Ideas or thoughts which may not involve trying to do both the many mergers, but can somehow revolve around a great fusion of PDF?

    Thank you very much

    Colin

    Since writing my last response, I realized there was a better answer. It is a scenario of Peter Kahrel and a modified version of a script by Olav Kvern. Details can be found here: batch of merge data | Adobe Community

    I have since made other mods to the script is easier to understand:

    if(app.documents.length != 0){
    // make sure to use the document that is open
            var myDoc = app.activeDocument;
    // get the name of the document that is open for future naming purposes
            var myName = myDoc.name
    // get the location of the folder that contains both the indesign files and the text files
            var myLocation = "FULL PATH LOCATION OF FOLDER CONTAINING TEXT FILE AND DESTINATION FOR FINAL PDFS"
    // define the names of the data files to use based upon the names of the indesign files
            var myImport = myLocation + myName + ".txt"
    // define the names of the data merged PDFs to be created
            var myExport = myLocation + myName + ".pdf"
    // the actual engine for the merge, including DM instructions such as remove blank lines, object fitting etc.
            var myDataFile = myImport
            app.dataMergeOptions.removeBlankLines = true;
            if(myDataFile != ""){
                    myDoc.dataMergeProperties.selectDataSource(myDataFile,);
                    myDoc.dataMergeProperties.exportFile(myExport, "[PDF/X-1a:2001]", );
            }
    
    }
    

    If this script will automatically merge a file which is open as LONG as the data file is the same name as the indesign file with .txt at the end for example

    Woodward.indd (indesign file)

    Woodward.indd.txt (used for merging text file)

    This script does still not the original memory and who was using an indesign document, to browse for many text files and merging of PDF based on text files.

    HOWEVER, I am sure that the answer to that is based only on the use of the script above (no need to Peter batch convert script) and changing the line 9 to be a loop for... but again, this is where I come to a grinding halt. Any help would be appreciated.

    Colin

  • Procedure call to the procedure in one package

    Hello

    I need help to call a procedure within a package.

    I have an ABC package in which I have 3 X Y and Z I procedures I need to call the procedure procedure Y X that belongs to the same package.

    Thanks in advance

    I need to call the procedure procedure Y X that belongs to the same package.

    Just make sure that this procedure that is has been defined before the X procedure in the package body. However, there no need this if the two procedures are also defined in the package specification.

  • Merges multiple data on one page

    I created a post card that I need to be sent to customers. To save money, we put three postcards on 12 x one 18 sheet of paper. I'm putting three mergers of data on each sheet for the addresses of customers. Is this possible? I can provide a picture if necessary.

    Hi ryaniscreative,

    It is quite possible, as I often do for the variable data on labels Avery labels. However, our printer should be able to get this done for you automatically if you print this digitally. Our Canon printers have the ability position (front and back) 2 - up, 3 copies files, etc. I don't know that this is the case for most digital printers on the market. Ask your printer and they should do it automatically, in which case you build the file at full size and merge data as usual.

    Never-the-less, here's how do it manually:

    1. create your 12 "x 18" document in InDesign CC (2014).

    2. drag your postcard art 12 "x 18" paper and create crop marks manually for this model of postcard art.

    3. position the art of model of post card in the upper left corner of the document.

    4. card all of your variables as usual in this art of model of a postcard on the two pages to your. CSV file.

    5. in your data merge Paletteand in the Drop Down Menu in the upper right hand corner, select create a new Document merged.

    6. in the section of documents for the Page of the Document , select multiple records and then at the bottom of the dialog box select Overview several cliché registration.

    7. click on the multiple record layout tab.

    8. adjust the margins and the spacing between the columns in the dialog boxes depending on your intention of positioning and design specifications.

    9. press the OK button so that InDesign can start to create a merged document on all of your variables.* list *.

    * If you just want to generate a PDF file then in step 5, instead of select Create a merged Document hit export to PDF.

    NOTE: This is possible with a unilateral design. If you need to print graphics across the postcard (for purposes of dissemination of course), you will have to do this process again exactly the same way, in another document InDesign manually create pages between existing on the front pages and then paste in place, to another InDesign document.

  • fusion of procedures in the package and calling with common proc?

    Hello

    I wrote similar procedures... and I'm calling each procedure separately and transmitting his values...

    something like that
     
    
       begin 
       mov_tbl1(1234); 
       end 
    
    then again similarly for 
    
       begin 
       mov_tbl2(1234); 
       end;    
       
    My question is how to merge these two procedures in one package and call them with a common procedure and pass the value (var_id) once for procedures?
     
    create or replace procedure mov_tbl1 ( var_id number)  is 
             
             cursor tbl1_cur as 
             select  src.col1, 
                     src.col2, 
              from abc_tbl1 tbl1, 
                   abc_tbl2 tbl2 
              where tbl1.no = var_id  -- this is variable i m trying to make it as a paramter in common proc 
                    tbl1.id = tbl.id 
                   -- the record variable declaration is implicit in FOR LOOP 
          begin 
                for  tbl1_cur_rec  in tbl1_cur 
                loop 
                  begin 
                    insert into tgt.tabl1(col1,col2) 
                                values (tbl1_cur_rec.col1, 
                                    tbl1_cur_reccol2, 
                            ); 
                            exception 
                         when others then 
                           null; 
                  end; 
                end loop; 
          end; 
    
    
    create or replace procedure mov_tbl2(var_id number) is 
        
           cursor cur_tbl2 
             select col3,col4, col5 
               ...... 
             from abc_tbl1 tbl1, 
                   abc_tbl2 tbl2, 
                   abc_tbl3 tbl3 
            where   tbl1.no = var_id and   --this is variable i m trying to make it as a paramter in common proc 
                    tbl1.id = tbl.id and 
                    tbl2.dept = tbl3.dept 
              begin 
                  for ... 
                    loop ... 
                      insert into ... 
                         values.... 
             .... 
              end; 
      
    I m bit confused, if you want to use the parameter or parameter... .i am beginner in writing packages... :))
    Ideas or examples is greatly appreciated! Thank you very much!!

    Check if all parameters have been assigned to certain values.

    And call the procedure that is packaged with the following syntax.

    Begin
    .(parameter_value);
    end;
    
    i.e.
    Begin
    TEST_PACK.COMMON_PROC(1234);
    End;
    

    Can you post the code here so that we can have a look at what goes wrong.

    Here is a test package I ran

    PRAZY@11gR1> create or replace package test_pack as
      2  procedure common_proc(var_id number);
      3  end;
      4  /
    
    Package created.
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> create or replace package body test_pack as
      2  procedure private_proc1(var_id number) as
      3  begin
      4  dbms_output.put_line('FROM PROC1 :'||var_id);
      5  end;
      6
      7  procedure private_proc2(var_id number) as
      8  begin
      9  dbms_output.put_line('FROM PROC2 :'||var_id);
     10  end;
     11
     12  procedure common_proc(var_id number) as
     13  begin
     14  private_proc1(var_id);
     15  private_proc2(var_id);
     16  end;
     17
     18  end;
     19  /
    
    Package body created.
    
    Elapsed: 00:00:00.04
    PRAZY@11gR1> begin
      2  test_pack.common_proc(100);
      3  end;
      4  /
    FROM PROC1 :100
    FROM PROC2 :100
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.01
    

    Kind regards
    Prazy

  • Debug/run procedures within the package

    Debugging with SQL Developer was generally very nice and I have come to rely on these tools. Today, I've written a procedure in a package and I want to debug this process, but I don't see it in the list of targets. It seems that I see only functions in the target list. I understand that the procedures need not have the same kind of output in function, but sometimes I like to create procedures that have multiple SETTINGS, especially when it comes to an exit very closely related.

    The interesting thing is that I can create this same procedure as a stand-alone procedure and the run/debug works great. Apparently I'm missing something obvious in SQL Developer somewhere I thought it was there all the time (I guess for a while since I've written a procedure with OUT parameters) but maybe I'm wrong. Any ideas or help someone?

    Earl

    It should work.

    Is that you can create a package of simple heel with just a function procedure that is a NULL; and use it as a test?

    If this does not work there either, please send a screenshot so we can see what you see in the debugging with the missing procedure dialog box.

  • Can only establish us a specific procedure in the package body?

    Hi experts

    Say we have a package as follows:

    package my_package

    a procedure;

    procedure b;

    procedure c;

    end packege my_package;

    my_package package body

    procedure a

    is

    ....

    end;

    procedure b

    is

    ....

    end b;

    procedure c

    is

    ....

    c end;

    end of packet my_package;

    I want to only change the procedure has, should I compile the body together for this? Can I do to compile the procedure like the following?

    create or replace the my_package.procedure one

    is

    ....

    end my_package.a;

    Thank you

    Hello

    No, you must recompile the entire body.  There is no way to compile a procedure in the package.

  • Merge multiple images into a single file

    Hi all

    I am writing because I need to merge multiple images into a single file and do not know how.

    I need to create a large table with several aerial photographs, so I didn't need to create a panorama, but I would like to use an automatic procedure to merge the images because they are many.

    Can you help me??

    I tried photomerge but it creates more levels without ordering the photos...

    If all the files are the same size, there is a script "File Stitcher" @ http://www.ps-bridge-scripts.talktalk.net/

  • __Is - it a way to "merge" multiple curves in a single curve?

    __Is - it a way to "merge" multiple curves in a single curve?

    By that I mean I have file with layers of curve 2-12 - I wanted to "merge" the curves so that I can end up with a single curve with the attributes of a lot. Maybe there at - it a script that would do this?

    I don't want to not be critical, but how get you to a situation where you have 12 layers of curves?

    The advantage of a curves layer is that you can adjust and re - adjust to your heart's content.

    If you usually add new curved layers one over the other, maybe you should re - evaluate your work process.  Maybe bit depth the way you think you should operate at a high level and make the operations of curves on the pixels?  Or put some time in retraining yourself do not add a new layer of curves but to manipulate that is already there.  There are some nice new improvements (e.g., subtool 'finger' that allows you to choose a location for the image and manipulate this part of the curve).

    Once again, I don't mean to criticize you, just look to see if maybe there's a way to avoid getting to the point where you need to combine the curves in the first place, since there is no direct possibility of "Merge curves", apart from the stamping a whole layer image and adjustment in pixels.  To be complete, I guess I should mention how...  Any combination of visible layers into a single layer of pixels (effectively combining all the curves layer and al.), you can stamp by pressing Ctrl - Shift - Alt-E.

    -Christmas

  • Data merge multiple records do not work

    Hi all

    When you try to merge multiple records, the result is the same if I selected just a recording.

    Here's the situation:

    Source file:

    • Excel file with several records, saved as a csv and txt

    The target file:

    • InDesign CS4 file with a single page.
    • framework of a text on the page,
    • a table with the header line and a line of body
    • every cell of body line contains a data field

    I went through all the necessary steps:

    • Choose the data source file (tried with csv and txt, the results are the same) and insert the fields in the table
    • chose "All records" to merge
    • to merge records: selected multiple records

    After choosing "Preview", I see only one record per page, and the new pages are created automatically for EACH record! This is not what I want.

    What I want is for as many records if poster in the table as possible and then to InDesign to create additional if necessary pages.

    What I am doing wrong, or isn't it possible?

    Thank you for all your comments!

    Several records, ID to duplicate everything on the page, so unless there is enough space for all of this, you will get several records.

    Think of it as a frame around all your items, group, then using the step and repeat, except merge data won't allow any element to extend beyond the edge of the drawing page.

  • How to move photos from multiple folders into one

    Hello!

    I exported photos of iPhotos to a folder on the Mac.

    He saved every moment in different folders.

    I want to combine them all, so that all the photos are in a single folder.

    How can I combine these multiple files from multiple folders into one?

    Thank you very much for your help!

    (PS next time I will not include fracture m´by moments, but for now, how do I fix?)

    Drag and drop one folder to the other.

  • How can I have multiple images in one frame in movie maker?

    Hello

    I would like to know how I can include multiple images in one frame in movie maker?

    Thank you.

    It would be useful to know exactly what you want to create.

    You can prepare the images in an image editing program
    before you import into Movie Maker.

    Picasa free software can make collages:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Picasa
    http://Picasa.Google.com/
    (for Windows XP/Vista/7)

    Tutorial Picasa: Collages: creating a montage
    http://Picasa.Google.com/support/bin/answer.py?hl=en&answer=19539
    (Photo battery option would be worth)

  • Move multiple files from one folder to another in SkyDrive?

    How can I move multiple files from one folder to another in SkyDrive?  When I click on a file, & then use CTRL-click on another file, it moves to that one.  Can I select multiple files & copy or move or rename on PC?

    For now - not.  SkyDrive Wave5 or anyone should have this ability when it is fully released.

    http://www.LiveSide.NET/2011/09/06/SkyDrive-wave-5-to-finally-support-multiple-files-selection/

    (Read and also read comments on things, you might be able to use now to accomplish what you want).

  • ODP 12 c version 3 with EF 6.1.1 I can't add Stored Procedure of a package to my model

    I use the ODP 12 c Release 3 (12.1.0.2.1), with Entity Framework 6.1.1 with the first database in MS Visual Studio 2013 update 4

    I have a MVC 5 (.Net Framework 4.5.2) project that connects to Oracle 11 G R2 Database server, an existing database (Tables, views and a pack of Stored procedures)

    I can add tables and use them successfully in my model
    I can add a simple stored procedure

    Here's the problem:
    I have my .edmx file right click and click on "update model from database...". «, on the 'Add' tab, I chose «Stored procedures and functions»
    I can see the list of procedures stored in the package (format packageName.usp) and check the box for the stored procedure of my package, then click 'Finish' to start the update process.

    No stored procedures have been added to my Model.Store


    The only possible exit I get the 'entity data model' is:
    Generated template file: Model1.edmx.
    Loading metadata from the database took 00:00:00.5803351.
    The model generation took 00:00:00.3761861.

    How to add a stored procedure from a package with the Entity Framework 6.1.1?

    I found the answer.

    When in the edmx model and you right click "Update Model database.

    Uncheck "Import selected stored procedures and functions in the entity model", select the package and update procedures. (It works)

    Then in "Model Explorer" under "Model. Store\ stored procedures/functions" you will see your procedures in the package (finally). Then their card in "Function Imports".

    I don't understand why unchecking import stored procedures works, but it does.

    I also found easier to simply call the procedure directly and not using Entity Framework, as all my procedures are: insertion, update and deletions and not all parameters mapped on the model for the view.

  • How to merge multiple images into a single document and place them on the bottom

    I am trying to merge multiple images in a single document and arrange them on this document and save it.  Is it still possible?  There are five black and white drawings that I've resized at all have the same size.  Tutorials that I looked at, but it seems that everyone has another way to do this and all are very confusing.  Thanks for your help.

    It is not surprising that "everyone has a different way to do this." In Photoshop that is common. Try this:

    1. open a new file large enough to accommodate five drawings.

    2. open each design, click on it in the layers panel and drag and drop it in the layers panel to the new file.

    3. Repeat until all are in the new file

    4. use the move tool to reposition. (They are on separate layers)

    5 flatten the file if you wish (but save a version not flattened for future editing)

Maybe you are looking for