Store Procedure required to check Quantity total

Dear Experts,
Kindly help me in writing Store Procedure, my requirement is to have an validation on Inventory Transfer Form where i have created two udf fields in row level as A & B contains where user enter value which is calculated as A * B  that is equal to  total Quantity,  for ex. (A * B = Quantity).
So i need here a validation check before adding this document, that Field A value multiply by Field  B value that should to be total Quantity in case changes made in field A or Field B but not update before saving this document it would result be wrong Quantity total.
To avoid such user entering mistakes a SP is required to check whether the Quantity total is equal to Field A value * Field B value.
Thanking in Advance....
Regards,
Krishnakumar

Hi!  Gordon,
Already there is an FMS to Calculate Field A value * Field B value and it through it's result to the Field Quantity. Now am looking to have an validation check or control that should actually check before document get saved that the value entered in Field value A multiply by Field value B  is that get tallied with the Field Quantity.
For ex: Field A value contain figure 100 and Field  B value contain figure 200 then the Field A * Field B = Quantity i.e. (100 * 200 = 20,000). In case if the user change the field Value of A or B without updating the Field Quantity then it result in correct Quantity.
So I need a Store Procedure that check the field value of A & B and check the product sum Field value Quantity if it matches then it should allow to save the document other wise it should print a Error message "Calculation Error".
I hope you understand what am exactly required, so i need  your helping hands to get this Store Procedure.
Thanks in Advance,
Regards,
Krishna
Edited by: krishnaoctopus on Jun 14, 2011 2:49 PM

