function and packages

Hi friends,

I have a requirement where in I need decode my source table values while inserting in my target table. I usually do my task by performing functions (don't use case and decode). My first question is

(1) is using the function to accomplish these tasks is good. I have several of these conversion requirements.
(2) Clubbing subprogrammes togther in packages is a good habit. But what should be the number of these subprogrammes. I can club togther 100 of this togther functions (a function of the average is 50 lines)? If this is not the case, what should be the thoughts of segregation?
(3) are the oracle integrated like sqrt, length etc. deterministic functions?

This code represents a typical requirement of the mine where in I map my name of source country in the target
ID of country when migrating my data from the source to the target.

create table source 
(
emp_id number,
empname varchar2(100),
sal number,
country varchar2(100)
);


insert into source values (1,'ALEX',1000,'US');
Insert into source values (2,'RAHUL',2000,'IND');
Insert into source values (3,'KARTIK',3000,'IND');
Insert into source values (4,'SHADOW',5000,'US');
insert into source values(5,'LOUI',1500,'JAP');


Create table source_country_code
(
country varchar2(100),
abbrv  varchar2(100),
area number,
climate varchar2(100)
);

insert into source_country_code values ('UNITED STATES','US',10000,'COLD');
insert into source_country_code values ('INDIA','IND',100000,'HOT');
insert into source_country_code values ('JAPAN','JAP',1000000,'MODERATE');




Create table target_country_code
(
country_id number,
descr  varchar2(100),
density number,
weather varchar2(100)
);

insert into target_country_code values (101,'this is descrition txt 1',1001,'COLD');
insert into target_country_code values (102,'this is descrition txt 2',1001,'HOT');
insert into target_country_code values (103,'this is descrition txt 3',1001,'MODERATE');



create table target
(
emp_id number,
empname varchar2(100),
sal number,
country_id number
);
I generally functions for this kind of mappings. I have several of these requirements as indicated above and the
cardinality of data is high.
create or replace function transform (in_src_country varchar2) return number deterministic
as
l_country_id number;
l_climate varchar2(1000);
begin

select climate into l_climate from source_country_code
   where upper(abbrv)=upper(in_src_country);
   
select country_id into l_country_id
from target_country_code
where upper(weather)=upper(l_climate);

return(l_country_id);
exception 
when no_data_found then
return null;
end;
last step,

so, what I usually do is

insert into target
Select emp_id, empname, sal, transform (country) in the source;



As always, thank you

Rahul

Published by: Rahul K on 5 June 2013 10:51

No technique is universally good or bad universally. You must understand your needs, the compromise and what you're trying to optimize for.

If you don't care anything else you are looking for the absolute fastest performance, reduce what you have to do in PL/SQL is a good idea. Most of the people and most of the systems, however, prefer to have code that is a bit slower if it makes the code easier to maintain and easier to write or minimizes the number of places that the code is duplicated. If you attempt to load a data warehouse of company with billions of new lines every night, you're as almost exclusively worry about raw performance. And, if you design correctly, there is that one way to load any particular item of data, you don't have to worry about code duplication because there will always be an INSERT statement that inserts data in a particular table. If you build an OLTP application, on the other hand, it is very likely that there will be many places where you want to do something like search for a value and you are much less concerned about raw performance you're on maintainability and ensure that you do not duplicate the code. In these cases, well-designed functions and procedures are well worth the return miners (so if you do a query of single line as most OLTP systems are generally easier to treat if you write DSS queries that return millions of processing lines billionr lines.

Justin

Tags: Database

Similar Questions

  • How to move the functions and procedures of packages in a schema?

    Hello

    I have less than the needs for a work at home and my question is if anyone can point me in the right direction to find documentation that can help me solve below. Any information will be appreciated. Thank you.

    Write procedures and functions (included or not in packets) as .txt or .sql scripts. Once they have been launched in Developer SQL they should, in addition, the functions and procedures of packages in the current schema. If the current schema contains only 2 packages, pac1 (p11, p12 procedures and functions f11, f12, f13) and pac2 (contains the p21 following procedures, p22, p23 and f21 and functions f21 (case of overload), running the scripts produce the following effects:)

    • Procedures p11, p12, p21, p22, p23, and f11, f12 and f13 functions will be created in the current schema.
    • PAC2 will contain 2 instances of the function of overload-f21; they will be kept in the package, without be created in the current schema. If all overloaded procedures/functions will be kept in their original packaging
    • If pac1 contains variables, cursors, and public types, keep us only the details of the package (and remove the body); usually if the packages contain no overloaded functions or procedures the body will be removed and if no variable, cursors, types of public then we will remove the header.
    • If in the triggers, procedures and functions we will call procedures/functions packages (procedures and functions moved into the current schema) they reference will need to be updated (via editing the body or recompilation) for example if pa1.p12 will be replaced with p12.
    • Scripts must have numbers in the next series (01... n) and the characters that explain the content.

    My only advice would be to remember that these are public forums and if YOU can find them, therefore cannot your instructors.

    In addition, those are horrible procedure names and function

    This mission seems to be around to overload the pl/sql objects and... prioritize a research on Oracle documentation around overhead and legacy
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28371/adobjplsql.htm#i21148

  • Copy all proecdures and packages in another DB functions

    Hello

    I hope someone can help me. I don't normally have to do so that I'm a bit of a loss as to how best to do it.

    I need to copy all the functions, procedures, packages with a specific prefix (long story - nothing to do with me) as well as grants and synonyms for a different database (dev to of many other dbs, not only diagrams). How best to do this? I work directly in development and is generally supported and if I aksed is a rapid execution of the package source control etc but, obviously, I don't want to do that.

    Pointers would be much appreciated.

    Thank you
    Vicky

    If you cannot access the server directly, you can use the EXP (Export Utility) instead.

  • How to query the DDL lock functions or stored procedures and packages?

    Hello!

    The subject says it all: how to display existing DDL locks on the functions or stored procedures and packages?

    While running a procedure, it cannot be deleted or replaced, so there must be a DDL lock on it. The information does not seem to be in V$ LOCK or V$ LOCKED_OBJECTS.

    Thank you!
    Marcus

    Published by: David on November 21, 2009 15:43

    Hello

    You have the DBA_DDL_LOCKS view.

    Best regards
    Jean Valentine

  • Oracle form functions and procedures in the APEX, how?

    I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.

    In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.

    I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?

    Some advice would be greatly appreciated.

    RLBickham wrote:
    I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.

    I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.

    In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?

    You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.

    -----

    When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:

  • Full version of APEX
  • Complete operating system DB, version, edition, host
  • Architecture of Web server (EPG, SST or APEX listener/host operating system)
  • Browser (s) and version (s) used
  • Theme
  • Model (s)

  • Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))

    With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.

  • Help with the AS3 Classes and packages

    Hello

    I'm trying to see if I can implement a function of speech synthesis in Flash. I found this post, which explains in detail how to integrate Google with Flash text-to-speech functionality. Looks pretty good, but the post seems to be written for programmers in AS3 uber-genius... Well not really, but at least those who already know how to assemble these pieces.

    I know a little about the use of the classes and packages, but do not understand how all segments of code in his position could be stitched together.

    No chance anyone can check this and give me a basic overview of how all these pieces go together? So I can try to implement myself...

    http://blog.onebyonedesign.com/ActionScript/Googles-text-to-speech-engine-in-Flash/

    Thank you very much in advance!

    Elliott

    PS. also open to an alternative to speech in Flash, if you know a easier... Thank you!!

    Here's a link to something that might be useful for you as well as to learn how to work with custom classes.  I don't think I've ever seen of it, but it was mentioned in another of tutorials from Lee that I watch and that it helped me anyway.

    http://gotoandlearn.com/play.php?id=30

    Insofar as the page you will bound, that third largest section of the code (the class named hand) is basically what you want to use for any Flash file you have on your page that provides the interface text/speech.  Then you would copy to a file named "Main.as" you have in the same folder as your swf file and use it as your document class.  The document class is specified in the properties of your fla Panel.

    One thing about this file, it's that I can't import the file "GTextToSpeech.as" that he uses.  So, you may need to add as an import at the beginning of your Main.as file.  The file GTextToSpeech.as is it that you would name the file you create using the first section of the code on this page.

    This small second section of the code, this is what you will place in a php file.  According to the file Main.as name this php file should be "proxy.php".  This file must be in the same folder as the html page that loads the swf file.

  • Resolution of delay function and the borough

    A small question about the delay () function.  The resolution is apparently 1ms according to the help file.  What happens if I pass a value with a fraction of a mlliseconds, say something like:

    Delay(0.0128);
    

    For 12.8ms.  Does round to the top and the 13th month of delay?  Or round to 12ms?  Undefined?  Something else?

    Thank you.

    Hey tstanley,

    I did some research on the function and it seems that the feature is for timer trying to get closer to the 12.8ms, but because the resolution is only 1 ms, it could still be +/-1ms to the value that you enter. So in some of our tests, it was waiting for 13.8ms, since it is in the accuracy of the clock 1ms.

    Because Windows is not a real-time operating system, there are several factors that could keep the timer delay for 13.8ms - other processes can run on the machine and anticipate the process timer, for example. If this level of accuracy is required, you can consider using the CVI RT module on a system in real-time.

  • difference between functionality and corresponding geometric base edge

    Can someone help me with the difference between a function and a corresponding based edge geometric model?

    I understand that:

    o geometric based function corresponding directly uses the intensity of pixels and reason for research and their settings

    o edge based geometric matching first calculates the gradient of the image and then uses this gradient to find features with generalized Hough transformation...

    More information here: documentation OR

    I hope this helps...

  • HP Touch Smart calendar and Notes cease to function and give me a notification so I end the program but it gives me immediately the notification even happening?

    HP Touch Smart calendar and Notes cease to function and give me a notification so I end the program but it gives me immediately the notification even happening?

    the notification said that the problem caused blocking the program works correctly.
    Windows will close the program and notify you if a solution is
    available.
    [Exit]
    I closed the program and this notification will appear back again.

    Hello

    I imagine the inconvenience that you are experiencing. I will certainly help the question of fixing.

    I would be grateful if you could answer the following questions:

    1. Since when are you facing the issue?

    2. you have any anti-virus installed on the computer program?

    3 are you aware of any changes made to the computer before the show?

    I would say you runa full scan using the Microsoft Safety Scanner and look for any infections.

    Note: there is a risk of data loss if all the files are infected and which can be removed in the cleaning process.

    If the problem persists, you can start the computer in safe mode and perform a clean boot. Clean boot helps eliminate any conflict of third party software.

    Note: when you are finished troubleshooting, follow step 3, mentioned in the article to start the computer to a normal startup.

    Hope this helps and let us know if you need more assistance. We will be happy to help you.

  • Visual Studio Professional 2015, Intellisense in bower.json and package.json does not work.

    I installed VS-2015 professional of the MSDN subscription site. When I tried to create a blank site ASP.NET 5, bower and NPM has failed. The survey, I discovered that there wasn't any NodeJS installed on my system in "C:\Program Files (x 86) \nodejs" (even if I chose NodeJS Joyent characteristic during the installation, but the node, NPM and everything has been installed in C:\Program Files (x 86) \Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External). So I installed on the site of NodeJS NodeJS and NPM has started working.

    But in bower.json and package.json intellisense does not work.

    In field, intellisense for the name of the package is now working but for version it still does not. that is, to say I type the name of the package and there is no intellisense when you type the name of the package, if release version inteliisense say the latest stable version.

    Bower.JSON package name intellisense or release version intellisense is available. I have to type the package name and version it displays ' *' only.

    Other people in my team also faced with the same question. Would anyone please be able to help me solve this problem of intellisense for the name of the package as well as regards the final version?

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    Note: after installation of NodeJS NodeJS site, restoration of package started working; only intellisense in file json does not work.

    I tried to install Git for windows as well (bower for troubleshooting site they say to install mysysgit and add it to the path variable) so I install the Git and added the location in the path variable. But still, intellisense did not.

    So, I did the following:

    1 set up Git to use http instead of git: / / with Git Bash

    git config--global url. ' http://".insteadOf git: / /.

    VS configured to use the new Git installed on VS Git

    Right click on folder Bower (under dependencies), and then select "Configure external tools", Unchecked "$(PublicAssemblies%) \Extensions\Microsoft\Web Tools\External\git" and adds a new node with "C:\Program Files (x 86) \Git\bin.

    Restarted the VS and intellisense worked still do not.

    Update 1: I installed Bower with the MUSEUM and after restarting VS several times, release version intellisense started working for bower.json! Then I uninstalled the Arbour (which I installed via NGP) and version intellisese version still works... It's a cause strange scenario now we can't say for certainty that Bower via NGP installation solved the problem like after UN-installing intellisense works always. Although I still do not get the package named by Intellisense. !!!

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    It has become a real nightmare in collaboration with Arbor and NPM in Visual Studio 2015. Help, please!

    Thanks and greetings

    Arun Kumar Dubey

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • Hi, I'm developing a simple mobile app in DW CC 2015 using JQuery Mobile. LIKE I need the list view with description of the product, functionality and image, I would like to connect with database instead of "writing" all the tables in the bearings inside

    Hi, I'm developing a simple mobile app in DW CC 2015 using JQuery Mobile. LIKE I need the list view with description of the product, functionality and image, I would like to connect with database instead of "writing" all the tables in the bearings inside the Jquery page. In the future I would also be able to add, to remove the DB records. Any help, tutorial... Thanks TG

    I would like to connect with the database instead of "writing" all the tables in the bearings inside the Jquery page

    This is usually done with a CMS (content management system). There are commercial products CMS like WordPress, Joomla and perch. You create one or several layouts and then create pages of these page layouts using the CMS. In this way, it is possible to have hundreds of pages, each with unique content, but a page layout that can be managed in a place of sharing.

    CMSs on shelf don't require programming skills. Otherwise, some of us write our own CMS with custom functions, but this requires back-end, as with PHP programming.

  • APEX 4.2 translate data 'function and Global Variable declaration '.

    Hello everyone,

    I use APEX 4.2.1.00.08 and I wonder if there is a way to translate "Function and Global Variable declaration" textarea. Any other script text box is available for translation, but not this one.
    I know what the code is loaded on the header, but may contain important alert messages of global functions.

    Thanks in advance.

    Hi Grandmaster,

    "Function and global variables declaration" contains the JavaScript code, that is why it is not wise to include in the standard translation process.

    In my opinion, you have several options to access your translated messages:

    -) Use Application-> Substitutions or
    -) Store your message in the form of component shared-> SMS and and assign it to an application with the APEX_LANG element. Api MESSAGE (http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_lang.htm#CHDBCEAB)

    In 'Function and Global Variable declaration' use substitution syntax to replace the value. For example:

    var myDeleteMessage = "&G_MY_DELETE_MESSAGE.";
    ...
    alert(myDeleteMessage);
    

    where G_MY_DELETE_MESSAGE would be a part of the application or the request for Substitution.

    Concerning
    Patrick
    -----------
    Member of the APEX development team
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • What is the difference between size function and aggragate function?

    Hi Experts,

    In OBIEE 11.1.1.6.0, what is the difference between size function and aggragate MDB measure column function?
    If it contains material or detail information, I am very grateful to you.

    Hello

    Good example with screenshots-

    http://www.clearpeaks.com/blog/Oracle-BI-EE/aggregation-based-on-dimensions

    Mark this reply / helped.

    Concerning
    Young

  • How to add the menu, under menu, forms and functions function and sub in resp.

    Can someone please provide me or direct me to the documentation, resources or the tuitorials "How to add menu, submenu and forms, function and functions in responsibility within the HRMS to the front end, not the example of back-end sub function responsibilities.»

    Appreciate your help.

    Published by: 931161 on December 14, 2012 10:55

    Hello

    PL. visit following links.

    http://erpschools.com/articles/sub-functions-in-Oracle-application#13554535205441&95816:resize_frame
    http://www.trutek.com/Serendipity/index.php?/archives/15-an-example-of-how-to-create-custom-functions, - the Menus - and - Responsibilities.html
    http://www.YouTube.com/watch?v=PKUiVIM0t94

    HTH
    Sanjay

  • Same algorithm in function and procedure so that one will be better?

    Why is better to pl sql function calculates a value instead of the procedure?
    If I apply the same algorithm in function and procedure while one will perform better?

    Siddharth Singh says:
    Oracle documentation

    http://docs.Oracle.com/CD/B10500_01/AppDev.920/a96624/08_subs.htm

    This:

    Generally, you use a procedure to perform an action and a function to calculate a value.

    Does not mean that the function are better to calculate a value, but you usually use functions to calculate a value.

    Usually, a function is can be more useful if you plan to use in a query.
    that is to say:

    SELECT myfunc(col1) from mytable;
    

    That you can't do with a procedure. Functions are also usually limited to the returning a single value, while procedures may have several OUTPUT parameters.

    Kind regards.
    Al

    Published by: Alberto Faenza on 21 November 2012 15:31

Maybe you are looking for

  • Early 2008 iMac upgrade to El Capitan

    El Capitan has disappeared from the app store.  How can I upgrade my iMac 2008 start of the Mavericks El Capitan now?  (Apple he will not go to Sierra.)

  • Upgrade to El Capitan in Yosemite

    I have a fairly new MacBook Pro running Yosemite. I was going to upgrade to El Capitan, but now he me Sierra offers instead. I don't want to do because of the risk that £500 dollars worth of software (File Maker Pro 11, final draft 8, Office 2011) wi

  • Portege R830-1EE - broken battery clamp

    Hello everyone, I have a problem with the 2 clamps that hold the battery in the guide. They broke and now the battery does not fit in the guide without the 2 attachment clamps with masking tape. Does anyone else have the same problem and now what I c

  • Pavilion G6-2213 nr: cannot start using HP system recovery disks

    Hi all I have a laptop of Pavilion G6 2213 nr and I had problems and ran diagnostics from the system on it and he failed the hard drive of the short dst test, so I ordered HP recovery discs and a new hard drive on ebay. I have put in the new drive ha

  • Droid Bionic: screen suddenly stopped auto-turning

    No apparent reason, my screen is auto rotation in apps. It automatically rotate when it is docked. I turned on the auto rotate in settings and off several times, pulled the battery, even installed an app to auto-rotation switch... nothing. Help! My o