Need Help With a Stored Procedure

Help With a Stored Procedure
Hi everyone.
I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
Anyway, here is my case:
I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
PlanID
EmployeeIndicator
UpdatedBy
CreatedBy
tblRef1, tblRef2 and tblRef3 has the following fields:
UserName
EmpIndicator
UserID
In my stored procedure, I need to perform the following:
1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
v_plan_no tblToUpdate.PLANID%TYPE;
v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
v_update_user tblToUpdate.UPDATEDBY%TYPE;
v_created_by tblToUpdate.CREATEDBY%TYPE;
v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
BEGIN
Open cur_plan;
     LOOP
     FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
          EXIT WHEN cur_plan%NOTFOUND;
          BEGIN
          -- Check if v_created_by has value.
               IF v_created_by IS NOT NULL THEN
               -- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
               SELECT UPPER(EmpIndicator)
                    INTO v_correct_ref_ind
                    FROM tblRef1
                    WHERE UPPER(USERNAME) = v_created_by
                    OR UPPER(USERID) = v_created_by;
                    IF v_correct_ref_ind IS NOT NULL THEN
                    -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                         UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                    ELSIF
                    -- Check the Other tables here????
                    END IF;
               ELSIF v_created_by IS NULL THEN
               -- Get the EmpIndicator based on the UpdatedBy
                    SELECT UPPER(EmpIndicator)
                    INTO v_correct_ref_ind
                    FROM tblRef1
                    WHERE UPPER(USERNAME) = v_update_user
                    OR UPPER(USERID) = v_created_by;
                    IF v_correct_ref_ind IS NOT NULL THEN
                    -- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
                         UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
                    ELSIF
                    -- Check the Other tables here????
                    END IF;
               END IF;
          END;
     END LOOP;
     CLOSE cur_plan;
     COMMIT;
END
Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
Thanks.