Similar Messages

  • Exec XP_CMDSHELL cannot find store procedure problem

    I run EXEC sp_configure 'xp_cmdshell', 1
    Message is"....change from 1 to 1 "
    Then
    EXECXP_CMDSHELL 'Dir N:'
    cannot find store procedure xp_cmdshell
    I check master database.
    No dbo.xp_cmdshell under store procedure.
    How to fix it? I need run command
    EXECXP_CMDSHELL 'Dir N:'
    Thanks

    Hallo Bestrongself,
    - what SQL Server version do you use?
    - since SQL 2005 xp_cmdshell is located in the sys-schema and the procedure itself is located in the resource database of Microsoft SQL Server.
    You can check xp_cmdshell by using the following command:
    SELECT * FROM sys.all_objects WHERE name = 'XP_CMDSHELL'
    I bet you will see it in the master database because you cannot drop system procedures and will return an error if you try to do so:
    USE master;
    GO
    BEGIN TRANSACTION
    DROP PROCEDURE dbo.xp_cmdshell;
    DROP PROCEDURE sys.xp_cmdshell;
    DROP PROCEDURE xp_cmdshell;
    ROLLBACK TRANSACTION
    To execute xp_cmdshell you need to have [CONTROL SERVER] permissions otherwise it won't work. Let's say I have a login which I grant exclusive permissions to execute xp_cmdshell it will fail!
    USE master;
    GO
    -- create the login and the user in master-database
    CREATE LOGIN test WITH PASSWORD = 'glmdpf12345', CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF;
    CREATE USER test FROM LOGIN [Test];
    GO
    -- grant explicit permission to execute the xp_cmdshell
    GRANT EXECUTE ON sys.xp_cmdshell TO test;
    GO
    -- tryp to execute xp_cmdshell as test
    EXECUTE AS login = 'test'
    EXEC xp_cmdshell 'DIR C:';
    REVERT
    -- Housekeeping
    REVOKE EXECUTE ON sys.xp_cmdshell TO test;
    DROP USER 'test';
    DROP LOGIN 'test';
    As you can see from the above statement the login "Test" got exclusive permission to execute xp_cmdshell but the execution will fail with the following error message:
    The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information.
    The above error message is clear. Test is a "normal" user which has the permission to execute the proc BUT due to missing permissions to retrieve the information about the service account it fails!
    You have to grant SERVER CONTROL to the account.
    So - next step...
    What is your permission on server level?
    You can check your permissions by using the following statement:
    -- what are my permissions on server level
    -- check for CONTROL SERVER!
    SELECT * FROM sys.fn_my_permissions (NULL, 'SERVER') ORDER BY permission_name;
    -- what are my permissions for the object xp_cmdshell
    SELECT * FROM sys.fn_my_permissions('xp_cmdshell', 'OBJECT');
    Can you provide us with the results of the above query?
    BTW: xp_cmdshell is a well documented statement and official command which is fully supported by Microsoft. You can find all information about functionality and security of xp_cmdshell here:
    http://technet.microsoft.com/en-us/library/ms175046.aspx
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

  • Store procedure call to fetch data in JDBC sender adapter

    Hi guys,
    I have to fetch data from a Oracle server through JDBC adpater.
    the partner has in place some store procedure that have to be used with this purpose.
    But al the time I try to call a store procedure I got error that variables are not binded.
    I fill up the query sql statement field with following text
    call <store procedure name> (v1 OUT VARCHAR2, v2 in varchar2)
    Does anyone know the syntax to access such store procedure within jdbc adapter?
    As far as I know the jdbc call the store procedure with Callable statement but the paremeters need to be linked to datatype,but here I do not see such possibility.

    HI
    A stored procedure is a subroutine available to applications accessing a relational database system. Stored procedures (sometimes called a sproc or SP) are actually stored in the database data dictionary.
    Typical uses for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures are used to consolidate and centralize logic that was originally implemented in applications. Large or complex processing that might require the execution of several SQL statements is moved into stored procedures and all applications call the procedures only.
    Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement
    Stored procedures can return result sets, i.e. the results of a SELECT statement. Such result sets can be processed using cursors by other stored procedures by associating a result set locator, or by applications. Stored procedures may also contain declared variables for processing data and cursors that allow it to loop through multiple rows in a table. The standard Structured Query Language provides IF, WHILE, LOOP, REPEAT, CASE statements, and more. Stored procedures can receive variables, return results or modify variables and return them, depending on how and where the variable is declared.
    http://help.sap.com/saphelp_nw04/helpdata/en/1d/756b3c0d592c7fe10000000a11405a/content.htm
    One of the usage is to prevent the query to directly write to the database
    http://en.wikipedia.org/wiki/Stored_procedure
    Check these:
    http://help.sap.com/saphelp_nw04s/helpdata/en/b0/676b3c255b1475e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/4d/8c103e05df2e4b95cbcc68fed61705/frameset.htm
    Integration with Databases made easy – Part 1.
    JDBC Stored Procedures
    http://help.sap.com/saphelp_nw04/helpdata/en/45/023c41325fa831e10000000a1550b0/frameset.htm
    Calling stored procs in MaxDb using SAP Xi
    cheers

  • UNABLE TO EXECUTE THE CMDSQL SCRIPT IN A STORE PROCEDURE.

    I am trying to call a .sql file from sql cmd mode.
    The requirement is to pass the .sql file as parameter value to the cmd script which I have able to achieve,here is the code which is working fine .
    declare @x sysname
    set @x = 'C:\Users\testuser\Desktop\testing.sql'
    :OUT $(TEMP)\GetServerName1.sql
    PRINT ':SETVAR FilePath'+ ' ' + @x
    GO
    :OUT stdout
    :r $(TEMP)\GetServerName1.sql
    GO
    :r $(FilePath)
    But when I try to wrap this code in store procedure it is giving the message fatal error but when I run it without wrapping it in store proc it is doing its job with no error . When I looked into the store proc I found the code as
    ALTER proc [dbo].[testing]
    as
    declare @x sysname
    set @x = 'C:\Users\testuser\Desktop\testing.sql'
    PRINT ':SETVAR FilePath'+ ' ' + @x
    It seems like the sqlcmd code disappears automatically. I have no clue why it is happening. 
    Can anyone help in letting me knw how to wrap the above code in store proc.
    Thanks Saurav 

    It is important to keep in mind that you have two entities in play here. One client and one server. The lines that start with a colon never sent to SQL Server, nor are the lines which reads "go". They are intercepted client-side. For instance :r
    instructs SSMS to read a local file and out: redirects the output. And "go" breaks up the code in batches.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Select all values from Rule in Store Procedure

    Hi
    I have a rule like this
    CREATE RULE [dbo].[Rle_Currency_Lst]
    AS
    @List IN
    ('PKR','USD')
    GO
    Now i want to make simple "Currency List" report for which i need to select values from above rule in Store Procedure which i will use in SSRS to fill my report.
    Please help
    Zubair Afridi | Please mark as answered or vote helpful if this post help resolved your issue. Thanks!

    One way to get the values.
    declare @definition nvarchar(max);
    select @definition = m.definition
    from sys.objects o
    inner join sys.sql_modules m on o.object_id = m.object_id
    where schema_name(o.schema_id) = 'dbo' and o.name = 'Rle_Currency_Lst';
    set @definition = SUBSTRING(@definition, CHARINDEX('''', @definition), LEN(@definition));
    set @definition = LEFT(@definition, CHARINDEX(')', @definition) - 1);
    declare @myXML AS XML;
    set @myXML = N'<H><r>' + REPLACE(SUBSTRING(@definition, CHARINDEX('''', @definition), LEN(@definition)), ',', '</r><r>') + '</r></H>'
    declare @result table(myvalues nvarchar(100));
    insert @result(myvalues)
    SELECT Vals.id.value('.', 'NVARCHAR(100)') AS val
    FROM @myXML.nodes('/H/r') AS Vals(id)
    update @result set myvalues = REPLACE(myvalues, '''', '');
    select * from @result;
    Note that rules is a deprecated feature and will be removed in a future version of SQL Server.  The replacement for rules is CHECK CONSTRAINTS.  You may well want to consider a plan to migrate your current rules to check constraints.
    Tom

  • Error when run crystal report with store procedure in JSP

    I try to run report which is developed by crystal report XI and store procedure (SQL 2005) with JSP.
    But it occurs error that is "com.crystaldecisions.reports.reportengineinterface.JPEReportSource - failed to process getPage request: No results were returned by the query."
    How can I do for solving this problem? Pls, help me !!!!!
    (In other report which is not used store procedure I can run fine.)
    Message was edited by:
    Bonds_Identity

    What version of CR are you using?
    What CR updates are you using?
    See sample apps here:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    in particular check out vbnet_win_pass_dataset_main_sub.zip
    The [Crystal Reports for Visual Studio 2005 Walkthroughs|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23] will also be good to look at.
    Ludek
    Follow us on Twitter
    http://twitter.com/SAPCRNetSup

  • Oracle JBDC error while calling the store procedure

    HI All,
    I am get one strange error while calling a store procedure which has two parameter in and out.
    I am pass the correct XML file which reaches the RDB and then PI receives a exception error message saying:
    oracle.rdb.jdbc.common.RdbException: Closed Resultset
    where as no error log is availble in RBD for the same.
    Can anybody tell me what can be the cause of the error.
    Let me know if you requires more information on this.
    -adi

    Hi Kiran,
    Thanks..
    But I am not able to understand you. I am calling a store procedure not a table. and we not doing anything in the store procedure except return one constant value in Out parameter.
    -Adi

  • Store procedure for sale order

    hi
    i want store procedure that we can't add stand alone sale order without sale quatation

    hi,
    you can check my post in this link
    Re: Storeprocedure for sale order without sale quotation
    regards
    Fidel

  • Quantity Total Stock is incorrect in the report

    0TOTALSTCK (Quantity Total Stock) is a non-cumulative key figure in the standard cube 0IC_C03 (Material Movements). The user is running a report for September month (01.09.2008 to 30.09.2008). At the end of the month i.e., 30.09.2008 the total stock is 0 in R/3, But in the BW reoprt it is showing as -19,000 which is incorrect.
    How can I check how the that value is calculated in the report? I can't see that key figure in the Infocube content preselection screen. In the definition of key figure,  it is calculated throgh Inflow and Outflow and mentioned arregation as Summation and Exception aggregation as Last Value. Is it correct? It should be linked with 0CALDAY for checking the stock day by day. How does it know?
    Any setting has to be done in the Report in order to get the correct values for the total stock qty?
    Please reply asap.

    Shiva,
    Inventory is calculated as a non cumulated KF which is aggregated based on stock receipts and stock outflows based on an opening stock marker. Think of this as something like a bank passbook where only debits and credits are entered and accordingly the balance is calculated. The Brought Forward line on your passbook is similar to the marker where once a page is completed the last available balance is updated.....
    only things which are not to be done in MM are :
    1. Compression without marker update - this corrupts the MM stock values.
    Also make sure you update the marker properly. The only solution to your case would be to do a full recon between the cube / R/3 and accordingly re-init / update the marker etc.
    Arun

  • Calling ORACLE Store Procedure with parameters in user define function

    Hi everybody,
    We have a scenario connecting Oracle DB thru JDBC adapter.
    We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
    Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
    I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
    I am looking for an example.
    Thanks in advance,
    Gigi

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • 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

  • Which is better to use Store Procedure or Views in Crystal Reports ?

    Hi,
    which one is more better to use Store Procedure or Views in Crystal Reports ?
    Thanks.

    It depeneds on the requirement. Well, but from performance point of view as u know that stored procedures are already compiled on DB side, they would be more efficient. Views are handled differently. Here CR has nothing to do with it.
    But if the stored procedure u r using is having 2 Select statements, CR will only display the results from the first select statement. In that case you need to use Views as one can use more than one views in the report and join them.
    Using a Generic view which is created by the DBA for a larger audience will result in performance issues meaning if a View "V" has 25 fields and View is based on 5 tables  and ur report is using only 5 fields which are coming only from 2 tables inside the view,in this case u will end up in joining 3 more tables unnecessarily.
    Hope this helps!

  • How to load and define Java Store Procedures using Consolidator Manager??

    Hi,
    I am trying to create a store procedure with a very easy example and I can not succeed. i am a bit new with OLite and I will appreciate any help from your side. I am quite lost now regarding of using java with OLite and it is becoming quite urgent for me. Thanks a lot in advanced.
    Those are the steps that I follow:
    - Creating the java class
    I create the java file MYUPPER.java with next code :
    public class MYUPPER {
    public static String doUpper( String p_text )
    return p_text.toUpperCase();
    I compile it and I create the jar file:
    C:\>javac MYUPPER.java
    C:\>jar cf MYUPPER.jar MYUPPER.class
    - This is an abstract of my java code using the API:
    ( m_cm is ConsolidatorManager)
    // Create the java resource
    m_cm.createStoredProc( "MYUPPER.jar", "MYUPPER", "doUpper", "doUpper");
    // Add it to the publication
    m_cm.addJavaResource( "PMTS", "MYUPPER" );
    - After running that code I do not receive any exception and checking into the repository looks ok:
    a) From the Mobile Server I can see the Java Ressource MYUPPER for that publication
    b) I can see the entries in C$Resouces and in C$Pub_Objects as well
    *** ON THE CLIENT:
    Then I go to the client device a Windows XP labtop where I did install the jre 5.0 and I added the bin path to the system variable PATH.
    - I get a POL-8000 error when synchronizing (could not start the Java Visrtual Machine)
    - Anyway, I can see the MYUPPER.class file deployed in the same directory than the databases are.
    - I have also tried next from msql:
    c:\>msql system/manager@jdbc:polite:tomeu_conscli
    Oracle Lite MSQL Version 10.3.0.2.0
    Copyright (c) 1997, 2008, Oracle. All rights reserved.
    Connected to: Oracle Lite ORDBMS
    Database Name: CONSCLI (Read Write)
    Database Version: 10.3.0.2.0
    Auto Commit: off
    Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
    SQL> select * from c$resources;
    PUB_NAME | DB_NAME | RESOURCE_NAME | RESOURCE_TYPE | RESOURCE_DATA
    PMTS | pmts | MYUPPER | JAVA CLASS | -¦¦¥ 1
    1 row(s) returned
    SQL>
    SQL> exit
    Disconnected from CONSCLI
    c:\>msql system/*****@jdbc:polite:tomeu_pmts
    Oracle Lite MSQL Version 10.3.0.2.0
    Copyright (c) 1997, 2008, Oracle. All rights reserved.
    Connected to: Oracle Lite ORDBMS
    Database Name: PMTS (Read Write)
    Database Version: 10.3.0.2.0
    Auto Commit: off
    Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
    SQL> select doUpper('fhjdjf') from dual;
    [POL-8035] no such attribute or method
    SQL> create table sp (id number(1) primary key );
    Table created
    SQL> alter table sp attach java source "MYUPPER" in '.';
    [POL-8028] error in calling a Java method
    SQL> commit;
    Commit complete
    SQL> select sp.doUpper('fhjdjf') from dual;
    [POL-8035] no such attribute or method
    Lost... :(
    Tomeu

    sorry to bother, similar like above, i tried many times on my computer to load a simple image in java application.. here's my code:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class View extends JFrame {
         private URL imageURL;
         private File file;
         private Image sourceImage;
         private String name, title, message;
         private int width, height;
        public static void main(String[] args) {
            System.out.println( "Hello Eros!!!" );
            View img = new View();
        public View() {
             name = "D:/shared/inputpic.gif";
             file = new File( name );
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            try {
                imageURL = new URL("http://www.google.com.my/images/logo_sm.gif" );
            } catch (MalformedURLException e) {
            if ( file == null ) {
                sourceImage = Toolkit.getDefaultToolkit().getImage( name );
                System.out.println( file );
            } else {
                sourceImage = toolkit.getImage( imageURL );
                System.out.println( file );
            width = sourceImage.getWidth( this );
            height = sourceImage.getHeight( this );
            System.out.println( "Pixel = " + width + "x" + height );
            if ( width * height == 1 ) {
                title = "Greetings";  // Shown in title bar of dialog box.
                if ( file == null ) {
                    message = "Unable to load the file " + name;
                } else {
                    message = "Unable to load the link " + imageURL;
                JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
    }could anyone test this n give my the reason i couldnt even load the image

  • 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

  • For loop to iterate through temp table in store procedure in pl/sql

    Hi,
    how to create For loop to iterate through the temporary table in the store procedure?

    Neha RK wrote:
    hi,
    its not working , i need to check each record of table and do some task using if else loop inside that for..
    if not possible to loop each row of table using for then how to use while loop.
    please helpWhat's not working? We haven't got psychic powers so we can't see the code you say isn't working.
    Please provide more information like create table statements, insert statements with test data, the code you've tried
    and the output you are expecting from the input data.
    Read {message:id=9360002} and follow the advice there.

Maybe you are looking for

  • My post installation script

    #I hope its the right forum to post that in, if not im very sorry! This here is a script i wrote to automate all the stuff i do after installing arch, i have several computers and it has options for a additional one Some important points: 1) this scr

  • Email Posts are generating duplicate entries in ShaerPoint Discussion Forum.

    If i send one email post name it as "Test Post" then on SharePoint site i can see multiple posts with the same name. when i open all the duplicate posts in new window its displaying with some random number at the end of the subject. Multiple Post wit

  • HELP - Missing Info For Dual USB iBook Display Repair

    I've read and re-read most all of the discussions regarding the blank and/or dimmed display and pretty much determined that my problem is also due to a pinched wire in the hinge. The display is normal until I open it further than about 45 degrees, th

  • "Media Cache Files" is a huge folder - is it necessary data or temporary data that I could delete?

    My folder "Media Cache Files" (found in: profiles > appdata > roaming > adobe > common > media cache files) is currently over 200 GB big and I was wondering whether all of this data is necessary for my projects (or for anything else?) or whether it i

  • READ RFC to managed system could not be found

    I am trying to run the managed system configuration in Solution Manager for NetWeaver CE (Java) system. The step "Configure Diagnostics" fails with 1 error and 2 warnings: [SSO] SSO setup OK [Roles] At least one support role assignment did not succed