Help regarding coding stored procedure

Dear All,
i am new in oracle. i have to develop an application for a store, where some material In and Out on daily basis.
and i want to see current status any time.
any one give me any idea how to do that means coding of stored procedure, on whose basis i can create material IN and OUT form.
If Any one have such application please Please share
thanks,
Sachin

I've never done this before, but on this google search
http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=%22java+stored+procedure%22+hello
This was the first hit
http://otn.oracle.com/oramag/oracle/03-jan/o13java.html
and after 30 seconds of looking at it, I noticed this line
loadjava -user scott/tiger Hello.class
was specifing .class instead of your .java
Could that be the problem?????

Similar Messages

  • 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! *{;-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help in JAVA stored procedure

    Hi,
    We need to interface a JAVA application from a pl/sql block. We are using JAVA stored procedure to do the same. This
    stored java class ( that we call from a PL/SQL procedure) has the
    statement ( " textFont = new Font("Arial", 0, 11)" ) where a Font is
    initialized. This is throwing an error message as given below. Please
    let us know if there is any issue with respect to usage of java.awt
    classes in java stored procedures (Oracle JVM of Oracle9i Enterprise
    Edition Release 9.2.0.2.0).
    We tracked down the exception to the following stack trace:
    java.lang.NullPointerException
    at java.lang.Class.forName0(Class.java)
    at java.lang.Class.forName(Class.java)
    at
    java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnviron
    ment.java)
    at java.awt.Font.initializeFont(Font.java)
    at java.awt.Font.<init>(Font.java)
    at com.idautomation.pdf417.PDF417.<init>(com/idautomation/pdf417/PDF417)
    at GenBarCode.createBarCode(GenBarCode.java:24)
    at CallGenBarCode.callGenerateBarCode(CallGenBarCode.java:14)
    g_error_text= ORA-29532: Java call terminated by uncaught Java
    exception: java.lang.NullPointerException in CallGenBarCode_callGBC
    DECLARE
    ERROR at line 1:
    ORA-20001: ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NullPointerException in CallGenBarCode_callGBC err 15
    ORA-06512: at line 12
    Any pointers in this regard will be of great help.
    thanks,
    Ayyappa

    Hi,
    OracleJVM, as a server-side VM, does not support any UI classes such as awt and swing. The basic GUI components found in the JDK's Abstract Windowing Toolkit (AWT) cannot be used in Stored procedures.
    For more information refer to http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96659/01_intro.htm#16826
    Hope this helps.
    Sujatha.
    http://otn.oracle.com/sample_code/content.html

  • Help creating a stored procedure

    I have a query that is going to run many, many times per day, potentially hundreds of thousands so I want to make sure it's as quick as possible
    The purpose is to take a compiled IP number, look it up and relate it back to the country based on data in the table for current IP/countries
    There are currently 113,536 records in the country table, It's typically taking around 4ms to 5ms, so it's not exactly slow, but as the use of this particular lookup is going to increase significantly I'd like to make sure I have it as fast as possible.
    Here's the current code:
    <CFSET ipnumber = (#listgetat(remote_addr,1,'.')# *256*256*256) +  (#listgetat(remote_addr,2,'.')# *256*256) + (#listgetat(remote_addr,3,'.')#  *256) + #listgetat(remote_addr,4,'.')#>
    <CFQUERY name="GetCountry" DATASOURCE="#datasource#">
        SELECT TOP 1(countryshort) as countryshort
        FROM #ipcountry#
        WHERE ipfrom <= #ipnumber# and ipto >= #ipnumber#
    </CFQUERY>
    The first thought is to try to create a stored proc to see if that generates any performance gain, I've search and read over several documents on setting one up, but I have to admit, I just can't quite grasp it.
    I'm wondering if anybody would be kind enough to stick this query into a stored proc for me and let me know what CF code I need to execute it and read the result.
    Once I see this done I am sure I'll be able to push forward from there on my own in the future
    Thanks
    Mark

    JR \"Bob\" Dobbs wrote:
    Bear in mind that database servers, such as Microsoft SQL Server, will cache the execution plan for parameterized SQL queries which will result in performance gains similar to use of a stored procedure. 
    You might try using CFQUERYPARAM in your queries.  This is also recommended to help prevent SQL injection attacks.
    You might also create indexes on the ipfrom column on your table.
    Agreed. Just wrapping a query in a stored procedures does not mean it is going to run faster. Look at the table's indexes and examine the execution plan to see how it can be improved. And you really should be using cfqueryparam in all of your queries. Not just for performance, but because you are risking sql injection attacks without it.
    HiTopp wrote
    EXEC sp_executesql @sql,
    Since the table name is hard coded, there really is not a need for dynamic sql in this query.
    Message was edited by: -==cfSearching==-

  • Please help convert MSSQL Stored Procedure to Oracle PL/SQL

    Hi there to all,
    this be my first post to these forums. I have already posted this question on a microsoft msdn forum, until someone advised that I ask my question here - dunno why I didnt think of that! ?:|
    Im working with an Oracle 10g Database from an ASP.NET 2.0 application, and want to know if it Oracle supports OPENXML (rhetorical question I fear!). The reason I ask is because I want to create an Oracle Stored Procedure that will accept an XML string as an input parameter, prepare it, select from it, and then insert it into an Oracle table.
    I have done this successfully in SQL server using the following as an example:
    CREATE PROCEDURE [dbo].[Employee_INSERT]
    bq. @INSERTRECORD XML
    AS
    BEGIN
    bq. DECLARE @XDOC INT; \\ EXEC sp_xml_preparedocument @XDOC OUTPUT, @INSERTRECORD; \\ INSERT INTO [dbo].[REC_Employees] (
    bq. bq. [EMPTITLE], \\ [EMPFNAME], \\ [EMPLNAME], \\ [EMPDEPTID], \\ [EMPBEGINDATE], \\ [EMPACTIVE], \\ [EMPDATEADDED]
    bq. )
    bq. SELECT
    bq. bq. [EMPTITLE] = Title, \\ [EMPFNAME] = Firstname, \\ [EMPLNAME] = LastName, \\ [EMPDEPTID] = DepartmentID, \\ [EMPBEGINDATE] = StartDate, \\ [EMPACTIVE] = IsActive, \\ [EMPDATEADDED] = GETUTCDATE()
    bq. FROM
    bq. bq. OPENXML(@XDOC, '/EMPREC/Table', 2) \\ WITH (
    bq. bq. Title VARCHAR(10), \\ FirstName VARCHAR(50), \\ LastName VARCHAR(50), \\ DepartmentID INT, \\ StartDate DATETIME, \\ IsActive BIT
    bq. bq. );
    bq. EXEC sp_xml_removedocument @XDOC;
    END
    I would sincerely appreciate any help in this regard!
    PS - Please excuse the formatting!
    Much Thanks!
    regards
    shalan

    Assuming your table is named DESTINATION
    Name                                      Null?    Type
    TITLE                                              VARCHAR2(10)
    FIRSTNAME                                          VARCHAR2(50)
    LASTNAME                                           VARCHAR2(50)
    DEPARTMENT                                         NUMBER
    STARTDATE                                          DATE
    ISACTIVE                                           NUMBERYou can use a procedure like:
    create or replace
    procedure test (p_xml in xmltype)
    is
    begin
      insert into destination
      select title
           , firstname
           , lastname
           , department
           , to_date (startdate, 'yyyy-dd-mm hh24:mi:ss') startdate
           , isactive
        from (xmltable ('/EMPREC/Table' passing p_xml
                       columns title varchar2(5) path 'Title'
                             , firstname varchar2(10) path 'FirstName'
                             , lastname varchar2(10) path 'LastName'
                             , department number path 'Department'
                             , startdate varchar2(20) path 'StartDate'
                             , isactive number path 'IsActive'
                      ) temp
    end test;to create records in the table
    Removed a unnecessary SELECT FROM DUAL...
    Edited by: Alex Nuijten on Jan 19, 2009 2:24 PM

  • Help in writing stored procedure!!!

    Hi,
    I m working step by step ....its very unclear to me ...because, my boss gave me SAS code and asking me to convert it into PL/SQL code ...without businees requiremnet.....thats sounds really wired .....And i dont know the SAS......So please help me in this regard ..How do i write a stored procedure for the following requirement...
    Create a table master as select from*
    *( select * from acct_master*
    where join_dt < NVL( close_dt,sysdate)
    oder by acct_nbr, join_dt, nvl (close_dt,sysdate));
    here its creating a master table and inserting the acct_master(prod table) result. Now the next step is i have to query the data which i got in master which is a another step, and that resulted query has to be inserted into another table called 'TEST'.
    so how do i write a proc for this above process......Pleaseee....Help!!!! Thank you so much ...i really appriciate it.

    Raj,
    Here is the SAS code ....for What i described Before... I m absolutely new to SAS ...first time im looking at SAS code....I m Posting what they gave me and told me ....
    There are basicallY two parts ......First part creates table i guess and second part queries the data i guess...
    First part*.........
    proc sq1;
    &con_str;
    create table master (sortedby= acct_nbr join_dt ) as
    select *
    from connection to ora (
    select *
    from acct_master
    where join_dt < nvl ( close_dt, SYSDATE)
    order by acct_nbr, join_dt, NVL
    (alian_close_dt, sysdate) )
    & dis_str;
    quit;
    Second Part*
    %let EOT = '31MAY3000'd;
    data test ;
    set master (keep= acct_nbr id join_dt close_dt cu_type cu_stat csd_resn );
    format init_join_dt join_dt close_dt effective_dt expire_dt lag1_expire_dt date9.
    fy_join 4.
    init_cu_type $3. ;
    retain init_join_dt fy_join n dlk_pend lag1_expire_dt lag1_id 0
    init_cu_type ;
    by acct_nbr join_dt ;
    join_dt = datepart(join_dt);
    close_dt = datepart(close_dt)-1;
    if first.acct_nbr then do
    dlk_pend = 0;
    lag1_id = .;
    lag1_expire_dt = .;
    init_join_dt = join_dt ;
    fy_join = year(intnx('month',join_dt,7));
    init_cu_type = cu_type;
    n = 1;
    end;
    expire_dt = close_dt ;
    lag1_id = lag1(id);
    lag1_expire_dt = lag1(expire_dt) ;
    if dlk_pend then do ;
    cu_class = 'DLK';
    effective_dt = lag1_expire_dt + 1;
    expire_dt = join_dt - 1;
    curr_id = id ;
    id = lag1_id;
    dlk_pend=2;
    output;
    id = curr_id ;
    dlk_pend=0;
    end;
    effective_dt = join_dt ;
    /* If the join date is in the initial fiscal year (01 june is fiscal year) */
    if join_dt < MDY( 6, 1, fy_join ) then do
    cu_class = init_cu_type;
    /* If it's open or closed after the end of the initial fiscal year */
    if close_dt = . or close_dt >= MDY( 6, 1, fy_join ) then do ;
    * Create one record through the end of the fiscal year;
    expire_dt = MDY( 6, 1, fy_join ) -1 ;
    output;
    * Create another record through the close date or leave open;
    effective_dt = expire_dt + 1 ;
    cu_class = 'EXISTING';
    expire_dt = coalesce(close_dt,&EOT) ;
    output;
    end;
    else do;
    * it it closed in the initial fiscal year, then output just one record ;
    expire_dt = close_dt ;
    output ;
    end;
    end;
    * if the record starts after the initial fiscal year ;
    else do;
    * Create a record through the close date or leave open;
    cu_class = 'EXISTING';
    expire_dt = coalesce(close_dt,&EOT) ;
    output;
    end;
    * if record is delink, output a DLK record ;
    if cu_stat = 'CLOSED' and csd_resn = 'DLK' then do
    effective_dt = close_dt + 1;
    expire_dt = &EOT ;
    cu_class = 'DLK';
    if last.acct_nbr then output;
    else dlk_pend = 1 ;
    end;
    n+1;
    run;
    So here is the SAS code ....Thank you so much guys ...i really appriciate it!!!!

  • Help needed in stored procedures

    Hi,
    I wrote a stored procedure when i execute it. i get the error
    ORA-00942: table or view does not exist
    ORA-06512: at "SANDEEP.PROC_INS_TEMP_NAC_GL", line 18
    ORA-06512: at line 9
    I was unable to resolve this error please help.
    CREATE OR REPLACE PROCEDURE PROC_INS_TEMP_NAC_GL(
    p_bu IN STRING,
    p_period IN STRING
    IS
    sql_stmt varchar2(1000);
    cnt number;
    BEGIN
         SELECT count(view_name) INTO cnt FROM sys.all_views where view_name = UPPER(p_bu||'_v_ldga') and owner = 'SUN';
         sql_stmt := 'INSERT INTO temp_nac_gl'||
         ' SELECT ''' || p_bu ||'''BU, gl.ACCNT_CODE , gl.ANAL_T0 , gl.ANAL_T1 , gl.PERIOD , gl.MEMO_AMT , gl.AMOUNT , gl.REGION, gl.ANAL_T3'||
                   ' FROM sun.'|| p_bu ||'_v_ldga gl, temp_acnt_grp acnt' ||
                   ' WHERE gl.accnt_code = acnt.acnt_code ' ||
                   ' AND acnt.bu = '''|| p_bu ||'''' ||
                   ' AND gl.period <= '''|| p_period || '''' ||
                   ' ORDER BY gl.REGION';
    EXECUTE IMMEDIATE sql_stmt;
    END;
    /

    If you are accessing a object from a Oracle procedure/function then you need direct rights and not through roles.
    You can check this by executing a SELECT from SQL plus , if you are able to see the table then type the following commond
    SQL> set role none;
    SQL> SELECT statement
    If it gives an error then you dont have direct rights.
    Thanks
    Edited by: Himanshu Kandpal on May 14, 2009 5:04 PM

  • HELP!! Stored Procedures - Adding and Inserting Records

    Can ANYONE tell what I'm doing wrong? I'm learning PL/SQL, and I don't know what I'm missing here.
    For starters, I'm trying to write a stored procedure to:
    -- insert data into a NULL column added using ALTER TABLE
    -- there's about +/- 45 records where this data needes to be added.
    -- the value for each null field in the column is a random value (that is, generated using dbms_random.random
    I've tried several ways to write the procedure, but have run against a wall to determine what I'm missing.
    Here's the SQL statements and the error messages:
    SQL> CREATE OR REPLACE PROCEDURE update_proj_number (p_proj4_id IN VARCHAR2)
    2 AS
    3 BEGIN
    4 DECLARE
    5 v_counter NUMBER(5) := 0;
    6 END;
    7 BEGIN
    8 v_counter := 0;
    9 dbms.random.initialize(32768);
    10 v_counter := v_counter + 1;
    11 p_proj4_id := dbms.random.random
    12 UPDATE sample_trades
    13 SET proj4_id = RANDOM(p_proj4_id);
    14 exit when NOTFOUND%;
    15 END;
    16 /
    Warning: Procedure created with compilation errors.
    SQL>
    SQL> SHOW ERRORS
    Errors for PROCEDURE UPDATE_PROJ_NUMBER:
    LINE/COL ERROR
    6/2 PLS-00103: Encountered the symbol "END" when expecting one of the following:
    begin function package pragma procedure subtype type use <an identifier>
    <a double-quoted delimited-identifier> cursor form current
    12/3 PLS-00103: Encountered the symbol "UPDATE" when expecting one of the following:
    . ( * @ % & = - + ; < / > in mod not rem an exponent (**)
    <> or != or ~= >= <= <> and or like between is null is not &#0124; &#0124; is dangling
    The symbol ";" was substituted for "UPDATE" to continue.
    14/22 PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( type <an identifier> <a double-quoted delimited-identifier>
    SQL>
    Would it be more efficient to use a cursor to fetch the rows containing the null value or is a stored procedure OK for this?
    Also, I would like to have a second example of a stored procedure that will add random rows to a table (that is, create duplicates of information already in the table). This stored procedure will also use dbms_random.
    For example,
    IF p_value1 = 'FIRST_VALUE' then
    add this record (incl. random_val for key);
    ELSIF p_value = 'SECOND_VALUE' then
    add that record (incl. random_val for key);
    and on and on.
    Much thanks to anyone who can help.
    For example,
    null

    Try this
    CREATE OR REPLACE PROCEDURE update_proj_number (p_proj4_id IN VARCHAR2)
    AS
    v_counter NUMBER(5) := 0;
    BEGIN
    v_counter := 0;
    dbms.random.initialize(32768);
    v_counter := v_counter + 1;
    p_proj4_id := dbms.random.random ;
    UPDATE sample_trades
    SET proj4_id = RANDOM(p_proj4_id);
    END;
    /

  • 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.

  • 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

  • Help Execute simple Stored Procedure - (please)

    When calling a simple Procedure from SQL Developer I am unable effectively utilize a value I am passing in. From a Worksheet I press 'Run Script' which executes this:
    DECLARE
    TICKET_ID NUMBER;
    v_Return VARCHAR2(200);
    BEGIN
    TICKET_ID := NULL;
    v_Return := GET_LOGISTIC_INFO(TICKET_ID => 1900710);
    DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
    END;
    The following stored procedure:
    CREATE OR REPLACE
    function get_logistic_info(ticket_id IN NUMBER) RETURN VARCHAR2 IS
    ret_name VARCHAR2(256);
    BEGIN
    --Not Working
    select logistics_method_id INTO ret_name from stub_trans where id=ticket_id;
    --Works! 
    --select logistics_method_id INTO ret_name from stub_trans where id=1900710;       
    return ret_name;
    END;
    When I hard code the ticket_id the Procedures runs just fine but when I try and utilized the passed in variable I get the error message:
    ORA-01403: no data found
    The record exists because if I use the hard-coded value I get a proper return:
    anonymous block completed
    v_Return = 4
    Any ideas?

    Is there a separate column in the stub_trans table called ticket_id? If there is, then you are just running the following (regardless of what you pass as the parameter):
    select stub_trans.logistics_method_id INTO ret_name from stub_trans where stub_trans.id=stub_trans.ticket_id;
    If this is the case, then either rename you parameter:
    function get_logistic_info(p_ticket_id IN NUMBER) RETURN VARCHAR2 IS
    or you can force PL/SQL to use the parameter, by referencing it more fully in your SQL, ie:
    select logistics_method_id INTO ret_name from stub_trans where id=get_logistic_info.ticket_id;

  • 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 needed in Stored Procedure validation

    Hi,
    I have defined 5 dimensions in my database. For GLs of Expense and Revenue drawer, I want to validate that if Dimension 1 is selected for a GL in any transaction, then Dimension 2 must also be mandatory.
    Now different transactions have different tables in SAP, like for service type AP Invoice and AR Invoice, I have to read different table; for Incoming & Outgoing Payment against Account, I have to read different table. Then there is Manual Journal Entry also etc.
    But all these transactions also generate a Journal Entry, so in my Stored Procedure, irrespective of AP, AR or whichever screen, how can I access the underlying Journal Entry of that transaction and validate the GL accounts in the Journal Entry that Dimension 2 is mandatory if Dimension 1 is selected?
    Thanks.

    Hi,
    What is your Account Dimension 1 and 2 supposed to be? Can you post here your Chart of Accounts? for us to build the right query for SP_TransactionNotification.
    Thanks
    Alvin

  • Help in calling stored procedure with parameter in JSP

    I need to know how to call this stored procedure in JSP
    here is my Stored procedure in oracle 9i:
    CREATE OR REPLACE procedure broker_activity
    (p_broker_id IN number,p_TotalValue out number,p_CrossValue out number, p_blockValue out number, p_MktWeight out number,p_BuyingVal out number, p_sellingVal out number, p_NetValue out number)
    AS
    begin
    declare
    -- buying value
    cursor c_BuyingVal is select buyer_firm, sum(volume*price) value from last_sale where buyer_firm = p_broker_id group by buyer_firm;
    -- selling value
    cursor c_SellingVal is select seller_firm,sum(volume*price) value from last_sale where seller_firm = p_broker_id group by seller_firm;
    v_BuyingCurVal c_buyingVal%rowtype;
    v_SellingCurVal c_sellingVal%rowtype;
    n_buy_val number :=0;
    n_sell_val number :=0;
    n_total_value number := 0;
    begin
    --buying value
    open c_BuyingVal;
    fetch c_BuyingVal into v_buyingCurVal;
    n_buy_val := nvl(n_buy_val,0) + v_buyingCurVal.value;
    --Exit when c_BuyingVal%NOTFOUND;
    close c_buyingVal;
    p_BuyingVal := n_buy_val;
    --selling value
    open c_SellingVal;
    fetch c_SellingVal into v_SellingCurVal;
    n_sell_val := nvl(n_sell_val,0) + v_SellingCurVal.value;
    -- Exit when c_BuyingFirm%NOTFOUND;
    close c_SellingVal;
    p_SellingVal := n_sell_val;
    --total value
    p_TotalValue := n_buy_val + n_sell_val;
    --cross val
    select sum(volume*price) into p_CrossValue from last_sale where board = 'C' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
    --block Sale
    select sum(volume*price) into p_BlockValue from last_sale where board = 'B' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
    --Net Value
    p_NetValue := n_buy_val - n_sell_val;
    --markte_weight
    select (sum(volume*price) * 2)/100 into p_MktWeight from last_sale ;
    end;
    end;

    http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html

  • 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.

Maybe you are looking for

  • How do you get your money back from a purchase you didn't recieve?

    I gave my girlfriend an iPhone for christmas last year and told her it was safe to shop on the app store. I have been paying for that mistake ever since. She quickly got interested in a fremium game called Dragon Vale and bought a huge pile of whatev

  • VMs on Hyper-V 2012 R2 are shutting down automatically

    Hello Guys!  I'm having a huge problem in my Hyper-V 2012 R2 environment. Yesterday, 9 of 40 VMs were shutdown automatically, and so, caused a downtime problem to my customers in the business hours. I checked in the Event Viewer (Application / System

  • DVD Burner won't recognize discs

    I recently installed an lg gsa-4166b dual layer dvd burner to my emac and for some reason it won't recognize cds or dvds. Whenever I try to burn anything and put in a blank disc I get the message "no disk inserted". I'm running Mac OSX 10.4.11 and ev

  • Moving photos from an ipod to a windows computer

    Friend of mine had his PC hard drive crash and lost all the photos on his hard drive. Fortunately, all the photos were synced to the iPod photo. Unfortunately, I have not been able to find a way to transfer photos from the iPod to another PC (since t

  • Timestamp in Oracle Forms10g

    Dear ALL, Can any one tell me how can i use the timestamp data type column in Oracle Forms 10G. when i create table with a time stamp as datatype and then when i make Data block by wizard i am getting FRM-10009 error message. My table structure is as