Ah, ok; I got the updates the wrong way round then.
BluShadow's single update sounds like what you need then.
I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • I need Help with the stored procedure

    Hello, I new with VS.Net
    I'm tring to call a stored procedure, but when i try to retrive the data don't return nothing.
    my VB code is the follows
    ocm_comando.Connection = ocn_coneccion
    ocm_comando.CommandText = "WPROC_PRUEBA"
    ocm_comando.CommandType = CommandType.StoredProcedure
    ocm_comando.Parameters.Add("PNI_ID_ESTUDIO", OracleDbType.Decimal).Direction = ParameterDirection.Input
    ocm_comando.Parameters("PNI_ID_ESTUDIO").Value = CType(vc_id_estudio, Integer)
    ocm_comando.Parameters.Add("pco_precalificada", OracleDbType.Varchar2).Direction = ParameterDirection.Output
    ocm_comando.Parameters.Add("pco_resultado", OracleDbType.Varchar2).Direction = ParameterDirection.Output
    Txb_empresa.Text = ocm_comando.Parameters("pco_precalificada").Value
    My stored procedure only take the parameter that I sent and make a simple select and return the value in the variable pco_precalificada
    thank for your help
    **** Sorry for mi English

    You forgot to actually execute the command. Before the last line, where you ask for the value of pco_precalificada, you need to:
    1. Open the connection (if it's not already open)
    2. Call ocm_comando.ExecuteNonQuery()
    HTH,
    Tom

  • Help! Need oracle help with constructing stored procedure that return resultsets

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

  • Help with Command - Stored Procedure

    Hi all,
    I'm having a great deal of difficulty getting my head around
    an update command / stored procedure, I've pulled out all of my
    books and spent the last two days on Google which has made my
    confusion worse. In simple terms what I'm trying to do is update a
    field in a table with the value y, but based on certain criteria.
    So my table has the following fields -
    JBAID
    JBASiteID
    JBADatePosted
    JBAPostFor
    JBANotified
    What i want to do is update the value of field JBANotified on
    all records that meeting the following criteria to Y
    The criteria is -
    WHERE DATEADD(d,JBAPostFor,JBADatePosted) BETWEEN DATEADD(d,
    -7, GETDATE()) AND GETDATE() AND JBANotified = 'n' AND JBASiteID =
    MMColParam (where MMColParam is Session("SITEID"))
    So I've just tried building a command / stored procedure -
    which reads (see attached code)(more than likely all wrong)
    The things that I cant get my head around are -
    Firstly getting the code right in the first place, running
    the command on page load and then when the command has run
    redirecting to the next page.
    I really would appreciate some help with this -
    thanks all

    Ed Stewart wrote:
    > Are you using CS3 with ASP/VBScript? There is a bug in
    the command
    > implementation that has this function broken.
    >
    > I asked about it in this forum several months ago, but
    now I can't find my
    > original post, but I did find another post that talks
    about the same thing:
    >
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=26
    > 3&threadid=1281539&enterthread=y
    >
    > My solution is to drop back to DW8 for command editing,
    but use CS3 for
    > everything else. I don't know what you're supposed to do
    if you don't have an
    > earlier version.
    >
    > It looks like your sql is correct, but the bug prevents
    the second code block
    > is not being updated with the correct values.
    >
    > I hope a solution is forthcoming....
    >
    Create a stored procedure and then use a recordset to
    exectute it,
    making sure the recordset has matching parameters that the
    stored
    procedure expects.
    Commands are broken, I reported it to Adobe and they said it
    might get
    fixed in the next version.
    Steve

  • I need help writing a stored procedure

    How do I update several tables with columns that store social security number as a single transaction? I have over 70 tables to update the ssn with correct ssn.The database I'm working on is not normalized.
    The update is strictly by request. Occasionally, I get calls for a customer who entered their ssn wrongly the first time they registered on the our website. when I get such a request, I manually update all the ssn in every database table that stores information
    about the customer. A very tedious task to update over 70 tables with ssn columns one by one. Does anyone have an idea how to do this efficiently ?Can someone show me how write a stored procedure that I can pass in the old SSN and the new SSN then it updates
    the 70 tables accordingly?
    Does anyone have a blue print that demonstrates how to write the stored procedure?
    TableName ColumnName
    table1 colA
    table2 colB
    table3 colC
    table4 cold
    I query the INFORMATION_SCHEMA.COLUMNS view
    to retrieve all the tables that have ssn columns as shown above.

    You can create a procedure that receives a ssn parameter and a key value to be searched for in every table, and then a varchar(max) variable that would store a dynamically generated SQL command based on the parameter values and the tables with the ssn column.
    Example:
    -- THE FOLLOWING VARIABLES ARE PARAMETERS
    DECLARE @SSN VARCHAR(100) = '12354676'
    DECLARE @PREDICATE VARCHAR(100) = 'A'
    DECLARE @CMD VARCHAR(MAX) = '' -- THIS IS THE COMMAND VARIABLE
    -- THIS WILL BUILD A SCRIPT TO UPDATE ALL TABLES WHICH CONTAIN THE SSN COLUMN
    SELECT @CMD = @CMD + 'UPDATE ' + T.NAME + ' SET SSN = ''' + @SSN + ''' WHERE KEY_COLUMN = ''' + @PREDICATE + '''
    GO
    FROM SYS.TABLES T
    WHERE T.OBJECT_ID IN (SELECT OBJECT_ID FROM SYS.COLUMNS WHERE NAME = 'SSN')
    EXEC (@CMD);
    Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this
    is an undocumented behavior and should not be relied upon.

  • Help with a stored procedure....

    i'll be honest, i have never written one, and i have been doing research all day to do one and i have not had much luck. Seems like they mostly all take variables or require data that i just do not want it to require.
    I have a query (using TOAD fyi) that is run every morning.... i am trying to make it a stored procedure because i am in the process of automating this for people who want it as opposed to sending it to everyone.
    This is the query i am trying to turn into a stored procedure.... (some details removed for sake of security)
    SELECT CASE
    WHEN stuff
    ELSE 'Unknown'
    END aging,
    a.transaction_type, a.status_code, b.description, a.exception_code,
    c.description,
    decode(a.exception_code,'XXXX','YYYY',
    'XXXX','YYYY',
    'XXXX','YYYY','EXCEPTION') "CATEGORY"
    ,COUNT (*)
    FROM (SELECT TO_DATE
    (DBMS_LOB.SUBSTR (clob_details,10,DBMS_LOB.INSTR (clob_details,
    '<TransactionDate>') + 17 ),'yyyy-mm-dd') receipt_date,
    transaction_type, status_code, exception_code
    FROM thisdb.TRANSACTION
    WHERE status_code = 'MX'
    AND clob_details IS NOT NULL) a,
    thisdb.status b,
    thisdb.EXCEPTIONS c
    WHERE a.exception_code = c.exception_code
    AND a.status_code = b.status_code
    and a.status_code = 'MX'
    GROUP BY a.status_code,
    b.description,
    a.transaction_type,
    a.exception_code,
    c.description,
    CASE
    WHEN Stuff
    ELSE 'Unknown'
    END;
    now, please do not worry about the contents of the query, it works nicely and does its job :)
    but how can i take this and encapsulate it so that i can turn it into a stored procedure?
    Thank you all very much for any and all advice, i do greatly appreciate it!

    Hi,
    user12733751 wrote:
    it is just a query, the results will be going to excel later, all that is created already (the connection and runnign basic queries via excel VBA), so perhaps you are right, i do not need a stored procedure but a view?
    I have not heard of a view (stored query), how does that work?You create a view once for all like this:
    CREATE OR REPLACE VIEW  fubar
    AS
    SELECT    CASE
               WHEN  stuff
              ...     -- the rest of your original query goes here
              END;And you use it just like a table:
    SELECT  *
    FROM    fubar;A user who runs this last, extremely short, query gets the exact same results as someone who runs your original query.
    Here's a completely different approach.
    Depending on your front-end, you could also save your original query in a script, called fubar.sql, and people could run it by simply saying
    @fubar

  • New Oracle DBA - Need help with backup & restore procedure via RMAN

    Hello everyone,
    I've been a SQL Server DBA for 12 years now, but new to the Oracle space. My first assignment at work was to refresh our training environment with production. So with that said, I took a full backup of our production database via RMAN and backed up the Control File. I then copied both the Control File and full backup from our production environment to training. I followed the procedures listed in the URL below:
    http://www.dba-oracle.com/t_rman_clone+copy_database.htm
    I then connected to RMAN and executed a 'show all' which is as follows:
    RMAN configuration parameters are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
    CONFIGURE BACKUP OPTIMIZATION OFF; # default
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
    The CONFIGURE CONTROLFILE AUTOBACKUP was set to ON but received a message that the database needed to be mounted, so, I mounted the database and made the changes, but when I shutdown the database and performed the startup nomount again, the settings were gone. Are these settings valid only when the database is mounted? How can I successfully refresh this training environment with production data? I'm at a standstill here so any help would be very much appreciated.
    Thank you,
    Pete

    The CONFIGURE CONTROLFILE AUTOBACKUP was set to ON but received a message that the database needed to be mounted, so, I mounted the database and made the changes, but when I shutdown the database and performed the startup nomount again, the settings were gone. These settings are persistent settings.So these information retain in control files.To reading information from control files database instance must be MOUNT or OPEN stage.Due to you have mount instance and try SHOW ALL command through RMAN.
    Are these settings valid only when the database is mounted? Not only MOUNT also OPEN stage.
    How can I successfully refresh this training environment with production data? I'm at a standstill here so any help would be very much appreciated.
    There are several ways like duplication.But you take full backup from production database using BACKUP DATABASE through rman.In this case you will get also AUTOBACKUP for controlfiles/spfiles.Then copy these backup files and all available archive logs to training server and perform below steps.
    1) You have set properly ORACLE_HOME and ORACLE_SID environment variable.After that first need restore spfile as
    rman target /
    startup force nomount;
    restore spfile from 'autobackup_location';
    startup force nomount;2) Now you have to restore controlfiie as
      rman>restore controlfile from  'autobackup_location';
    rman>alter database mount;
      3) Now need catalog(it means register) all backup files and archivelogs in new restored controlfile as
       rman>catalog start with 'backuplocation';
       4) Finally you can restore and recover your database as below
       rman>restore database;
    rman>recover database;
    rman>alter database open resetlogs;
       If you want restore database to new location then before executing RESTORE DATABASE command you can use SET NEWNAME FOR DATAFILE clause.Firstly refer backup recovery guide in online documentation.

  • Help with calling stored procedure and preparing statement

    hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();
                con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
                *cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
    ERROR:
    Incompatible Types
    Found : java.sql.Statement
    Required: java.sql.CallableStatement

    Nevermind guys..i got it..
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();           
                cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
                }     Edited by: daimous on Jan 31, 2008 6:04 PM

  • I need help with re-storing my G4

    It was running fine, i just had memory issues. I bought an external hard drive so I can save my larger files. It's been running a bit slow and my applications have been quiting unexpectadly. Firefox, illustrator, photoshop all quites. So I decided to back up everything and start fresh and repartition my drives so my start-up can have more memory.
    I've re-installed Tiger only to get error messages at the end of the installations. I went to Disk Utilities and cleared it out, did a repair, and it sais nothing to repair.
    I tried re-installing it again and the the error log had all kinds of codes i don't understand. The only start up disc the computer reads is the Tiger DVD.
    Before I go out and buy diskwarrior, is there something that I am not doing? I really can't afford to spend more money on this.

    My mac came with a 10.2.1 version, so I did install the right disc and it's been working fine till now. My external drive is plugged with a USB instead of a firewire, so I thought that could be an issue.
    I have a PowerMac G4-version 2.1, 867 MHz speed, 133 bus speed, my system folder that I'm installing in is 50.11 Gig.
    this is an example of what was on my error log:
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Date/Time: 2007-06-07 04:52:02.839 -0700
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: OS Version: 10.4.3 (Build 8F46)
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Report Version: 3
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Command: Installer
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Path: /Applications/Utilities/Installer.app/Contents/MacOS/Installer
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Parent: LCA [94]
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Version: 2.1.0 (86.1)
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Build Version: 36
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Project Name: Installer
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Source Version: 860100
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: PID: 119
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Thread: 4
    Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Jun 7 04:52:25 c-24-60-225-224 crashdump[350]: Exception: EXCBADACCESS (0x0001)
    I had re-installed OS X 10.2.1 and it installed fine, but again firefox quit on me.

  • Performance problem with java stored procedure

    hi,
    i developped a java class, then I stored it in Oracle 8.1.7.
    This class contains several import of other classes stored in the database.
    It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
    I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
    Has anyone an idea to increase the performance of this execution of my class ?
    In particular, is there a way to keep permanently in memory the java objects used by my class ?
    Thanks in advance
    bye
    [email protected]
    null

    before running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
    Kuassi
    I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
    O/S: IBM AIX
    Oracle: 8.1.7

  • What is the problem with this Stored Procedure

    Hi ,
    What is the problem with this Stored Procedure ?Why is it giving errors ??
    CREATE or replace  PROCEDURE getEmpName
    *(EMP_FIRST OUT VARCHAR2(255))*
    BEGIN
    SELECT ename INTO EMP_FIRST
    FROM Emp
    WHERE EMPNO = 7369;
    END ;
    */*

    You don't specify precision in procedure arguments.
    (EMP_FIRST OUT VARCHAR2(255))should be
    (EMP_FIRST OUT VARCHAR2)Since you asked what's wrong with it, I could add that it needs formatting and the inconsistent use of upper and lower case is not helping readability.

  • Need help with Berkeley XML DB Performance

    We need help with maximizing performance of our use of Berkeley XML DB. I am filling most of the 29 part question as listed by Oracle's BDB team.
    Berkeley DB XML Performance Questionnaire
    1. Describe the Performance area that you are measuring? What is the
    current performance? What are your performance goals you hope to
    achieve?
    We are measuring the performance while loading a document during
    web application startup. It is currently taking 10-12 seconds when
    only one user is on the system. We are trying to do some testing to
    get the load time when several users are on the system.
    We would like the load time to be 5 seconds or less.
    2. What Berkeley DB XML Version? Any optional configuration flags
    specified? Are you running with any special patches? Please specify?
    dbxml 2.4.13. No special patches.
    3. What Berkeley DB Version? Any optional configuration flags
    specified? Are you running with any special patches? Please Specify.
    bdb 4.6.21. No special patches.
    4. Processor name, speed and chipset?
    Intel Xeon CPU 5150 2.66GHz
    5. Operating System and Version?
    Red Hat Enterprise Linux Relase 4 Update 6
    6. Disk Drive Type and speed?
    Don't have that information
    7. File System Type? (such as EXT2, NTFS, Reiser)
    EXT3
    8. Physical Memory Available?
    4GB
    9. Are you using Replication (HA) with Berkeley DB XML? If so, please
    describe the network you are using, and the number of Replica’s.
    No
    10. Are you using a Remote Filesystem (NFS) ? If so, for which
    Berkeley DB XML/DB files?
    No
    11. What type of mutexes do you have configured? Did you specify
    –with-mutex=? Specify what you find inn your config.log, search
    for db_cv_mutex?
    None. Did not specify -with-mutex during bdb compilation
    12. Which API are you using (C++, Java, Perl, PHP, Python, other) ?
    Which compiler and version?
    Java 1.5
    13. If you are using an Application Server or Web Server, please
    provide the name and version?
    Oracle Appication Server 10.1.3.4.0
    14. Please provide your exact Environment Configuration Flags (include
    anything specified in you DB_CONFIG file)
    Default.
    15. Please provide your Container Configuration Flags?
    final EnvironmentConfig envConf = new EnvironmentConfig();
    envConf.setAllowCreate(true); // If the environment does not
    // exist, create it.
    envConf.setInitializeCache(true); // Turn on the shared memory
    // region.
    envConf.setInitializeLocking(true); // Turn on the locking subsystem.
    envConf.setInitializeLogging(true); // Turn on the logging subsystem.
    envConf.setTransactional(true); // Turn on the transactional
    // subsystem.
    envConf.setLockDetectMode(LockDetectMode.MINWRITE);
    envConf.setThreaded(true);
    envConf.setErrorStream(System.err);
    envConf.setCacheSize(1024*1024*64);
    envConf.setMaxLockers(2000);
    envConf.setMaxLocks(2000);
    envConf.setMaxLockObjects(2000);
    envConf.setTxnMaxActive(200);
    envConf.setTxnWriteNoSync(true);
    envConf.setMaxMutexes(40000);
    16. How many XML Containers do you have? For each one please specify:
    One.
    1. The Container Configuration Flags
              XmlContainerConfig xmlContainerConfig = new XmlContainerConfig();
              xmlContainerConfig.setTransactional(true);
    xmlContainerConfig.setIndexNodes(true);
    xmlContainerConfig.setReadUncommitted(true);
    2. How many documents?
    Everytime the user logs in, the current xml document is loaded from
    a oracle database table and put it in the Berkeley XML DB.
    The documents get deleted from XML DB when the Oracle application
    server container is stopped.
    The number of documents should start with zero initially and it
    will grow with every login.
    3. What type (node or wholedoc)?
    Node
    4. Please indicate the minimum, maximum and average size of
    documents?
    The minimum is about 2MB and the maximum could 20MB. The average
    mostly about 5MB.
    5. Are you using document data? If so please describe how?
    We are using document data only to save changes made
    to the application data in a web application. The final save goes
    to the relational database. Berkeley XML DB is just used to store
    temporary data since going to the relational database for each change
    will cause severe performance issues.
    17. Please describe the shape of one of your typical documents? Please
    do this by sending us a skeleton XML document.
    Due to the sensitive nature of the data, I can provide XML schema instead.
    18. What is the rate of document insertion/update required or
    expected? Are you doing partial node updates (via XmlModify) or
    replacing the document?
    The document is inserted during user login. Any change made to the application
    data grid or other data components gets saved in Berkeley DB. We also have
    an automatic save every two minutes. The final save from the application
    gets saved in a relational database.
    19. What is the query rate required/expected?
    Users will not be entering data rapidly. There will be lot of think time
    before the users enter/modify data in the web application. This is a pilot
    project but when we go live with this application, we will expect 25 users
    at the same time.
    20. XQuery -- supply some sample queries
    1. Please provide the Query Plan
    2. Are you using DBXML_INDEX_NODES?
    Yes.
    3. Display the indices you have defined for the specific query.
         XmlIndexSpecification spec = container.getIndexSpecification();
         // ids
         spec.addIndex("", "id", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         spec.addIndex("", "idref", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         // index to cover AttributeValue/Description
         spec.addIndex("", "Description", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_SUBSTRING, XmlValue.STRING);
         // cover AttributeValue/@value
         spec.addIndex("", "value", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         // item attribute values
         spec.addIndex("", "type", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         // default index
         spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
         // save the spec to the container
         XmlUpdateContext uc = xmlManager.createUpdateContext();
         container.setIndexSpecification(spec, uc);
    4. If this is a large query, please consider sending a smaller
    query (and query plan) that demonstrates the problem.
    21. Are you running with Transactions? If so please provide any
    transactions flags you specify with any API calls.
    Yes. READ_UNCOMMITED in some and READ_COMMITTED in other transactions.
    22. If your application is transactional, are your log files stored on
    the same disk as your containers/databases?
    Yes.
    23. Do you use AUTO_COMMIT?
         No.
    24. Please list any non-transactional operations performed?
    No.
    25. How many threads of control are running? How many threads in read
    only mode? How many threads are updating?
    We use Berkeley XML DB within the context of a struts web application.
    Each user logged into the web application will be running a bdb transactoin
    within the context of a struts action thread.
    26. Please include a paragraph describing the performance measurements
    you have made. Please specifically list any Berkeley DB operations
    where the performance is currently insufficient.
    We are clocking 10-12 seconds of loading a document from dbd when
    five users are on the system.
    getContainer().getDocument(documentName);
    27. What performance level do you hope to achieve?
    We would like to get less than 5 seconds when 25 users are on the system.
    28. Please send us the output of the following db_stat utility commands
    after your application has been running under "normal" load for some
    period of time:
    % db_stat -h database environment -c
    % db_stat -h database environment -l
    % db_stat -h database environment -m
    % db_stat -h database environment -r
    % db_stat -h database environment -t
    (These commands require the db_stat utility access a shared database
    environment. If your application has a private environment, please
    remove the DB_PRIVATE flag used when the environment is created, so
    you can obtain these measurements. If removing the DB_PRIVATE flag
    is not possible, let us know and we can discuss alternatives with
    you.)
    If your application has periods of "good" and "bad" performance,
    please run the above list of commands several times, during both
    good and bad periods, and additionally specify the -Z flags (so
    the output of each command isn't cumulative).
    When possible, please run basic system performance reporting tools
    during the time you are measuring the application's performance.
    For example, on UNIX systems, the vmstat and iostat utilities are
    good choices.
    Will give this information soon.
    29. Are there any other significant applications running on this
    system? Are you using Berkeley DB outside of Berkeley DB XML?
    Please describe the application?
    No to the first two questions.
    The web application is an online review of test questions. The users
    login and then review the items one by one. The relational database
    holds the data in xml. During application load, the application
    retrieves the xml and then saves it to bdb. While the user
    is making changes to the data in the application, it writes those
    changes to bdb. Finally when the user hits the SAVE button, the data
    gets saved to the relational database. We also have an automatic save
    every two minues, which saves bdb xml data and saves it to relational
    database.
    Thanks,
    Madhav
    [email protected]

    Could it be that you simply do not have set up indexes to support your query? If so, you could do some basic testing using the dbxml shell:
    milu@colinux:~/xpg > dbxml -h ~/dbenv
    Joined existing environment
    dbxml> setverbose 7 2
    dbxml> open tv.dbxml
    dbxml> listIndexes
    dbxml> query     { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }
    dbxml> queryplan { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }Verbosity will make the engine display some (rather cryptic) information on index usage. I can't remember where the output is explained; my feeling is that "V(...)" means the index is being used (which is good), but that observation may not be accurate. Note that some details in the setVerbose command could differ, as I'm using 2.4.16 while you're using 2.4.13.
    Also, take a look at the query plan. You can post it here and some people will be able to diagnose it.
    Michael Ludwig

  • Need help with how to reset bios and admin password to reformat hard drive in 8440p elitebook.......

    need help with how to reset bios and admin password to reformat hard drive in 8440p elitebook? removal of cmos, resetting laptop, using cccleaner, windows password recovery and hiren's was noneffective, any help is appreciated. thanks

    Hi,
    As your notebook is a business class machine, security is more stringent - the password is stored in non-volatile memory and there are no 'backdoor' passwords.  Your best option would be to contact HP regarding this.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • Help: using a stored procedure to insert a record in DB

    A stored procedure:
    PROCEDURE db_insert
    db_block IN OUT plsql_table)
    is created in DB.
    db_select and db_update are created too. They both work fine as
    db_select is called by go_block execute_query (block populated) and
    db_update is called by commit (DB updated);
    I am trying to have db_insert called as:
    1. DO_KEY('Create_Record');
    2. fill in fields and then
    3. commit.
    These 3 steps do not cause the call of the auto generated block trigger insert_procedure. I think that after filling in the fields and there should be a way to call this insert_procedure trigger. I am not sure how this will work.
    Any suggestions are greatly appreciated.

    I went through quite a deep search and yet not found any good answers. Knowing that select and update all done well with execute_query(stored procedure is called) and commit(stored procedure is called), but not insert.
    Logically there must be some FORM build in that will trigger the call of stored procedure insert.
    I am still looking for answers and just to remind that there are quite number of similar posts and I do not think that any clear answers were delivered.
    Please help.

  • How to verify the user information pass by the form with a stored procedure?

    Hi,
    I would like to know how to verify user information pass by the form with a stored procedure.
    I want make a portal which accepts to new user registration, but I want verify the new user's informations (like the name don't contain a number etc).
    Thanks for your help
    regards
    jla

    Hi Samson,
    You can use the UI API to do this. You can catch the form_ADD event and then validate the input from the users. You can even block the event from completing (and stop the document from being added) if your code finds some incorrect data using the bubbleEvent functionality.
    I don't have one specific example to show you, but if you look at some of the SDK samples (for example C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents) to see how to work with events, you can then create your own validation to ensure the users data is valid.
    Regards,
    Niall

Maybe you are looking for

  • Quicktime pro crashes on all three of my computers_Help!

    I produce video using Premiere pro. I just bought QT pro 7 and the mpeg2 plugin. I am trying to export ipod compatible files and other MP4 files. No matter what I try the success rate is extrely limited. I have manged 1 or 2 files to export sucessful

  • Creating a report batch

    I have a series of reports which must be run periodically -- all use the same parameters, but access different tables. I would like to enter the parameters once, and have all the reports run. There is no need for communication between the reports. I

  • Windows DEP error when scanning in Acrobat Pro 9.2

    Hi-- I scan in Acrobat Pro using create docuemnt>from scanner, via a TWAIN driver.  I upgraded from 9.1.3 to 9.2 recently, last week sometime, and this is the first time I've tried to scan.  If I try to scan, I get an error that Windows DEP is closin

  • SOAP error in SL4 app

    I have a Silverlight 4 app that uses SOAP services to get data from a SQL db. It worked fine on a windows 2003 server with IIS 6. I am trying to move the app to a Windows 2008 Server with IIS 7. When I try to run the app on the 2008 server I get the

  • Using nested query to avoid repeated object traversal

    Hi everyone, My SQL is still very basic, hopefully this is not a dumb question ;-) I have a table with a single spatial column of type SDO_GEOMETRY: SQL> desc WITHIN_POINT_DISTANCE_TAB Name                                            Null?    Type POI