How to store procedure

how to write function for following calculation
"round((total(distinct if (PS = 'IAL' and Watsons(Pension)) or (PS ='NPL' and MNPL) or ( PS ='Original' and MS) or (PS ='SAPS' and MSAPS) or ( PS= 'Services' and MSer)) then (PERS (Unique for Employee)) Else(0) for Employee Number),2)"
Note : PS is direct field and other is user define function

hi ,
i want to write the function for following claculation
"round((total(distinct if (PS = 'IAL' and Watsons(id)) or (PS ='NPL' and MNPL) or ( PS ='Original' and MS) or (PS ='SAPS' and MSAPS) or ( PS= 'Services' and MSer)) then (PERS (Unique for Employee)) Else(0) for Employee Number),2)"
in this claculation ps is a colum of table which hold value and Watsons(id) ,
MNPL(id) ,MSAPS,... are function.
can we write if part using decode function
or any other way to manage above calculation
Thanks

Similar Messages

  • Stored Procedures - How to store procedures?

    Hi,
    I would like to use this feature on the database, how do I achieve this?
    What is a stored procedure? At the moment it is none. I will have to store this from somewhere. At the database design level?

    Reynold Dreamweaver CS6 wrote:
    Could you elaborate what do you mean by "...the php mysql 'standard' extension anyway, which is the one supported by DW'. Why do they not work?
    Hi
    The 'standard' php:mysql extension is the one used by php to communicate with the database server, (it translates the php you/Dw writes for the database). Each type of php database extension offers different functionality, and PDO, (this is my opinion) is the best one, as it not only supports SP's, Transactions/Views, but different databases, (with additional extensions required for each database type).
    The 'standard' php:mysql extension does not support any of these 'newer' features, and never will. If you visit the php site it well tell you that the old 'standard' extension should no longer be used as it has been deprecated, which means that it no longer being developed.
    Unless you are reliant on Dw extensions then I would recommend that you learn OOP, with one of the newer database models, as these are the future of php and databases.
    FIO: Yes, I do use OOP, PDO and SP's, Transactions in all of my database work now, and once learned these skills are much easier, (and more secure) to use than the old ones that you are currently learning.
    I also wrote a 'learners' extension for PDO and the MySQL database and one to display SP's in Dw, a few years ago, but I have for various reason stopped development. The extensions are available at - http://www.pziecina.com/design/dreamweaver/pdo_extension.php
    PZ

  • HOW TO EXECUTE A STORE PROCEDURE THAT RETURN MULTIPLE ROWS FROM A QUERY

    I NEED TO CREATE AND USE A STORE PROCEDURE THAT IS GOING TO DO A SELECT STATEMENT AN THE RESULT OF THE SELECT STATEMENT IS RETURN IN SOME WAY TO THE REQUESTER.
    THIS CALL IS MADE BY AN EXTERNAL LANGUAGE, NOT PL/SQL OR FORMS APPLICATION. USING FOR EXAMPLE ODBC AND VISUAL BASIC. WHAT I NEED TO DO IS ADD A DATA ACCESS LAYER TO MY APPLICATION AND I ALREADY HAVE IT DONE FOR MS SQL SERVER, BUT I NEED THE SAME FUNCTIONALITY ACCESSING AN ORACLE DATABASE.
    FLOW:
    1. VB CREATE A ODBC CONNECTION TO A ORACLE DATABASE
    2. VB EXECUTE A STORE PROCEDURE
    3. THE STORE PROCEDURE RETURNS TO THE VB APPLICATION THE RESULT OF THE QUERY THAT IS INSIDE OF THE STORE PROCEDURE.(I.E. THE STORE PROCEDURE IS A BASIC SELECT, NOTHING COMPLEX)
    4. VB DISPLAY THE RESULT IN A GRID
    FOR SURE I CAN DO THE SELECT DIRECTLY TO ORACLE, BUT FOR PERFORMANCE REASONS AND SCALABILITY, I'LL LIKE IT TO DO IT USING A STORE PROCUDURES
    IS THIS POSIBLE?, HOW?
    THANKS

    Certainly, it's possible. First, define a stored procedure that includes an OUT parameter which is a REF CURSOR. Then, call the stored procedure via ODBC omitting the OUT parameter from the list of parameters. IT will automatically be returned as a result set. Syntax for both is below...
    CREATE PROCEDURE foo (inParam in varchar2, resultSet OUT REF CURSOR )
    In ODBC:
    {call foo( 'someData' )}
    Justin

  • How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000

    Post Author: ltkin
    CA Forum: WebIntelligence Reporting
    Hi,
    How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000 ?
    Regards,

    Hi ltkin,
    Unfortunately, it is not possible in Xir2 to create Webi reports from stored procedures.
    Webi reports can only be created from Universe. So in Business Objects XIR3 we can create a special universe that enables Web Intelligence user's to access stored procedures residing in the database. This is the only way that Web Intelligence user's can access stored procedures.
    Please let me know if the above information helps.
    Regards,
    Pavan

  • How can i pass NULL value in Store Procedure?

    Hi guys,
    I am calling one store procedure from MS SQL Server 200, i had create the follow layout:
    But i need pass to MSQL SEVER the CPF = NULL, when i execute the procedre the CPF send empty value (not null).
    I already changed Communication Channel parammeter "Interpretation of Empty String Values" to "Null Value" value.
    But the interface always send empty string instead of null.
    How can anybody help me, please?
    Edited by: João Noberto dos Santos Junior on Jun 24, 2009 5:00 PM

    Hi,
    To achieve this through "Interpretation of Empty String Value" in the cc, you will have to implement a patch which is sent to you by SAP when an OSS is raised. By default its not available, i mean you can configure it but it will actually not work.
    As a temporary solution you can map your element with a constant/mapwithdefault field with value mentioned as NULL.
    Regards,
    Anshul

  • How to pass values to Oracle store procedure in Crystal Report

    Hi all,
    I am newbie on passing values to stored procedure parameters. I created a Crystal Report using the Crystal Report wiward with PULL method and data come from Oracle stored procedure. In an ASP.NET page, I have stored two values in Session and need to pass them as input parameters to Oracle stored procedure to print the report. In Crystal reports 2010 once you connect to a stored-procedure as data source, it automatically creates the parameter fields with Crytal Report Viewer. Please show me how I pass values to store procedure at runtime automatically.
            'Set the parametter value
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
        End Sub
    I tried to apply above codes from Brian Bischof book but display the error from the following lines:
            myReport.SetParameterValue("@P_COURSE", "CoursetNo")
            myReport.SetParameterValue("@P_CLASS", "ClassNo")
    I also enclosed my code. Any experts, please let me know anything wrongs on my code . I tried several methods that searching via google, but did not solve my issues. Thanks.
    Edited by: avt2K7 on Mar 15, 2011 7:02 AM

    Hi,
    Thank you for your response. Here are the detailed code and error as following:
    Please show what I am missing in my below VB.NET codes:
    ===========================================================================================
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            LogonToTables("username", "password", "servername", "")
        End Sub
        Private Sub LogonToTables(ByVal myUserId As String, ByVal myPassword As String, ByVal myServerName As String, ByVal myDataBaseName As String)
            Dim Course, Class As String
            Course = Session.Item("CourseNumber"))
            Class = Session.Item("ClassNumber"))
            Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            myReport.Load(Server.MapPath("CrystalReport1.rpt"))
            Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
            'Set the database properties and security credentials
            Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
            myConnectionInfo.ServerName = "servername"
            myConnectionInfo.DatabaseName = ""
            myConnectionInfo.UserID = "username"
            myConnectionInfo.Password = "password"
            'Apply the ConnectionInfo to the report tables
            Dim myTables = myReport.Database.Tables
            For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
                myTableLogonInfo = myTable.LogOnInfo
                myTableLogonInfo.ConnectionInfo = myConnectionInfo
                myTable.ApplyLogOnInfo(myTableLogonInfo)
            Next
            'Set the parametter value to Crystal Report parameter named P_COURSE and P_CLASS
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
        End Sub
    =================================================================================
    I put a break point to debug but display the error at the following lines:
            myReport.SetParameterValue("@P_COURSE", "Course")
            myReport.SetParameterValue("@P_CLASS", "Class")
    Eventhough, if I set a specific value to Course=1000 and Class = math and still receive the error:
    Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    I tried several sources from Google search but it is not working. I really appreciate any detailed code either in C# or VB.NET to solve my issues. Thanks in advance.

  • How to Pass multiple parameter into single store procedure

    How to Pass multiple parameter into single store procedure
    like a one to many relationship.
    it is possible then reply me immediatly

    you mean like this .....
    CREATE OR REPLACE procedure display_me(in_param in varchar2,in_default in varchar2 := 'Default') is
    BEGIN
    DBMS_OUTPUT.put_line ('Values is .....'||in_param || '....'||in_default);
    END display_me;
    CREATE OR REPLACE procedure display_me_2 as
    cnt integer :=0;
    BEGIN
    For c1_rec In (SELECT empno,deptno FROM test_emp) Loop
         display_me(in_param => c1_rec.empno);
         cnt := cnt+1;
         end loop;
         DBMS_OUTPUT.put_line('Total record count is ....'||cnt);
    END display_me_2;
    SQL > exec display_me_2
    Values is .....9999....Default
    Values is .....4567....Default
    Values is .....2345....Default
    Values is .....7369....Default
    Values is .....7499....Default
    Values is .....7521....Default
    Values is .....7566....Default
    Values is .....7654....Default
    Values is .....7698....Default
    Values is .....7782....Default
    Values is .....7788....Default
    Values is .....7839....Default
    Values is .....7844....Default
    Values is .....7876....Default
    Values is .....7900....Default
    Values is .....7902....Default
    Values is .....7934....Default
    Values is .....1234....Default
    Total record count is ....18

  • How to write a store procedure under SQL Server 2008

    Hi Folks,
    Kindly help me step by step how to create a simple store procedure with help of sql server 2008 r2 for Crystal report.
    I know how to work by using Universe but not SQL Server. Kindly help me how to hard code by using sql.
    Thanks in adv.
    Reddy

    For the actual syntax for programming the stored proc, you'll need to work with someone (or a website) who knows T-SQL.
    The cursor that gets returned from the stored proc must be an "in out" parameter for the stored proc.  For SQL Server I usually define a record type that includes the fields that will be returned and then return a set of records of that type.  Again, check with someone who is familiar with T-SQL for more information about how to do this.
    -Dell

  • How to call a Store Procedure with IN PARAMETER

    Hi, im new using Oracle 10G with Oracle SQL Developer, my cuestion is how to call a Store Procedure with IN PARAMETER, I tried the following without results
    SELECT * FROM procedure_name(parameter);
    PROCEDURE procedure_name(parameter);
    EXEC procedure_name(parameter);
    CALL procedure_name(parameter);
    Please help me....

    Hi,
    As Beijing said,
    EXEC procedure_name(parameter);
    CALL procedure_name(parameter);work for me.
    So does
    BEGIN
        procedure_name(parameter);
    END;Can you be more specific about what you're doing? That is, are you testing it in SQL Developer? Where are you entering the commands? Where are you looking for output? Do you get error messages? Does anything else (like "SELECT SYSDATE FROM dual;") work?

  • How to call store procedure in query generator

    Hi All,
    How to call store procedure in query generator.
    Regards
    Rajkumar Gupta
    Edited by: Rajkumar Gupta on Dec 7, 2010 2:11 AM

    Hi,
    Please check the following threads.
    How to use Stored Procedure in sap business one
    How to add parameters to a stored procedure in B1 Query generator
    How to execute the procedure in sap b1
    Hope it helps,
    Vasu Natari.

  • Help: How to open wrapped store procedure on oracle database

    Dear Gurus,
    how to open the wrapped store procedure on oracle database?
    anyone can help me...?
    reply me soon
    take care

    Any other way so that I can see the flow of data that written on wrapped store procedure?You need to see the source code which has keeped outside of database. Read a wrapped code is not common for humans...
    reply me asap If you want an asap answer, raise a SR for oracle support, not through a forum which is based on volunteers.
    Nicolas.

  • How to execute a store procedure

    Hi Forum
    I have a store procedure with 4 variables in and 1 out, how to execute via sql this procedure for obtain the result in the out variable.
    Thanks and regards

    SQL> create or replace procedure test_proc (
      2     a in number,
      3     b in number,
      4     c in number,
      5     d in number,
      6     outvar out number) is
      7  begin
      8     outvar := a + b + c + d;
      9* end;
    SQL> /
    Procedure created.
    SQL> variable var1 number;
    SQL> exec test_proc (1, 2, 3, 4, :var1);
    PL/SQL procedure successfully completed.
    SQL> print var1
          VAR1
            10
    SQL>

  • How to invoke the store procedure(Oracle) in java ?

    There is a store procedure in Oracle. the out parameter type is %ROWTYPE. how to invoke it in java ?
    create or replace procedure select_on_test(outtable out test%rowtype) is
    cursor ctest is
    select id,name from test;
    begin
    open ctest;
    fetch ctest into outtable.ID, outtable.NAME;
    end select_on_test;
    Any help will be very thankful to you.
    Thanks.

    Basically your output is a result set.
    You might want to try this thread.
    http://forums.java.sun.com/thread.jsp?forum=48&thread=89624

  • (Resolved) How to execute 2 store procedures in 1 transaction?

    public void method1(){
    Session session = getSessionFactory().acquireSession();
    StoredProcedureCall spc1 = new StoredProcedureCall();
    spc1.setProcedureName("PKG.SP1");
    spc1.addNamedArgumentValue("param", "aaa");
    session.executeNonSelectingCall(spc1);
    StoredProcedureCall spc2 = new StoredProcedureCall();
    spc2.setProcedureName("PKG.SP2");
    spc2.addNamedArgumentValue("param", "bbb");
    session.executeNonSelectingCall(spc2);
    The above method is defined in SessionFacadeBean (just like the EJB in SRDemo),
    I want the above 2 procedures executed in 1 transaction. If spc2 failed, the spc1 should not be committed. How can I do this?
    Regards,
    Jason
    Message was edited by:
    Jason.Lu

    I have changed code as follows:
    public void method1(){
    DatabaseSession session = getSessionFactory().getSharedSession();
    session.beginTransaction();
    try{
    StoredProcedureCall spc1 = new StoredProcedureCall();
    spc1.setProcedureName("PKG.SP1");
    spc1.addNamedArgumentValue("param", "aaa");
    session.executeNonSelectingCall(spc1);
    StoredProcedureCall spc2 = new StoredProcedureCall();
    spc2.setProcedureName("PKG.SP2");
    spc2.addNamedArgumentValue("param", "bbb");
    session.executeNonSelectingCall(spc2);
    } catch (Exception e) {
    session.rollbackTransaction();
    } finally {
    session.release();
    It seems that the "session.rollbackTransaction();" will be executed if spc2 fails.
    toplink logs are as follows:
    [TopLink Info]: 2007.11.12 10:20:36.690--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--default login successful
    [TopLink Finer]: 2007.11.12 10:20:36.690--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX beginTransaction, status=NO_TRANSACTION
    [TopLink Finer]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX Internally starting
    [TopLink Finer]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--external transaction has begun internally
    [TopLink Fine]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Connection(11203640)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--BEGIN PKG.SP1(param=>'aaa'); END;
    [TopLink Fine]: 2007.11.12 10:20:36.971--ServerSession(1901666)--Connection(22861541)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--BEGIN PKG.SP2(param=>'bbb'); END;
    [TopLink Warning]: 2007.11.12 10:20:37.440--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SP2'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    [TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX rollbackTransaction, status=STATUS_ACTIVE
    [TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX Internally rolling back
    [TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--external transaction has rolled back internally
    The problem is the 1st store procedure is committed (it should be rolled back!), and the database is updated.
    Thanks,
    Jason

  • How I can call Store procedure by TABLENAME.FIELD_VALUE ?

    Hello,
    I have one table called store_proc_list.
    In the table there are two fields ie ID, SP_NAME.
    In SP_NAME I have set the store procedure name.
    Now,
    What I wanted to do is .
    I am writting one store procedure and in that
    and I want to execute the another store procedure (by name), which I will get from
    SELECT sp_name FROM store_proc_list WHERE id=1
    How I can do it ?
    I tried to do it but I could not get that how we can execute stored procedure by the name which I will get from the table.field_value for the specified condition.
    sample will more helpful.
    Thanks
    Kamlesh Gujarathi
    [email protected]

    I am curious to know how does Execute immediate help in executing the stored prod dynamically...
    SQL>CREATE OR REPLACE PROCEDURE test_proc1
    2 AS
    3 BEGIN
    4 DBMS_OUTPUT.PUT_LINE('This is test_proc1');
    5 END;
    6 /
    Procedure created.
    SQL>
    SQL>CREATE OR REPLACE PROCEDURE test_proc2
    2 AS
    3 lv_proc_name VARCHAR2(30) := 'TEST_PROC1';
    4 BEGIN
    5 EXECUTE IMMEDIATE lv_proc_name;
    6 END;
    7 /
    Procedure created.
    SQL>sho err;
    No errors.
    SQL>
    SQL>exec test_proc2;
    BEGIN test_proc2; END;
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at "AIP.TEST_PROC2", line 5
    ORA-06512: at line 1
    Regards
    Arun

Maybe you are looking for

  • How many times can a iPad 3 be recharged

    How many before it dies and is there a way to find out how many so far

  • Lightroom 5.5 edit in Photoshop CC 2014 not working.

    Has anyone had problems using the edit in photoshop cc 2014 option from the Lightroom 5 drop-down menu? It won't open in photoshop for some reason... never hat problems with photoshop cc.

  • Wrong Qty Showing in Sales Analysis Report

    Dear All When we run Sales Analysis Report Item Wise by selecting Delivery Note in the selection, then it shows '0' or '-1' in Quantity field. It should show totat quantity delivered of each item. Can anyone elaborate this why it happens? Thanks and

  • XY Graph Pains

    I took this code from an example.  I hooked up my two data sources and this is what I get.  What now?  The example does NOT use dynamic data sources.  Is this the issue?  Solved! Go to Solution. Attachments: Broken LabView.JPG ‏51 KB

  • XML forms show content of HTML document

    Hi all, I want to show the content of a html document stored on portal KM in the SHOW form. Can this be done? The user can browse in the EDIT form to this html document and store its path. By using a label I can only show the document path or make a