Database design and pl/sql vs external procedures

hi,
My project involves predicting arrival time of a bus at a bus-stop, given statistical data of traffic patterns on the previous ‘n’(say 3) days, as well as the current location of the bus(latitude-longitude).
Given current bus location, I derive my distance-until-destination bus-stop, which must be translated into time until arrival.
Ive enlisted the triggers and procedures involved in making the prediction. Thse procedures especially the determination of perpendicular distances involve some complex trigonometric operations. I would like to know if my approach is correct and my database design is suited for the operations to b performed.
Will it be more efficient to implement the procedures as external procedures or as pl/sql blocks
This is my database design:
LINKS ( a link is the road segment between adjacent bus-stops)
LINK_ID                NUMBER      [PRIMARY-KEY]
START_LATITUDE          NUMBER     
START_LONGITUDE     NUMBER     
START_STOP_ID          NUMBER
END_LATITUDE          NUMBER
END_LONGITUDE          NUMBER
END_STOP_ID          NUMBER
LINK_LENGTH          NUMBER
BUS_ROUTE
ROUTE_ID               NUMBER
LINKS_ENROUTE          VARRAY(30) OF NUMBER
STOPS_ENROOUTE          VARRAY(30) OF NUMBER
TRACK(keeps track of current location of bus)
BUS_ID           NUMBER          [PRIMARY-KEY]
ROUTE          VARCHAR2(20)
LATITUDE          NUMBER
LONGITUDE          NUMBER
TS               TIMESTAMP
LINK_ID          NUMBER
START_STOP     NUMBER
END_STOP          NUMBER
ARRIVAL_TIMES(actual arrival times of the bus, updated by track)
BUS_ID           NUMBER     [PRIMARY-KEY]
BUS_ROUTE          VARCHAR2(20)
ARRIVAL          TIMESTAMP
STOP_ID          NUMBER
ETA (expected time of arrival)
BUS_ID          NUMBER
BUS_ROUTE          VARCHAR2(20)
BUS_STOP_ID     NUMBER
ARR_TIME          VARRAY(5) OF TIMESTAMP
Triggers and procedures
1)TRACK_TRIGGER
On insert/update of track determine which link the us is currently on.
Invoke a procedure that calculates perpendicular distance from current location to all links en-route (cursor on LINKS).
Results are stored in a temporary table. Select the link-id of the tuple whose perpendicular distance is MINIMUM. This is the link the bus is currently on. Place link-id, start_stop_id and end_stop_id in corresponding row of TRACK.
2)ARRIVAL_TRIGGER
update ARRIVAL_TIMES.and store in ARRIVAL_TIMES that start-stop id with the time-stamp of the current track record.
b)update ETA: Find the BUS-STOPS that come before the START_STOP of current track record. All these rows are deleted from the ETA tables, as the bus has already crossed these stops.
3)Prediction Algorithm Procedure.
Determine distance until destination for each STOP, 20 stops down from stop current location.
Determine current avg. speed of the bus over a 2 hour window, by dividing total distance traveled by time taken.
Calculate time-until arrival T1=current avg. speed * distance until destination
From the records of previous ‘n’ days (say n=3) find those buses on the same route that were near the link the bus is currently on. Again determine avg speed over 2 hour window and calculate avg. speed.
Calculate travel time T(i) = speed*distance until destination.     i.=2,3, 4…
The final predicted arrival time is a weighted sum of all T(i).
I hope Im not asking for too much, but the help would be greatly appreciated.
Thankyou,
Amina

hello,
actually i can manage ETA without a varray, since there will b a maxximum of 3 -4 values of expected arrival times at each stop. this can b done with separate columns.
though i dont quite understand how lag() will help me...from what i understand lag() is to access values of previous rows. but in ETA table each element in the varray(if there is one) is going to be the expected arrival time of buses on a particular route at that particular stop, and is different from the arrival time at a previous stop(i.e.row).
but for my other table BUS_ROUTE i have 2 varrays describing the links and stops enroute. in quite a few procedures i have to loop through these arrays and perform some calculations in every iteration is varray the best way 2 go, or nested tables?
Thank you
Amina
As an aside, external procedures tend by their very
nature to be slow - there's an overhead incurred
each time we step outside the database. Therefore
you really ought to avoid using a C extproc unless
your calculations really cannot be done in PL/SQL or
a Java Stored Procedure.
Also, before you go down the VARRAY route you should
consider the virues of analytic functions, notably
[url=http://download-west.oracle.com/docs/cd/B1050
1_01/server.920/a96540/functions56a.htm#83619]LAG()[/u
rl]. I think you really ought to do some
benchmarking of parformance before you start afdding
denormalised columns like ETA. You may find the
overhead in maintaining those columns exceeds their
perceived benefits.
Cheers, APC

