Strange error on stored procedure after update to version 7.6.06.10

Hi,
in past version MaxDB 7.6.03 i created a stored procedure with follow SQL statement inside:
TRY
            SELECT SUM(QTDE) QTDE_SAIDA
               FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewS
               WHERE mviewS.MY_EMPRESA = :OID_EMPRESA AND
                     mviewS.MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                     mviewS.GERA_ESTOQUE = 'S' AND
                     mviewS.TIPO = 'S' AND
                     mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
                     EXISTS(SELECT * FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewE WHERE 
                        mviewE.my_Empresa = mviewS.my_Empresa AND
                        mviewE.tipo = 'E' AND
                        mviewE.data <= mviewS.data AND
                        mviewE.my_Produto = mviewS.my_Produto AND
                        mviewE.gera_Estoque = 'S' AND
                        mviewE.gera_Financeiro != 'N'
            FETCH INTO :QTDE_SAIDA;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar Saidas');
if execute that procedure with new version 7.6.06.10 i get an error:
(at 1834): Data types must be compatible.
the line of error is this:
mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
if i remove the EXISTS part that procedure works, but i need to use EXISTS there.
ps: MVIEW_MOVPRODUTOS is a table, not a view, i preceed tables with MVIEW for tables created by triggers, to simulate Materialized Views.
ps2: DATA field is DATE field on english.
any idea what can be wrong?
best regards.
Clóvis

Hi, Elke
you are right, changing SELECT * to SELECT oid works, follow the full procedure with changes:
CREATE DBPROC SP_ESTOQUE_ATUAL_DATA_PROD_DEF (
    IN OID_EMPRESA VARCHAR(8),
    IN OID_PRODUTO_DEF VARCHAR(8),
    IN DTA_ESTOQUE TIMESTAMP,
    OUT ESTOQUE_ATUAL VARCHAR(200))
AS
    VAR MAX_DATA_ESTOQUE_INICIAL TIMESTAMP;
        QTDE_ESTOQUE_INICIAL FIXED(10,3);
        QTDE_SAIDA FIXED(10,3);
        QTDE_ENTRADA FIXED(10,3);
    BEGIN
        TRY
            SELECT MAX(DATA) MAX_DATA_ESTOQUE_INICIAL
               FROM VENDOR_CONCES.ESTOQUEINICIAL
               WHERE MY_EMPRESA = :OID_EMPRESA AND
                   MY_PRODUTO = :OID_PRODUTO_DEF AND
                   DATA <= :DTA_ESTOQUE;
            FETCH INTO :MAX_DATA_ESTOQUE_INICIAL;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error em MAXDATAEINI');
        TRY
            IF MAX_DATA_ESTOQUE_INICIAL IS NULL THEN BEGIN
                SET MAX_DATA_ESTOQUE_INICIAL = '1900-01-01 00:00:00.000';
                SET QTDE_ESTOQUE_INICIAL = 0;
            END ELSE BEGIN
                SELECT QTDE QTDE_ESTOQUE_INICIAL
                   FROM VENDOR_CONCES.ESTOQUEINICIAL
                   WHERE MY_EMPRESA = :OID_EMPRESA AND
                       MY_PRODUTO = :OID_PRODUTO_DEF AND
                       DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE;
                FETCH INTO :QTDE_ESTOQUE_INICIAL;
            END;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error em Carregamento do Estoque Inicial');
        TRY
            SELECT SUM(QTDE) QTDE_SAIDA
               FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewS
               WHERE mviewS.MY_EMPRESA = :OID_EMPRESA AND
                     mviewS.MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                     mviewS.GERA_ESTOQUE = 'S' AND
                     mviewS.TIPO = 'S' AND
                     mviewS.DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE AND
                     EXISTS(SELECT oid FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS mviewE WHERE 
                        mviewE.my_Empresa = mviewS.my_Empresa AND
                        mviewE.tipo = 'E' AND
                        mviewE.data <= mviewS.data AND
                        mviewE.my_Produto = mviewS.my_Produto AND
                        mviewE.gera_Estoque = 'S' AND
                        mviewE.gera_Financeiro != 'N'
            FETCH INTO :QTDE_SAIDA;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar Saidas');
        TRY
            IF QTDE_SAIDA IS NULL THEN
                SET QTDE_SAIDA = 0;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao zerar saida');
        TRY
            SELECT SUM(QTDE) QTDE_ENTRADA
               FROM VENDOR_CONCES.MVIEW_MOVPRODUTOS
               WHERE MY_EMPRESA = :OID_EMPRESA AND
                   MY_PRODUTO_DEF = :OID_PRODUTO_DEF AND
                   GERA_ESTOQUE = 'S' AND
                   TIPO = 'E' AND
                   DATA BETWEEN :MAX_DATA_ESTOQUE_INICIAL AND :DTA_ESTOQUE;
            FETCH INTO :QTDE_ENTRADA;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao contar entradas');
        TRY
            IF QTDE_ENTRADA IS NULL THEN
                SET QTDE_ENTRADA = 0;
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error ao zera entrada');
        TRY
            SET ESTOQUE_ATUAL = CHR(QTDE_ESTOQUE_INICIAL + QTDE_ENTRADA - QTDE_SAIDA);
        CATCH
            IF $rc <> 100 THEN STOP ($rc, 'unexpected error');
    END;
about the error, I discovered the line using database studio, as I droped the old procedure and tried to recreate, database studio says that error is at BETWEEN expression, but you find the right problem with select * in exists.
best regards
Clóvis

Similar Messages

  • Exit stored procedure after UPDATE

    Hello,
    I have written a LOOP that calls a second Stored Procedure.
    In the second Stored Procedure I have 3 INSERTS each SELECT's values limited with a WHERE clause.
    Example:
    begin
    dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
    SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JAN.2012 and '03.JAN.2012' --if not condition not met, no insert
    execute immediate dynsql;
    dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JAN.2012 and '03.JAN.2012'
    execute immediate dynsql;
    dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
    SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.APR.2012 and '01.MAY.2012'  --if not condition not met, no insert
    execute immediate dynsql
    dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.APR.2012 and '01.MAY.2012'
    execute immediate dynsql;
    dynsql:=INSERT INTO destinationtable (ID,DATE,NAME)
    SELECT src.ID,src.DATE, dest.NAME FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between '01.JUN.2012 and '01.JUL.2012'  --if not condition not met, no insert
    execute immediate dynsql;
    dynsql:=UPDATE destinationtable SET DATE = dest.DATE FROM sourcetable src INNER JOIN destinationtable dest ON dest.ID=src.ID WHERE dest.date between  '01.JUN.2012 and '01.JUL.2012'
    execute immediate dynsql;
    end;
    commit;What do I do?
    I update the existing "old" row with a new date and then I am basically duplicating that row but adding it with a new DATE, the ID and NAME is "copied" as it is.
    The big problem is that the rows result in recursive updates. if the first statement updates a date it might make the conditions for the second and first update become "true".
    Which is not what I want. Initially, only one of the statements is true, ever. The problem with my code is that after the first update and date setting, another "might" become true.
    This should stop. After one of the updates occured, I need to stop the stored procedure.
    How do I stop it after upate?

    metalray wrote:
    Hello BlueShadow, that makes sense. Thanks.
    Can you tell me when sql&rowcount is reset, after an execute immediate, after a commit?It doesn't get 'reset' in the strict sense. When a PL/SQL program unit is initiated the implicit "SQL" cursor space is defined and exists in the scope of that program unit. At that point it is like any variable that is declared with it's value undefined (null). When you issue any DML statement (insert, update, delete, merge etc.), these will explicitly set the ROWCOUNT attribute within the SQL cursor space. Other SQL statements are also issued from PL/SQL through the SQL "space" (interface), and as such, they may (it's not defined anywhere) effect the values of attributes within it, including the ROWCOUNT, but we cannot say exactly in what way. Therefore, the only thing that can be definitely determined is that a) when it's first instantiated, the SQL%ROWCOUNT will be null, and also, )_immediately_ after any appropriate DML statement the SQL%ROWCOUNT will contain the number of rows effected. If the SQL%ROWCOUNT value is examined at any other point, the value is indeterminate so, for example, after a commit statement, we cannot be sure what value it has or what that value refers to.
    I loop through each tax no. need to do either an update, update or delete, delete, each with different WHERE clauses. the danger is that
    I update and then the where clause for the deletion becomes true, but my process should not do the deletion if an update happened. its a sequential check and ones true and update/deletion made, the loop stored procedure should terminate. right now I check for sql&rowcount to "not" get into a update or delete if one already happened but I fail to grasp the logic of when sql&rowcount gets which value . I have the feeling that the parent stored procedure that calls my second one with the update and deletes sets the sqlrowcount to 1 because it has an insert. (I use 11g)After your insert/update you should immediately get the value of SQL%ROWCOUNT into a variable, so that you have the value before it is effected by other statements.
    You can then use that value in your variable to determine program logic e.g. whether the delete should process or not, regardless of whether you issued further code between the insert/update and the check to see if you should delete. Don't rely on things 'resetting' the ROWCOUNT attribute, only rely on things setting it.

  • How to use the Stored Procedure to update my UDF

    I want to use the Stored Procedure to update my UDF U_InstokCS when the warehouse "OnHand" was changed. The UDF is display the stock by cases. I copied the query as follewing. I couldn't see any thing in the UDF after I made some transactions. Can anybody tell me why? How to continue it?
    if @transaction_type in ('A','U','D') and @Object_type='64'
    begin
    Update OITW
    Set U_InstokCS = OnHand/(Select T0.NumInBuy from [DBO].[OITM] T0
    Where T0.ItemCode = @list_of_cols_val_tab_del)
    Where ItemCode = @list_of_cols_val_tab_del
    end
    Thanks.
    Ying Zhang

    Ying,
    The use of any stored procedures against the SAP Business One database is not allowed per SAP Support.  There is not an instance where you can use SP's.  The ONLY SP that you are allowed to use is the SBO_SP_TransactionNotification SP that comes with SAP Business One itself. You can read about the use of this SP from this article...
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e991e2b9-0901-0010-0395-ef5268b00aaf
    Eddy

  • Stored Procedure to update Ids

    Hi,
    I want to write a stored procedure to update IDs in detail table by matching description from master table i.e.
    TabMaster
    Col1: 1 2 3 4 5 6 7 8
    Col2: A B C D E F G H
    TabDetail
    Col:
    Col2: D B C E D A A B G H C
    Please Help!
    Thanks in advance

    Now sure what you are really after, but it looks like you may only need a correlated update statement. This statement can then be put inside a stored procedure:
    UPDATE  TabDetail TD
    SET     Col = (
                    SELECT  Col1
                    FROM    TabMaster TM
                    WHERE   TD.Col2 = TM.Col2
                  )This will update ALL the rows in the TabDetail table. However if you need to restrict the rows to be updated you can always add on a WHERE clause.

  • Stored procedure to update particular key column with increment of +1

    Hi,
    This is my table
    EMPID,NAME
    1 SSS
    2 AAA
    I NEED STORED PROCEDURE TO UPDATE EMPID WITH INCREMENT OF +1.BASED ON
    MAX(EMPID).fOr example if i execute stored procedure once it will update empid 2 as 3,
    if i run same procedure again it will take increment +1 then emp id should be 4 like that i want output.
    Any one please help me on this scenario...

    937506 wrote:
    Hi All,
    I have two tables,one is date dimension table,one is fact table.
    when we load data through informatica (source as csv file),then key will be populated in fact table based on lookup on
    date dimension table.it will create corresponding date key in fact table.
    My scenario:we load data in to fact table with etl with "n" number of records only once at a time.
    But next time onwords we will update that datekey in fact table through stored procedure.stored procedure
    will take only max(date_key) from fact table then update that key as like +1(logic n+1)
    If i run stored procedure nextday it will update that record with increment +1.
    we wil schedule this storedprocedure to run daily once.For this i need stored procedure..
    I think you will clear now................
    thxSo, are you saying you want to keep the same data you loaded "yesterday" but update the date_key so it appears as if it was from today?
    Still seems strange: why aren't you loading today's data?
    Also, you are assuming that the date_key in the date dimension table increments with no gaps: if it was sequence generated, that might not be true.

  • Version 8 configure error when opening Itunes after updating to V8

    I have contacted iTunes several times with no answer to this problem.
    Everything was fine until I updated to Version 8, now every time I try and open iTunes it starts with a green bar stops about 3/4 along bar then says you need to restart to configure with Windows.
    I restart then it does the same as before yes, DEJA VU.
    This VERSION 8 is BUGGED I tell ya!
    Any solutions would be appreciated before I delete this software and use something else!
    Message was edited by: Version 8 bug
    Message was edited by: Version 8 bug

    I have a similar problem. After updating to version 8 (October 25, 2008) the itunes icon is plain and clicking it gives an error message (translated) like "This measure is only allowed for installed products".
    So I fetch the iTunes801setup.exe and try to install it again by clicking the "Repair" button. It appears to do its' thing and asks me to restart the machine. OK, but after that it's the same again: "This measure is only allowed for installed products".
    I don't want to lose all my music, can it be saved?
    I guess that I will lose it if I remove iTunes and start all over.

  • I now get an 500 Internal Server error when loading Firefox, after updating RealPlayer

    I now get an 500 Internal Server error when loading Firefox, after updating RealPlayer.
    When I try to open Firefox, it opens. But there is the error message.
    What is this? How do I did rid of it?
    '''bold text'''

    Clear the cache and the cookies from sites that cause problems.
    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites causing problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    You can also check the connection settings in Tools > Options > Advanced : Network : Connection<br />
    If you do not need to use a proxy to connect to internet then select "No Proxy"
    See "Firefox connection settings":
    * [[Firefox cannot load websites but other programs can]]

  • I have a problem my blackberry z10 after update os version 10.3.1.1779

    I have a problem After update os version 10.2 to 10.3.1.1779  in my BlackBerry z10 .I lost my whole data after phone switch off  and all setting are reset. Please anyone help me to resolve this issue. 

    Hi and Welcome to the Community!
    Here is a KB that discusses that error:Article ID: KB36747 All data is deleted following a manual restart of the BlackBerry 10 smartphone and a blue LED is displayed during boot upHopefully it contains something useful! There also are multiple existing threads on this site that discuss that exact error...your review of those might prove useful, and a search of this site, using the error message, error code, or symptom, should reveal all applicable existing threads to you. If it does not apply, then the next recommended action is for you to do an OS reload via LINK.
    Good luck and let us know!

  • HT1222 my iphone 4S no longer plays music output to speaker after updating to version 6.1.3.  I am unable to reset the phone to an earlier version!  How do I get my audio output to speaker back? (music, audible, youtube, netflix))

    my iphone 4S no longer plays music output to speaker after updating to version 6.1.3.  I am unable to reset the phone to an earlier version!  How do I get my audio output to speaker back? (music, audible, youtube, netflix)

    So you have business contacts that were lost... do you not have these on a Database in some shape or form? Sounds like you need to invest in a RAID1 backup setup for your computer so you dont have this issue in the future.
    As for repairing your problem, sounds like you are going to need to start from scratch at this point or if the data is still on your phone look into a program that can take the information from the phone onto iTunes.

  • Hello. After updating to version 7.0.2 was not on the phone face time application why?

    Hello. After updating to version 7.0.2 was not on the phone face time application why?

    If your phone was originally sold in KSA or UAE, facetime is permanently removed from it. If you are in one of those countries, and your friends have facetime on their phones, then they were originally sold in a different country.

  • FF doesn't start after update to version 27.0.1

    FF doesn't start after update to version 27.0.1
    Crash ID: bp-2bc18734-d643-4843-a10f-fd6102140214

    Firefox 27.0.1 is too new for me to know what unique issues it might have. I will message you a link to download the installer for Firefox 27.0 to see whether that reverses the problem.

  • Screen resolution changed only in the browser after update of version 9.0.1 how do I change it back

    Screen resolution changed only in the browser after update of version 9.0.1 how do I change it back?

    http://kb.mozillazine.org/Screen_resolution_changes_when_launching_application ?

  • Nano quit working after update to version 1.2

    Brand new nano quit working after update to version 1.2 It worked fine before. My computer see usb storage device but doesn't recognise ipod. ipod updater that worked to let me update doesnt regonise nano either. I returned to store where I bought it, got a new one, brought it home, ran updater again now it the new one is doing the same thing. What gives? I have never had a problem in the past with updater. Is there any way to take it back to version 1.1 since 1.2 doesn't work?

    This fix came from Caspar (Thank you SOOO much!). It took me 10 minutes to do this and now my beloved ipod nano is back! Hopefully this will help some of you:
    Original Problem: Updated iTunes(6.0.5) and iPod nano (1.2). After the update, iTunes would not recognize my iPod and therefore would not let me remove the iPod from my computer, which seems to be the problem most people are having.
    The Fix:
    *uninstall iTunes, iPod, and any updates (make sure anything related to these two programs are not on your computer)
    *Open Control Panel
    *Click the "switch to classic view" link, if
    necessary
    *Double click "administrative tools"
    *Double click "computer management"
    *Under "storage" click on "disk management"
    *Find your iPod's listing
    *Right-click on it and click "format"
    *Select "FAT32" and start the format
    *After reformatting, remove iPod from computer
    *Download iTunes directly from the Apple website (I didn't restart my computer at the prompt)
    *Download 6/28/06 update for iPod (do NOT plug iPod in before doing this!)
    *Open update for iPod and wait until prompt to plug iPod in (do not plug in early)
    *Wait for the update....and there ya have it!!
    Hopefully this will help some people, as I have spent the past 2 weeks doing the 5R's thing. After completing the steps above, I haven't had a problem with my iPod..and now my Nike+ works!! Thanks again, Caspar...you're a genius!!
    p.s. if this helps, please repost this message to others who have the same problem as we do...

  • Nothing works after updating to version 15

    After updating to version 15 nothing will load. I can't open any webpage or even connect to my router via Firefox.

    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "Continue in Safe Mode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Infragistics UltraWebListbar was working fine with the earlier version of the firfox. But it crashes after updating to version 12.

    I am using infragistics UltraWebListbar to display list of menu in one of my page.
    It was working fine with the earlier version of the firfox. But it crashes after updating to version 12.
    Following are the few details from the stack trace
    System.Convert.ToInt32(String value) +63
    Infragistics.WebUI.UltraWebListbar.UltraWebListbar.getRenderer() +237

    It's a third-party application, ask Infragistics support board. Maybe they have a fix or a dev version to fix your issue.

Maybe you are looking for

  • Win 7 Pro or Win 8 Pro on W530

    My W530 arrives in a few days.  It is pre-configured for Win 7 Pro, but comes with a Win 8 Pro installation DVD. I know Win-7 reasonably well.  I've installed Win-8 on several laptops, keeping what's good (the updated OS), adding the "start" button,

  • Error msg. PS cc 2014. The pattern is bad or corrupted.

    I installed PS cc 2014 and things seemed to work OK. Then I tried installing plug-ins.  Now I get an error msg. when I pull up PS either by itself or thru LR5.  It says The Pattern is bad or corrupted.  When I click OK everthing seems to work OK.  Wh

  • Doubt in Table Function?

    Hi, I created a Table funtion. Its working fine. After processing every record, I am piping the record. Can we pipe bulk records (for ex: 50 records) ? Is there any advantange in pefromance? Thanks in advance. Thank you, Regards, Gowtham Sen

  • Get idoc number of receiver system in a SAP-to-SAP scenario

    Hi, In a my custom program i create cremas idoc that i send to another SAP system to create the vendor in the second SAP. How can i do to get the inbound idoc number created in the receiver SAP to get and show its status in the sender SAP without to

  • Installating Oracle 9i Rel 2 on Red Hat Linux 7.3 (Intel)

    Hi, Can any one help me in this error. Error: Initializing Java Virtual Machine from /tmp/oraInsatall2003/jre/bin/java Warning: Cannot convert string "<Key>Escape,_Key_Cancel" to type VirtualBinding Warning: Cannot convert string "<Key>Home,_Key_Begi