Similar Messages

  • Logical Database design and physical database implementation

    Hi
    I am an ORACLE DBA basically and we started a proactive server dashboard portal ,which basically reports all aspects of our infrastructure (Dev,QA and Prod,performance,capacity,number of servers,No of CPU,decomissioned date,OS level,Database patch level) etc..
    This has to be done entirely by our DBA team as this is not externally funded project.Now i was asked to do " Logical Database design and physical Database
    implementation"
    Even though i know roughly what's that mean(like designing whole set of tables in star schema format) ,i have never done this before.
    In my mind i have a rough set of tables that can be used but again i think there is lot of engineering involved in this area to make sure that we do it properly.
    I am wondering you guys might be having some recommendations for me in the sense where to start?are there any documents online , are there any book on this topic?Are there any documents which explain this phenomena with examples ?
    Also exactly what is the difference between logical database design vs physical database implementation
    Thanks and Regards

    Logical database design is the process of taking a business or conceptual data model (often described in the form of an Entity-Relationship Diagram) and transforming that into a logical representation of that model using the specific semantics of the database management system. In the case of an RDBMS such as Oracle, this representation would be in the form of definitions of relational tables, primary, unique and foreign key constraints and the appropriate column data types supported by the RDBMS.
    Physical database implementation is the process of taking the logical database design and translating that into the actual DDL statements supported by the target RDBMS that will create the database objects in a target RDBMS database. This will generally include specific physical implementation details such as the specification of tablespaces, use of specialised indexing (bitmap, clustered etc), partitioning, compression and anything else that relates to how data will actually be physically stored inside the database.
    It sounds like you already have a physical implementation? If so, you can reverse engineer this implementation into a design tool such as SQL Developer Data Modeller. This will create a logical design by examining the contents of the Oracle data dictionary. Even if you don't have an existing database, Data Modeller is a good tool to use as a starting point for logical and even conceptual/business models.
    If you want to read anything about logical design, "An Introduction to Database Systems" by Date is always a good starting point. "Database Systems - A Practical Approach to Design, Implementation and Management" by Connolly & Begg is also an excellent reference.

  • Good database design and modelling books

    Hi ,
    I need to work on designing a database from the scratch by creating logical database design and then physical database design.I'm new to database design.
    Can someone please point me to some good database design and modelling related books /tutorials.
    Regards,
    Bharath.

    bharathDBA wrote:
    Hi Girish Thanks for the information.
    I would definitely look into this book later.
    I don't mind paying any amount of money,if that book gives me the knowledge I want.
    As this book is international edition,for shipping it is taking 8-10 business days and by that time I need to complete designing my database and probably I might need to some other book.
    Is this a school assignment? I hope so. Referring back to your opening statement "I need to work on designing a database from the scratch by creating logical database design and then physical database design.I'm new to database design." I can only say that database design is a very big subject. If you are starting from a position of no knowledge at all, I'm afraid there is nothing that is going to give you the knowledge you need in the time frame you have. I will say you need to start by learning the rules of Data Normalization. Make your logical design Third Normal Form. Good can be your friend. There is actually a pretty good write-up on Data Normalization on Wikipedia.

  • Should I learn database design and development skills?

    Hi everyone,
    I am a junior Oracle with 3 years experience. I have got Oracle 10g and 11g OCP certifications.
    I know how to install, configure,monitor and maintain databases, but I don't know hot to design and develop databases.
    I know that employers demand of us more and more. Database design and development skills are the basic requirements.
    Should I start to learn database design courses?
    If yes, please recommend me the books(or Oracle Docs) of Getting Started.
    Thank you very much
    Edited by: user8096439 on Feb 24, 2009 11:59 AM

    user8096439 wrote:
    Are the following books suitable for a getting started designer?
    2 Day Developer Guide      
    2 Day Plus Application Express Developer's Guide      
    2 Day Plus Java Developer Guide      
    2 Day Plus .NET Developer Guide      
    2 Day Plus Locator Developer Guide      
    2 Day Plus PHP Developer GuideYou could do worse, but I think before you plunge into specific technologies (java, .NET, etc) I'd study up on basic data analysis and normalization.
    Google "data normalization" and study up on 1st, 2d, and 3d Normal Form.
    Go through the Oracle docs and get very familiar with the different data type (varchar, number, date, etc)
    Read the Tom Kyte Books.
    Programmers keep wanting to re-invent what the database already does, and treat the database as a data dump. As a result, I'd focus on analysis and design issues before approaching books on programming technology. (and I was an applications programmer/analyst for about 15 years before transitioning to DBA)

  • Requirements for database design and installation

    Hi,
    As a database administrator, how to find out whether the database is design and installed properly?
    Can you please what would be the requirements to be considered towards the databse design for application developer ?
    thanks heaps !!!!

    Mohamed ELAzab wrote:
    regarding that the number of execution is the main thing that affects the performance i said that already above " the application executed it 30 000" but you didn't read my answer correctly. I did not respond to that "answer" of yours as it was not part of your posting that I responded too. In your response, which I quoted, talked about non-sharable SQL retrieving 20 rows and after 3 years it retrieving a million rows. This has no bearing on whether the SQL is sharable or not.
    I don't agree with you regarding that the design is not being done regarding considering the performance bottlenecks.So you decide on what the bottlenecks are up front, and then use these as database design considerations? I fail to see any logic or merit in such an approach.
    i want to let you know that we in the telecoms environment have many problems in our databases because the people who designed those applications didn't take performance in consideration.I understand too well - and it is not that they did not take performance into consideration when designing the database, it is because the design is just plain wrong from the start.
    You do not need to consider amount of memory available, number and speed of CPUs, bandwidth and speed of the I/O system, in order to design a database. These have no relevance at all during the design phase. Especially as the h/w that will run the design in production in a year's time can be drastically different from the h/w that will be used today.
    No, instead you use a proper and correct design methodology and data modeling approach. Why? Because such a design by its very nature will make optimal use of h/w resources and will provide data integrity, scalability and performance.
    Again i think design of the database application must take database performance bottlenecks in consideration like application which doesn't use bind variables if they took into consideration to avoid that it will help the DBA in the future but unfortunately most people doesn't do that. And as I said - using bind variables or not has absolutely nothing to do with the basic question asked in this thread: "+what are the requirements of database design+".
    How does using/not using bind variables influence the design of a table? Determine whether an entity is in 3NF? What the unique identidiers are for an entity? These are the design considerations for a database.. not bind variables.
    Yes, SQLs not using bind variables can cause performance problems. Not paying the electricity bill can cause a power outage for the database server. So what? These issues have no relevance to database design.

  • Difference between database design and schema design

    Hi i have visited so many database websites and i found so many people saying we can design a data base for you. Is schema designing and database designing is the same. so many palces i find people saying we have to design data base first in order to create a physical databse. so i am little bit confused. are they same? and also what is the difference between data model and schema?

    > the definition i found for logical data model, physical data model and the definition you
    gave for logical database design, physical database design are the same.
    Not correct. The physical design is the implemetation of the logical design. These two designs are at different levels. Also, the logical design will be the same. irrespective of the RDBMS product use.
    What is incorrect is a designer/architect designing a logical design specifically for Oracle.. or specifically for SQL-Server. A logical design has nothing to do with the RDBMS product (or h/w platforms. app servers, web severs and operating systems used).
    So the logical design will always be the same - it is RDBMS independent.
    The physical design is fully dependent on the RDBMS product used. The same logical design will be implemented as different physical designs for Oracle and for SQL-Server.

  • DDL statements and dynamic  sql  in stored procedure

    I created a stored procedure to create and drop tables, using dynamic sql.
    When I try to do the inserts using dynamic sql, i.e
    v_string := 'INSERT statement';
    EXECUTE IMMEDIATE v_string;
    I get the following error message:
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at line 63
    Line 63 happens to be the line that the EXECUTE IMMEDIATE v_string; statement is in.
    I am able to describe the table that the inserts are being made into, so I know that the table exists.
    Any idea why I'm getting this error message would be appreciated.

    Yes I do and I have been able to create other tables using dynamic sql.
    The table that I am having problems with SELECTs data from another table to get its column values; within the SELECT statement, the CAST function is used:
    ie. CAST(CASE SUBSTR(CAST(E_MOD AS VARCHAR(7)),2,3)
    WHEN 'AAA' THEN 'A55'
    ELSE ............
    I get the following error message:
    ERROR at line 18: (this line starts the CAST statement)
    ORA-06550: line 18, column 13:
    PLS-00103: Encountered the symbol "AAA" when expecting one of the following:
    . ( * @ % & = - + ; < / > at in is mod not rem return
    returning <an exponent (**)> <> or != or ~= >= <= <> and or
    like between into using || bulk
    When I remove the quotes or add another single quote, the same error cascades to 'A55'.
    After doing the same for the next error, I get the error message below:
    ERROR at line 1: (this line has the EXECUTE IMMEDIATE statement)
    ORA-00936: missing expression
    ORA-06512: at line 6
    Any idea what the problem could be?
    Also is there another way to have DDL statements as stored procedures other than using dynamic sql or the DBMS_SQL package?

  • Is it possible to have different authentication mode for SQL Server Database Engine and corresponding SQL Server instance?

    Hi,
    I have installed the x64 SQL Server 2008 R2 Express with default settings and run MBSA 2.3 (using default settings too). It shows three SQL Server instances: MSSQL10_50.SQLEXPRESS, SQLEXPRESS and SQLEXPRESS (32-bit). For the first, authentication
    mode is Windows, for the rest two - mixed. Here https://social.msdn.microsoft.com/Forums/sqlserver/en-US/03e470dc-874d-476d-849b-c805acf5b24d/sql-mbsa-question-on-folder-permission?forum=sqlsecurity question
    about such multiple instances was asked and the answer is that "MSSQL10.TEST_DB
    is the instance ID for the SQL Server Database Engine of the instance, TEST_DB", so in my case, it seems that MSSQL10_50.SQLEXPRESS is the instance ID for SQL Server Database Engine  of the SQLEXPRESS instance.
    I have two questions:
    1) How can it be that SQL Server DB Engine instance has different authentication mode than corresponding SQL Server Instance?
    2) Why 32-bit instance reported although I installed only 64-bit version?
    Also, this https://social.technet.microsoft.com/Forums/security/en-US/6b12c019-eaf0-402c-ab40-51d31dce968f/mbsa-23-reporting-sql-32bt-instance-is-running-in-mixed-mode-when-it-is-set-to-integrated?forum=MBSA question seems to be related to this
    issue, but there is no answer :(.
    Upd: Tried on clean Windows 8 installation and Windows 7 with the same result.

      Because I DO NOT want the three people who will be having access to the production SQL Server to also have access to the primary host ProductionA.  Since I have to allow them to RDC into the box to manage the SQL Server, I figure why not create
    a separate VM for each one of them and they can RDC into those instead.
    Does this make any sense?
    Any tips are greatly appreciated.  The main reason for doing this is because the three people who will be accessing the box, I need to isolate each one of them and at the same time keep them off of the primary ProductionA.
    Thanks for your help.
    M
    Hello M,
    Since you dont want the 3 guys to have access to Production machine A.You can install SQL Server client .By client i mean SQL server management studio(SSMS) on there local desktop and then create login for them in SQL Server.Open port on which your SQL server
    is running for three of the machines so that they can connct.Now with SSMS installed on each machine each can connect to SQL server from there own machine.
    I would also like you to be cautious with giving Sysadmin privilege to all three of them ,first please note down what task they would do and then decide what rights to be provided.
    Your option will also work but you need to create 3 VM for that .Which is more tedious task.
    Hope this helps
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Java, access database( mdb) and java.sql.date

    I having a problem querying my access database with user specified date the code is as follows
    //get results of income from database with respectto dates
         //so u first create the sql.date instances
         private void getResults(){
         String text1=from.getText();//text input is like this 01-01-2005
              String text2=to.getText();
         Date d1=new Date(Integer.parseInt(text1.substring(6)),Integer.parseInt(text1.substring(3,5)),Integer.parseInt(text1.substring(0,2)));
         JOptionPane.showMessageDialog(this,d1.toString());//traces date with 1900 added to year and 1 added to month
         try{
              //custom class DataSource used to connect to database
              Connection conn=DataSource.getConnection("RealFotoInc");
              PreparedStatement ps=conn.prepareStatement("select * from Members where date=?");
              ps.setDate(1,d1);
              ResultSet rs=ps.executeQuery();
              while(rs.next()){
                   System.out.println("going");
                   System.out.println("trial"+rs.getString(3));
         }catch(Exception se){
              JOptionPane.showMessageDialog(this,se);
         }and it prints out nothing I dont know what is wrong

    Whoever put that comment in there about "1900" and so on knew what had to be done. That "Date" class must be "java.sql.Date"; go and read the API documentation of that constructor you are using there. Then adjust the parameters you are passing to it accordingly.

  • SQL Developer and External Procedures not in tree.

    Does sql Dveloper add external procedures to the object browser tree? I have SQL Developer 1.5 and if you have external procedures/functions before your regular PLSQL objects they will not display in the tree. I can make the tree work but the tree still doesn't capture the externals. Am I doing something wrong or should this be a feature request?
    VSAMPLE1 shows the problem.
    VSAMPLE2 is a try to resolve...
    /* the problem.. */
    CREATE OR REPLACE package VSAMPLE_1 IS
         PROCEDURE foobar(feedname IN VARCHAR2);
    END VSAMPLE_1;
    CREATE OR REPLACE PACKAGE BODY VSAMPLE_1
    IS
         * Function Name:- canread
         * Description  :-This function checks the file will give any error or not while reading
         FUNCTION canread (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.canRead (java.lang.String) return int';
         * Function Name:- is_exist
         * Description  :-This function checks the existance of the filein the required folder
         FUNCTION is_exist (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.exists (java.lang.String) return int';
         * Function Name:- isDirectory
         * Description  :-This function checks the name provided by the user is a directory or not
         FUNCTION isDirectory (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isDirectory (java.lang.String) return int';
         * Function Name:- isFile
         * Description  :-This function checks the name provided by the user is a file or not
         FUNCTION isFile (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isFile (java.lang.String) return int';
         * Function Name:- isExist
         * Description  :-This function checks the existance of file,correctness of the directory provided by the user.
         * @Param file_name :- File Name in directory
         * @return retcode  :- Error checking while uploading the feed.
         FUNCTION isExist(file_name IN VARCHAR2,
                    is_dir       BOOLEAN)
              RETURN PLS_INTEGER
         IS
              retcode PLS_INTEGER := -1;
              v_errcode PLS_INTEGER;
              v_errtext      VARCHAR2(1000);
              l_section_name VARCHAR2(32) := 'isExist ' ;
         BEGIN
              IF VTMLOG.isDebugEnabled THEN
                   VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Checking existense of '||file_name);
              END IF;
              retcode   := is_exist(file_name);
              IF retcode = 1 THEN
                   IF is_dir THEN
                        retcode := isDirectory(file_name);
                   ELSE
                        retcode := isFile(file_name);
                   END IF;
                   IF retcode          = 1 THEN
                        retcode    := canread(file_name);
                        IF retcode != 1 THEN
                             VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Can not read ' || file_name);
                        END IF;
                   ELSE
                        VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Unable to check if ' || file_name || ' is directory or file ');
                   END IF;
              ELSE
                   VTMLOG.error(l_section_name,$$PLSQL_LINE, file_name || ' does not exist ');
              END IF;
              VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Leaving ' );
              RETURN retcode;
         EXCEPTION
         WHEN OTHERS THEN
              VTMLOG.SHOW_ERROR_MESSAGE(l_section_name,$$PLSQL_LINE);
              RAISE;
         END isExist;
         PROCEDURE foobar(feedname VARCHAR2)
         IS
                    retval PLS_INTEGER;
            BEGIN
              /* implementation omitted */
              retval := isExist('feed.txt',false);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END foobar;
    END VSAMPLE_1;
    /* This version at least shows the tree. But I can't reach the external by clicking in the navigation tree just the placeholders */
         PROCEDURE foobar(feedname IN VARCHAR2);
    END VSAMPLE_2;
    CREATE OR REPLACE PACKAGE BODY VSAMPLE_2
    IS
            FUNCTION canread (FILE IN VARCHAR2) RETURN NUMBER;
            FUNCTION is_exist (FILE IN VARCHAR2) RETURN NUMBER;
            FUNCTION isDirectory (FILE IN VARCHAR2) RETURN NUMBER;
            FUNCTION isFile (FILE IN VARCHAR2) RETURN NUMBER;
         * Function Name:- isExist
         * Description  :-This function checks the existance of file,correctness of the directory provided by the user.
         * @Param file_name :- File Name in directory
         * @return retcode  :- Error checking while uploading the feed.
         FUNCTION isExist(file_name IN VARCHAR2,
                    is_dir       BOOLEAN)
              RETURN PLS_INTEGER
         IS
              retcode PLS_INTEGER := -1;
              v_errcode PLS_INTEGER;
              v_errtext      VARCHAR2(1000);
              l_section_name VARCHAR2(32) := 'isExist ' ;
         BEGIN
              IF VTMLOG.isDebugEnabled THEN
                   VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Checking existense of '||file_name);
              END IF;
              retcode   := is_exist(file_name);
              IF retcode = 1 THEN
                   IF is_dir THEN
                        retcode := isDirectory(file_name);
                   ELSE
                        retcode := isFile(file_name);
                   END IF;
                   IF retcode          = 1 THEN
                        retcode    := canread(file_name);
                        IF retcode != 1 THEN
                             VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Can not read ' || file_name);
                        END IF;
                   ELSE
                        VTMLOG.error(l_section_name,$$PLSQL_LINE, ' Unable to check if ' || file_name || ' is directory or file ');
                   END IF;
              ELSE
                   VTMLOG.error(l_section_name,$$PLSQL_LINE, file_name || ' does not exist ');
              END IF;
              VTMLOG.debug(l_section_name,$$PLSQL_LINE, 'Leaving ' );
              RETURN retcode;
         EXCEPTION
         WHEN OTHERS THEN
              VTMLOG.SHOW_ERROR_MESSAGE(l_section_name,$$PLSQL_LINE);
              RAISE;
         END isExist;
         PROCEDURE foobar(feedname VARCHAR2)
         IS
                    retval PLS_INTEGER;
            BEGIN
              /* implementation omitted */
              retval := isExist('feed.txt',false);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END foobar;
         * Function Name:- canread
         * Description  :-This function checks the file will give any error or not while reading
         FUNCTION canread (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.canRead (java.lang.String) return int';
         * Function Name:- is_exist
         * Description  :-This function checks the existance of the filein the required folder
         FUNCTION is_exist (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.exists (java.lang.String) return int';
         * Function Name:- isDirectory
         * Description  :-This function checks the name provided by the user is a directory or not
         FUNCTION isDirectory (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isDirectory (java.lang.String) return int';
         * Function Name:- isFile
         * Description  :-This function checks the name provided by the user is a file or not
         FUNCTION isFile (FILE IN VARCHAR2)
              RETURN NUMBER AS LANGUAGE JAVA NAME 'com.myCompany.myApp.bulk.FileUtil.isFile (java.lang.String) return int';
    END VSAMPLE_2;
    /

    Hi,
    I am afraid that according to the error message, it seems that this issue is mainly related to third-party, since issues using oracle database are not supported here, you could consider posting this issue in its website to get supports.
    In addition, you could mark any reply as answer if it is helpful.
    Thanks for your understanding.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Converting SQL Server Stored Procedure to Oracle

    Hi there,
    I tried to use SwisSQL to convert my SQL Server stored procedure to Orcale without much success.
    Is there anyone who could help me out with this?
    My SQL Server Stored Procedure is:
    CREATE PROCEDURE [dbo].[SP_BackgroundCheckRequest]
         --MASTER Table
         @MASTER_ID int,
         @PERSONNEL_ID int = NULL,
    @DATE_OF_BIRTH datetime = NULL,
         @GENDER varchar(1) = NULL,
         @COUNTRY_OF_BIRTH varchar(3) = NULL,
    @TOWN_OF_BIRTH varchar(100) = NULL,
         @STATE_OF_BIRTH varchar(50) = NULL,
         @CHECK_CATEGORY varchar(10) = NULL,
         @CHECK_TYPE varchar(10) = NULL,
         @PRIORITY varchar(10) = NULL,
         @PRIORITY_REASON varchar(100) = NULL,
         @SCREENING_LEVEL nchar(1) = NULL,
         @POSITION nchar(50) = NULL,
         @REQUEST_SOURCE varchar(60) = NULL,
         --NAME_TYPE Table
         @NAME_TYPE varchar(5) = NULL,
         @FAMILY_NAME varchar(50) = NULL,
         @FIRST_NAME varchar(50) = NULL,
         @MIDDLE_NAME varchar(50) = NULL,
         @TITLE varchar(10) = NULL,
         @PREFFERED_NAME varchar(40) = NULL,
         @PREVIOUS_NAME varchar(140) = NULL,
         --ADDRESS_TYPE Table
         @ADDRESS_TYPE varchar(10) = NULL,
         @ADDRESS_LINE_1 varchar(30) = NULL,
         @ADDRESS_LINE_2 varchar(30) = NULL,
         @ADDRESS_LINE_3 varchar(30) = NULL,
         @COUNTRY varchar(3) = NULL,
         @SUBURB varchar(50) = NULL,
         @STATE varchar(50) = NULL,
         @POSTCODE varchar(15) = NULL,
         @START_DATE varchar(10) = NULL,
         @END_DATE varchar(10) = NULL,
         --LICENSE_TYPE Table
         @LICENSE_TYPE varchar(5) = NULL,
         @LICENSE_AGENCY varchar(15) = NULL,
         @LICENSE_NUMBER varchar(100) = NULL,
         @LICENSE_SIGHTED varchar(1) = NULL,
         --PHONE_TYPE Table
         @TELEPHONE_TYPE varchar(5) = NULL,
         @TELEPHONE_NUMBER varchar(20) = NULL,
         @MOBILE_TYPE varchar(5) = NULL,
         @MOBILE_NUMBER varchar(20) = NULL,
         @EXTENSION_TYPE varchar(5) = NULL,
         @EXTENSION_NUMBER varchar(20) = NULL,
         --PASSPORT_TYPE Table
         @PASSPORT_TYPE varchar(5) = NULL,
         @PASSPORT_NUMBER varchar(50) = NULL,
         @PASSPORT_COUNTRY varchar(3) = NULL,
         @PASSPORT_SIGHTED varchar(1) = NULL
    AS
    BEGIN TRANSACTION
    INSERT into MASTER (MASTER_ID, PERSONNEL_ID, DATE_OF_BIRTH, GENDER, COUNTRY_OF_BIRTH,
         TOWN_OF_BIRTH, STATE_OF_BIRTH, CHECK_CATEGORY, CHECK_TYPE, PRIORITY, PRIORITY_REASON,
         SCREENING_LEVEL, POSITION, REQUEST_SOURCE)
         VALUES (@MASTER_ID, @PERSONNEL_ID, @DATE_OF_BIRTH, @GENDER, @COUNTRY_OF_BIRTH,
         @TOWN_OF_BIRTH, @STATE_OF_BIRTH, @CHECK_CATEGORY, @CHECK_TYPE, @PRIORITY, @PRIORITY_REASON,
         @SCREENING_LEVEL, @POSITION, @REQUEST_SOURCE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into MASTER table!', 16, 1)
         RETURN
    END
    INSERT into NAME_TYPE (MASTER_ID,NAME_TYPE,FAMILY_NAME,FIRST_NAME,MIDDLE_NAME,TITLE)
         VALUES (@MASTER_ID,@NAME_TYPE,@FAMILY_NAME,@FIRST_NAME,@MIDDLE_NAME,@TITLE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into NAME_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into ADDRESS_TYPE (MASTER_ID,TYPE,ADDRESS_LINE_1,ADDRESS_LINE_2,ADDRESS_LINE_3,
              COUNTRY,SUBURB,STATE,POSTCODE,START_DATE,END_DATE)
         VALUES (@MASTER_ID,@ADDRESS_TYPE,@ADDRESS_LINE_1,@ADDRESS_LINE_2,@ADDRESS_LINE_3,
              @COUNTRY,@SUBURB,@STATE,@POSTCODE,@START_DATE,@END_DATE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into ADDRESS_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into LICENSE_TYPE (MASTER_ID,TYPE,AGENCY,NUMBER,SIGHTED_YN)
         VALUES (@MASTER_ID,@LICENSE_TYPE,@LICENSE_AGENCY,@LICENSE_NUMBER,@LICENSE_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into LICENSE_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
         VALUES (@MASTER_ID,@TELEPHONE_TYPE,@TELEPHONE_NUMBER)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting Telephone number into PHONE_TYPE table!', 16, 1)
         RETURN
    END
    IF ((@MOBILE_TYPE <> NULL) AND (@MOBILE_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@MOBILE_TYPE,@MOBILE_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Mobile number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    IF ((@EXTENSION_TYPE <> NULL) AND (@EXTENSION_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@EXTENSION_TYPE,@EXTENSION_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Extension number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    INSERT into PASSPORT_TYPE (MASTER_ID,NUMBER,COUNTRY,SIGHTED_YN)
         VALUES (@MASTER_ID,@PASSPORT_NUMBER,@PASSPORT_COUNTRY,@PASSPORT_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into PASSPORT_TYPE table!', 16, 1)
         RETURN
    END
    COMMIT

    First, a basic concept. That also illustrates how different Oracle is (and PL/SQL) from SQL-Server (and T-SQL).
    PL/SQL integrates two different languages. The PL language. The SQL language. It allows you to code SQL source code natively inside the PL language. The PL compiler is clever enough to do the rest - make calls to the SQL engine to create SQL cursors, bind PL variable values to bind variables in the SQL code. Etc.
    PL is a "proper" programming language. It is much like Pascal (it is based on Ada, a close family member of Pascal). It is nothing at all like T-SQL.
    Okay, now for the very basic rule for Oracle development.
    Maximize SQL. This means using the SQL language to crunch data. It is the "closest" to the data. It is designed and optimised for dealing with data. Do your data processing using SQL.
    Minimize PL/SQL. This means using the PL language not to crunch data, but to provide the conditional logic. Implement business rules. And then have the SQL language crunch the data as the data processing language.
    Attempting to directly translate T-SQL code into PL/SQL is flawed. It is like trying to make coffee with teabags. Yeah, the tea may have caffeine it, but it is not coffee.
    To do what that T-SQL script does, insert a row into a table, a typical PL/SQL equivalent will look as follows:
    create or replace procedure InsertMaster( masterRow master%rowtype ) authid definer is
    .. types and variables declared here
    begin
      -- masterRow is a record structure that matches the actual MASTER table
      .. apply business rules and validation to the data.. raising user exceptions as needed
      -- e.g. the POSITION column must be upper case
      masterRow.position := upper(masterRow.position);
      -- after the business logic and data validation we can add the row to the table
      -- (PL will make the INSERT call to the SQL engine)
      insert into master values masterRow;
    end;No commit. The caller does the business transaction. It needs to decide when to commit to maintain the integrity of the data in the database. It may need to do several more calls, before committing.
    With this approach, we can give the application schema (the caller) execute privs on this procedure. This procedure is defined with definer rights. This means it runs with the privs of owner of that procedure and MASTER table. It is trusted code. It does all the correct stuff to add a valid and checked row to the MASTER table. So we give the app schema execute privs on the procedure and no insert priv on the MASTER table.
    The only way the caller can add row to the MASTER table is via this trusted procedure of ours.
    And this is a typical approach in Oracle - using the PL/SQL (both PL language and SQL language) code to create an interface to a logical database in Oracle. Abstracting the complexities of SQL from the caller. Moving business and validation into PL. Allowing us the flexibility of modifying business and validation logic, without touching a single byte of caller/client code. Allowing us to manage and tune SQL performance without dealing with (badly designed and coded) SQL from a client - as the SQL resides in PL/SQL packages and procedures and functions.

  • External Procedure call from Trigger

    I'd like to call an external C Procedure from
    an Oracle Trigger.
    In trying to get an example to work, after setting up the listener and tnsnames.ora for external procedures, the following SQL*Plus command behaves strangely:
    CREATE LIBRARY TTest as "c:\winnt\system32\TTrigger.dll";
    After entering this, the command line prompts for more data as if the command was not terminated. Tried single quotes, double quotes, forward slash, backward slash...
    What is wrong with this command?
    Thanks

    hi,
    COuld you send me the configuration parameters for listner and TNSNAMES? I am working so hard to set it up but getting stuck and I am sure that I am missing some configuration set up.
    Please could you mail your tnsname a nd listner files to bellow shown address?
    [email protected] ?
    Thanks in advance
    Suresh

  • Running catproc.sql and catalog.sql scripts

    hi there,
    what is the need to run catproc.sql and catalog.sql scripts after creating the database manually?
    please write me the answer.
    thanks in advance.

    CATALOG.SQL script create data dictionary views,
    synonyms, tables in your sys/system schemas like
    (USER_XXX , DBA_XXXX, ALL_XXXX, V$XXXX .....)
    CATPROC.SQL script creates all packages including
    their procedures and functions in sys schema.
    Both must be run through SYS schema.Apart for this
    These scripts executes many Create View statements as well as series of other scripts.
    Catproc.sql makes call to several other scripts like
    standard.sql: to create datatypes and in-built SQL functions
    catexp: to create views used by Import/Export utilities
    catldr: to create views used by SQL*Loder utilities
    and there many other scripts called too.
    Similarly, catproc.sql makes call to .sql and .plb encrypted scripts like dbmsutil.sql and dbmssql.sql to create procedural options and PL/SQL utilities.

  • To get best database design

    Hello...
    I am going through one case study for the database design. and for this I want your view / suggestion regarding this.
    I have one table with 6 column
    create table test (
    id primary key,
    col1 varchar2(100),
    col2 varchar2(100),
    col3 varchar2(100),
    col4 varchar2(100),
    col5 varchar2(100))
    It might be possible that col1 value duplicated in col2 or col3 or col4 or col5 for some other raw.
    Now I have query that is require to search for the row by matching given value with all of 5 column col1 to col5. like this:--
    select * from test where col1=''pratik' or col2='pratik' or col3='pratik' or col4='pratik' or col5='pratik';
    I want to know, is this design is good for large table with millions of records into it.
    Is any other design is possible?? that is more efficient
    Thanks

    But in case of address, generally I am going to retrieve address for a give
    name or id. while in this case on basis of supplied value I have to search
    all 5 columnsNot necessarily. A search might be for all customers in a given postal district. But that is my point. I suggested address as a possible explanation for your requirements to fill a void.
    You have given us a strawman architecture and no clues about the underlying business premises. Under those circumstances all I can say is if you want to retrieve Col1, Col2, Col3, Col4 and Col5 for each ID where any of those columns matches 'Pratik' then I think your design is probably correct.
    Certainly I wouldn't want to suggest a different design without knowing why it is legitimate for the value 'Pratik' to appear in Col1, Col2, Col3, Col4 or Col5.
    Cheers, APC

  • Recapturing database design using designer6i

    We use designer as a tool to document our production database (basically use designer to store description for the tables and attributes). A promotion to the production database was made a while ago and we need to find a way to synchronize the repository and the production database.
    Does anybody know if we recapture the database design and retrofit table -> entity, will we lose all the descriptions already stored in the repository? Or is there a better way to do the synchronization?
    Thanks in advance

    Please check the Cameleon Open Source project at http://www.must.de/cameleon.html if ti fits your needs.

Maybe you are looking for

  • How do i turn off all base on macbook pro?

    when i put the headphones in, the right one makes a thumping sound, how can i turn this off?

  • How to create a system tablespace as  locally manged in 8.1.7

    After a good time looking for it I still haven't found an example of how to create a database with the system tablespace as locally managed in release 8.1.7 I'm trying this, that isn't OK at all: create database CSR character set "WE8ISO8859P15" data

  • Document attachments in email -- how do I save them?

    I have emails that have attachments in .rtf. and .doc formats that I want to save. How do I make a folder to put them in? Or can this even be done? The user guide says to select a folder or other mailbox to move them to, but there are no other folder

  • Video podcast stops and restarts

    with one of my podcasts (Bush League TV), it will download completely, but after i sync it to my iPod, whenever it reaches a certain point it will stop and restart. Whenever i play it in iTunes it plays alright but is sorta slow and skippy. i have tr

  • Function Modue with Dynamic Table as output parameter

    Hi experts, i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in <ft>. How can i return <ft> as output parameter of function module (table) ? function import parameter  - > IC_