Question

I am constantly getting the following while executing a stored proc which is called from within another stored proc .What i am using is ORA10g. ORA-06502: PL/SQL: numeric or value error

Asked by: jitendrakalyan

I am  constantly  getting the following while executing a stored proc which is called from within another stored proc .Server  is  ORA10g.

ORA-06502: PL/SQL: numeric or value error

I have checked all possbile causes for this error ... .and it not the common casuses .. ..like field lengths , data type mismatch source and destination tables   etc . . . .

To track the error i have inserted values in to a temporary table for each statement that is execurted in the procedure.

The statment executions stop at  :

EXECUTE IMMEDIATE 'TRUNCATE TABLE Tbl_XXXX';

Is there anything wrong with using execute immediate statements in a procs .....

Or any specific rules that apply to usage of this statement?

I do not know how to correlate a truncate statement with a numeric value error .

Experts please help.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-02-28 at 04:29:36ID24186460
Topics

PL / SQL

,

Databases Miscellaneous

,

Oracle 10.x

Participating Experts
3
Points
500
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ORA-06502 error while trying to insert data
    Hi, I've a PL/SQL procedure which while running is giving errors. It says ORA-06502 at the insert statement and in the beginning of the procedure st.(create or replace procedure xyz( x date, y date) and also the error ORA-06512. Need inputs asap. TIA.
  2. ora-06502
    Hi, A have a procedure that work and its status is valid but in order moment i run my aplication and appear error ora06502 . I recompile my procedure and run aplication. This error desappear and work correctly.In time, its error return to happen. Why its happen? thank´s. ...
  3. ora-06502 error
    I am geting ORA-06502 error when I execute procedure from one site. When I execute same procedure from another 2 sites I am not geting any error? I checked user-permissions, NLS settings, Oracle drivsers. Default site parameters, they are identical for all three sites. Even ...
  4. ORA-06502
    Hello Experts. I have a question. I want to execute a program and when it is processing, shows me the code error ora-06502. Please, I need your help. Give me a solution soon. Karen
  5. ORA-06502 error with Win_Api_Dialog.Save_File
    I have to write data into the ASCII file in Oracle forms, when I'm using Win_Api_Dialog.Save_File I'm getting some exceptions, which I need to resolve: 1. If I decide to use "Cancel" in "Save File As" dialog box it triggers "ORA-06502" error 2. ...
  6. Recompile Stored Procedures in Ora10g
    I was wondering if there's a way to recompile stored procedures in SQL*Plus for ora10g? We are in the process of upgrading from oracle 7.34 to 10g and the old way in SQL*Plus was EXEC DBMS_UTILITY.Compile_Schema('dbname'); This command no longer works in 10g and we have to ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: angelIIIPosted on 2009-02-28 at 06:13:25ID: 23763744

as the truncate statement itself cannot raise that error, I can only presume an audit trigger...

 

by: rrjegan17Posted on 2009-02-28 at 08:06:56ID: 23764186

You obtain that error message while executing the command

TRUNCATE TABLE Tbl_XXXX

because this table might have child records in some other table which prevents truncate on this table. Truncate all the child tables that originates from this table and try it again.

 

by: ajexpertPosted on 2009-02-28 at 10:53:33ID: 23764815

When you get this error,

Try 'TRUNCATE TABLE Tbl_XXXX' in the SQL PLUS or SQL Developer.

If there are child records, or triggers you should get error message, else you might have to investigate the real causue of error

 

by: rrjegan17Posted on 2009-02-28 at 19:15:17ID: 23766550

One More thing..

You need to have ALTER table privileges to do TRUNCATE in that table.

 

by: jitendrakalyanPosted on 2009-03-01 at 00:10:05ID: 23767347

TRUNCATE TABLE Tbl_XXXX

The table mentioned does not have any child tables .

i have tried executing all statements in SQL developer sequentially as they are executed in the procedure.

It executes properly !!!

No child records or triggers attached to this table .....absolutely no relation with other objects .

Only when these statements  are executing in the procedure there is an error.

I have executed this proc from SQL developer to ensure there is no issue with the drivers i am using in the application. The same error occurs while executing the proc from sql developer.

Angelll

Can you tell me more about audit trigger . do u mean any system triggers in action could cause this .

There are quiet a few Truncate  and insert statements that i am using on few tables in the procedure ....

Does too many truncates and inserts impact anything.



 

 

by: angelIIIPosted on 2009-03-01 at 03:15:47ID: 23767739

if it works in some tool, but not in the other, it won't be an audit trigger.
please show the relevant part of the procedure.

 

by: jitendrakalyanPosted on 2009-03-01 at 03:22:17ID: 23767763

Dear Angell ,

I dint say it works in one tool and not in another .

It works if the execute the statments individually .

 When i call the procedure it throws the error.

 

by: angelIIIPosted on 2009-03-01 at 04:07:45ID: 23767886

comes to the same result: it's not the syntax you showed, so it must be the parts "around".

 

by: jitendrakalyanPosted on 2009-03-01 at 04:14:47ID: 23767901

Find the  procedure in the following code snippet .

create or replace
PROCEDURE STPR_INDIANSTRELECTRONIC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
   AS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  iCount NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  cMaxLineNo CHAR(8);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  ILen NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  nACC NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  nTRN NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  nLPE NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  nINP NUMBER(10);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
BEGIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
   -- insert into tbl_a values('The very first');
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBALPE ';                                                    
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBAACC ';                                                    
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBAINP ';                                                    
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBABRC ';                                                    
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBATRN ';                                                    
  EXECUTE IMMEDIATE 'delete from tbl_IndianSTR_SBACTL ';  
  -- insert into tbl_a values('The very second');
  --Execute Immediate 'Trucate table tbl_a ';
 
  --insert into tbl_a values('before');
-- SBALPE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
 
--EXECUTE IMMEDIATE 'Truncate table TT_LPE_LINENUMBER ' ;    
 
  --insert into tbl_a values('after');
  
  INSERT INTO TT_LPE_LINENUMBER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  Select RecordType, DateOfReport, ROWNUM AS LineNumber,BSRCode,AccountNo,                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         annexEnclosed,NameOfLegalPerson,CustomerId,NatureofBusiness,incorporationDate,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
         ConstitutionType,RegistrationNumber,RegisteringAuth,RegisteringPlace,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         PANNo,addBuildingNo,addStreet,addLocality,addCity,addState,addPinCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         addTelNo,addFaxNo,addEmail,Comm_AddressLine1,Comm_AddressLine2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         Comm_City,Comm_State,SecondAddress5,Comm_PinCode,Comm_PhoneNo,Comm_FaxNo ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
         Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  From                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  SELECT Distinct 'LPE' AS RecordType, SYSTIMESTAMP AS DateOfReport,i.BSRCode, i.AccountNo,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
         i.annexEnclosed, i.NameOfLegalPerson, i.CustomerId,  i.NatureofBusiness, i.incorporationDate incorporationDate,                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
         i.ConstitutionType, i.RegistrationNumber, i.RegisteringAuth, i.RegisteringPlace,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
         i.PANNo, substr(i.addBuildingNo,1,40) addBuildingNo, i.addStreet, i.addLocality, i.addCity, i.addState, i.addPinCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
         i.addTelNo, i.addFaxNo, i.addEmail, i.Comm_AddressLine1, i.Comm_AddressLine2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
         i.Comm_City, i.Comm_State, i.Comm_State AS SecondAddress5, i.Comm_PinCode, i.Comm_PhoneNo, i.Comm_FaxNo ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
         'N' AS Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
         FROM tbl_IndianSTRLeglPersonDetils i                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
              INNER JOIN (SELECT Distinct * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED' ) t ON i.AlertNo = t.AlertNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  )A;   
  
  --insert into tbl_a values('first insert');
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  UPDATE TT_LPE_LINENUMBER SET incorporationDate='' WHERE TRIM(incorporationDate) IS NULL;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
/*  UPDATE TT_LPE_LINENUMBER A SET AccountNo=(Select AccountNo from tbl_AccountsMaster B Where A.CustomerId=B.CustomerID and rownum=1)                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  Where CustomerId in (Select CustomerID from tbl_AccountsMaster B Where A.CustomerId=B.CustomerID);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
*/              
 -- insert into tbl_a values('first Update');
  
  SELECT COUNT(*) INTO iCount                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         FROM TT_LPE_LINENUMBER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
         WHERE BSRCode||AccountNo NOT IN (SELECT BranchReferenceNumber||AccountNumber FROM tbl_IndianSTR_SBAACC);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  --IF iCount = 0 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
     INSERT INTO tbl_IndianSTR_SBALPE                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
             SELECT * FROM TT_LPE_LINENUMBER ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 --                  WHERE BSRCode||AccountNo NOT IN (SELECT BranchReferenceNumber||AccountNumber FROM tbl_IndianSTR_SBAACC);                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
     nLPE :=SQL%rowCount;     
  --END IF;                   
  -- insert into tbl_a values('second Update');
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-- SBAINP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  UPDATE tbl_IndianSTR_SBALPE A SET AccountNumber=(Select AccountNo from tbl_AccountsMaster B Where A.CUSTOMERIDNUMBER=B.CustomerID and rownum=1)                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  Where CUSTOMERIDNUMBER in (Select CustomerID from tbl_AccountsMaster B Where A.CUSTOMERIDNUMBER=B.CustomerID);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                    
    --insert into tbl_a values('third Update');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  --dbms_output.put_line('0');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  EXECUTE IMMEDIATE 'delete from TT_INP_LINENUMBER ';                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  INSERT INTO TT_INP_LINENUMBER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  Select RecordType,DateOfReport,ROWNUM AS LineNumber,BRANCHREFERENCENUMBER,AccountNumber,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
         relationFlag,FULLNAMEOFINDIVIDUAL,CUSTOMERIDNUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                        
         NAMEOFFATHERSPOUSE,OCCUPATION,DATEOFBIRTH, --TRUNC(i.DOB) DATEOFBIRTH,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         SEX,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         NATIONALITY,TYPEOFIDENTIFICATION, IDENTIFICATIONNUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         ISSUINGAUTHORITY, PLACEOFISSUE,                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
         PAN, COMMUNICATIONADDRESS1,  COMMUNICATIONADDRESS2,                                                                                                                                                                                                                                                                                                                                                                                                                                                        
         COMMUNICATIONADDRESS3,COMMUNICATIONADDRESS4,COMMUNICATIONADDRESS5,                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         COMMUNICATIONADDRESSPINCODE,CONTACTTELEPHONE,CONTACTMOBILENUMBER,CONTACTEMAIL,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
         PLACEOFWORK,SECONDADDRESS1,SECONDADDRESS2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
         SECONDADDRESS3,SECONDADDRESS4,SECONDADDRESS5,SECONDADDRESSPINCODE,                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         SECONDTELEPHONE,'N' GENERATED,ANNEXENCLOSED                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 From                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  SELECT Distinct 'INP' AS RecordType, SYSTIMESTAMP AS DateOfReport,i.BSRCode BRANCHREFERENCENUMBER, I.AccountNo AccountNumber,                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
         RelationFlag relationFlag, i.FullName FULLNAMEOFINDIVIDUAL, i.CustomerId CUSTOMERIDNUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
         i.FATHERNAME NAMEOFFATHERSPOUSE, i.OCCUPATION OCCUPATION,TO_CHAR(NVL(i.DOB,''),'DDMMYYYY') DATEOFBIRTH, --TRUNC(i.DOB) DATEOFBIRTH,                                                                                                                                                                                                                                                                                                                                                                                                                                                        
         i.SEX SEX,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
         i.NATIONALITY NATIONALITY, i.IDDOC TYPEOFIDENTIFICATION, i.IDNUMBER IDENTIFICATIONNUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
         i.ISSUINGAUTH ISSUINGAUTHORITY, i.PLACEOFISSUE PLACEOFISSUE,                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         i.PANNO PAN, i.ADDBUILDINGNO COMMUNICATIONADDRESS1,  i.ADDSTREET COMMUNICATIONADDRESS2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         i.ADDLOCALITY COMMUNICATIONADDRESS3,  i.ADDCITY COMMUNICATIONADDRESS4, i.ADDSTATE COMMUNICATIONADDRESS5,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
         i.ADDPINCODE COMMUNICATIONADDRESSPINCODE, i.ADDTELNO CONTACTTELEPHONE, i.ADDMOBILENO CONTACTMOBILENUMBER, i.ADDEMAIL CONTACTEMAIL,                                                                                                                                                                                                                                                                                                                                                                                                                                                         
         i.ADDEMPLOYERNAME PLACEOFWORK, i.SECADDBUILDINGNO SECONDADDRESS1, i.SECADDSTREET SECONDADDRESS2,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
         i.SECADDLOCALITY SECONDADDRESS3, i.SECADDCITY SECONDADDRESS4, i.SECADDSTATE SECONDADDRESS5, i.SECADDPINCODE SECONDADDRESSPINCODE,                                                                                                                                                                                                                                                                                                                                                                                                                                                          
         i.SECADDTELNO SECONDTELEPHONE,'N' GENERATED,i.annexEnclosed ANNEXENCLOSED                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
         FROM tbl_IndianSTRIndividualDetails i                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
              INNER JOIN (SELECT DISTINCT * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED' ) t ON i.AlertNo = t.AlertNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  )A;  
  
  
 -- insert into tbl_a values('second  insert');
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  UPDATE TT_INP_LINENUMBER SET DATEOFBIRTH=' ' WHERE TRIM(DATEOFBIRTH) IS NULL;                                                                                                                                                                                                                                                                                                                                                                                                                                     
             
  -- insert into tbl_a values('4  update');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  UPDATE TT_INP_LINENUMBER A SET AccountNumber=(Select AccountNo from tbl_AccountsMaster B Where A.CUSTOMERIDNUMBER=B.CustomerID and rownum=1)                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  Where CUSTOMERIDNUMBER in (Select CustomerID from tbl_AccountsMaster B Where A.CUSTOMERIDNUMBER=B.CustomerID);       
  
  -- insert into tbl_a values('5  update');       
  SELECT COUNT(*) INTO iCount                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         FROM TT_LPE_LINENUMBER ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  --       WHERE BSRCode||AccountNo NOT IN (SELECT BranchReferenceNumber||AccountNumber FROM tbl_IndianSTR_SBAACC);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  --IF iCount = 0 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
     INSERT INTO tbl_IndianSTR_SBAINP                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
             SELECT * FROM TT_INP_LINENUMBER ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    --               WHERE BRANCHREFERENCENUMBER||AccountNumber NOT IN (SELECT BranchReferenceNumber||AccountNumber FROM tbl_IndianSTR_SBAACC);                                                                                                                                                                                                                                                                                                                                                                                                                                                     
     nINP :=SQL%rowCount;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  --END IF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
      dbms_output.put_line('1');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-- SBABRC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  SELECT Count(*) INTO iCount                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         FROM tbl_IndianSTR_SBABRC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
         WHERE BranchReferenceNumber in (SELECT repBSRCode FROM tbl_IndianSTRManualFormDetails);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 --IF iCount = 0 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    SELECT COUNT(*) INTO iCount from tbl_IndianSTR_SBABRC;                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    INSERT INTO tbl_IndianSTR_SBABRC(RecordType, DateOfReport, LineNumber, NameOfBranch, BRANCHREFERENCENUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                 UIDISSUEDBYFIU, BRANCHADDRESS1, BRANCHADDRESS2, BRANCHADDRESS3, BRANCHADDRESS4, BRANCHADDRESS5, BRANCHPINCODE,                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                 BRANCHTELEPHONE, BRANCHFAX, BRANCHEMAIL )                                                                                                                                                                                                                                                                                                                                                                                                                                                          
         Select RecordType, ReportSendingDate,ROWNUM AS LineNumber,repBranchName,repBSRCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                 repIDFIUIND,repBuildingNo,repStreet,repLocality,repCity,repState,repPinCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                 reptelNo,repFaxNo,repEmail                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
         From                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
           SELECT Distinct 'BRC' AS RecordType, ReportSendingDate,i.repBranchName, i.repBSRCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                 i.repIDFIUIND, i.repBuildingNo, i.repStreet, i.repLocality, i.repCity, i.repState, i.repPinCode,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                 i.reptelNo, i.repFaxNo, i.repEmail                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                 FROM tbl_IndianSTRManualFormDetails i                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                      INNER JOIN (SELECT DISTINCT * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED' ) t ON i.AlertNo = t.AlertNo                                                                                                                                                                                                                                                                                                                                                                                                                                                          
         )A;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 --END IF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  dbms_output.put_line('22');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
--SBAACC            
--insert into tbl_a values('6666666'); 
 
Begin
 STPR_ACCOUNTSSUMMARY_STR();            
End;
 
--insert into tbl_a values('777777'); 
EXECUTE IMMEDIATE 'TRUNCATE TABLE TT_FINAL ';                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
EXECUTE IMMEDIATE 'TRUNCATE TABLE TT_ACC_LINENUMBER ';
 
   INSERT INTO TT_ACC_LINENUMBER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
   Select RecordType, DateOfReport, ROWNUM AS LineNumber,BranchReferenceNumber,AccountNumber,
   '-' AS NameOffirstoleaccountholder,TypeOfAccount, TypeOfAccountHolder,DateofAccountOpening,
          Case                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
             When RiskCategory = 1 Then 'A'                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
             When RiskCategory = 2 Then 'B'                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
             When RiskCategory = 3 Then 'C'                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
             When RiskCategory = 4 Then 'C'                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
              else 'A'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
          End AS  RiskCategory ,--RiskCategory ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          CumulativeCreditTurnover,CumulativeDebitTurnover,                                                                                                                                                                                                                                                                                                                                                                                                                                                         
          CumultCshDeptTrnover, CumultCshWithdlTrnover,                                                                                                                                                                                                                                                                                                                                                                                                                                                             
          Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
   From                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
   (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
   SELECT Distinct 'RAC' AS RecordType, SYSTIMESTAMP AS DateOfReport,isad.BSRCode BranchReferenceNumber, isad.AccountNo AccountNumber,                                                                                                                                                                                                                                                                                                                                                                                                                                                              
          '-' AS NameOffirstoleaccountholder, isad.AccountType TypeOfAccount, isad.ACCOUNTHOLDERTYPE TypeOfAccountHolder,
          isad.ACCOUNTOPENDATE DateofAccountOpening, am.RiskRating AS RiskCateGory,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
          ASM.CUMULCREDITTURNOVER CumulativeCreditTurnover, ASM.CUMULDEBITTURNOVER CumulativeDebitTurnover,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
          ASM.CUMULCASHDEPOSITTURNOVER CumultCshDeptTrnover, ASM.CUMULCASHWITHDRAWALTURNOVER CumultCshWithdlTrnover,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
          'N' AS Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
          FROM (Select * from tbl_IndianSTRAccountDetails Where AlertNo in                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                   (Select AlertNo from Tbl_IndianSTRs_File Where Upper(Status)='APPROVED')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
               )isad                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
          INNER JOIN tbl_AccountsMaster am ON isad.AccountNo = am.AccountNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          INNER JOIN TBL_ACCOUNTSSUMMARY_STR ASM on isad.AccountNo = ASM.AccountNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
          INNER JOIN (SELECT DISTINCT * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED') test ON isad.AlertNo = test.AlertNo                                                                                                                                                                                                                                                                                                                                                                                                                                                              
   )A;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
              insert into tbl_a values('88888');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
   INSERT INTO tbl_IndianSTR_SBAACC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
       (RECORDTYPE,DATEOFREPORT,LINENUMBER,BRANCHREFERENCENUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                   
	ACCOUNTNUMBER,NAMEOFFIRSTSOLEACCOUNTHOLDER,TYPEOFACCOUNT,                                                                                                                                                                                                                                                                                                                                                                                                                                                          
	TYPEOFACCOUNTHOLDER,DATEOFACCOUNTOPENING,                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
	RISKCATEGORY,CUMULATIVECREDITTURNOVER,CUMULATIVEDEBITTURNOVER,                                                                                                                                                                                                                                                                                                                                                                                                                                                     
	CUMULATIVECASHDEPTURNOVER,CUMULATIVECASHWITHTURNOVER,GENERATED )                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    SELECT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
		RecordType, DateOfReport, LineNumber, BranchReferenceNumber,                                                                                                                                                                                                                                                                                                                                                                                                                                                      
		AccountNumber,NameOffirstoleaccountholder, TypeOfAccount,                                                                                                                                                                                                                                                                                                                                                                                                                                                         
		TypeOfAccountHolder, DateofAccountOpening,                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
		RiskCateGory,Round(CumulativeCreditTurnover), Round(CumulativeDebitTurnover),                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
		Round(CumultCshDeptTrnover), Round(CumultCshWithdlTrnover),                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                /*Round(0), Round(0),                                                                                                                                                                                                                                                                                                                                                                                                                                                               
		Round(0), Round(0),*/ 'N' AS Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
	FROM TT_ACC_LINENUMBER ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    --           WHERE BranchReferenceNumber||AccountNumber NOT IN(SELECT BranchReferenceNumber||AccountNumber FROM tbl_IndianSTR_SBAACC) Order by LINENUMBER;                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 nACC :=SQL%rowCount;    
 
 insert into tbl_a values('999999'); 
 Update tbl_IndianSTR_SBAACC A set NAMEOFFIRSTSOLEACCOUNTHOLDER=(Select CustomerName from tbl_CustomerMaster Where CustomerID in                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
            (Select CustomerID from tbl_AccountsMaster C Where A.ACCOUNTNUMBER=C.AccountNo and rownum=1) and rownum=1)  --Changed by jitendra for IOB 27 Feb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  Where ACCOUNTNUMBER In (Select AccountNo from tbl_AccountsMaster C Where A.ACCOUNTNUMBER=C.AccountNo and rownum=1);                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  dbms_output.put_line('333');  insert into tbl_a values('12121212');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
--  SBATRN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  INSERT INTO tbl_IndianSTR_SBATRN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
        	(RECORDTYPE,LINENUMBER,BRANCHREFERENCENUMBER,                                                                                                                                                                                                                                                                                                                                                                                                                                                              
		ACCOUNTNUMBER,TRANSACTIONID,DATEOFTRANSACTION,                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
		MODEOFTRANSACTION,DEBITCREDIT,AMOUNT,                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
		CURRENCYOFTRANSACTION,DISPOSITIONOFFUNDS,                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
		REMARKS,GENERATED )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
     Select RecordType, ROWNUM AS LineNumber, BSRCODE, AccountNo, TransactionNo,TRANSACTIONTIMESTAMP,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                MODEOFTRANSACTION, DipositOrWithdrawal, Amount, CurrencyOfTransaction,DispositionFunds,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
                Remarks, Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
     From                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
     (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
         SELECT Distinct 'TRN' AS RecordType,a.BSRCODE, a.AccountNo, Replace(trn.TransactionID,' ','') AS TransactionNo, b.TRANSACTIONTIMESTAMP,--b.TransactionNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                --Substr(TransactionType,1,1) MODEOFTRANSACTION,                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                b.INSTRUMENTCODE MODEOFTRANSACTION,                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                b.DipositOrWithdrawal, b.Amount,trn.AcctCurrencyCode CurrencyOfTransaction,'X' AS DispositionFunds,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                'wert' AS Remarks, 'N' AS Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
         FROM tbl_IndianSTRAccountDetails a                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
         INNER JOIN tbl_IndianSTRAccCusTranDetail b ON a.AlertNo = b.AlertNO                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         --INNER JOIN tbl_Transactions trn ON a.TransactionNo = trn.TransactionNo
         INNER JOIN tbl_Transactions trn ON b.TransactionNo = trn.TransactionNo
         INNER JOIN (SELECT DISTINCT * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED') test ON a.AlertNo = test.AlertNo                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
     )A;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  nTRN :=SQL%rowCount;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  dbms_output.put_line('4444'); 
  insert into tbl_a values('13131313');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-- SBACTL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
   /*SELECT COUNT(*) INTO iCount                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          FROM  tbl_IndianSTR_SBACTL WHERE BSRCode IN (SELECT BSRCode FROM tbl_IndianSTRManualFormDetails);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
   IF iCount = 0 THEN */                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
      SELECT COUNT(SNoReport) INTO iCount FROM tbl_IndianSTR_SBACTL;                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
      IF iCount = 0 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
         cMaxLineNo := '00000001';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
      ELSE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
         SELECT MAX(SNoReport) into cMaxLineNo FROM tbl_IndianSTR_SBACTL;                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         cMaxLineNo := cMaxLineNo + 1;                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
         iLen := LENGTH(cMaxLineNo);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
         IF iLen = 1 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
            cMaxLineNo := '0000000' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
         ELSIF iLen = 2 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            cMaxLineNo := '000000' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         ELSIF iLen = 3 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            cMaxLineNo := '00000' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
         ELSIF iLen  = 4 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
            cMaxLineNo := '0000' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
         ELSIF iLen  = 5 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
            cMaxLineNo := '000' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
         ELSIF iLen  = 6 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
            cMaxLineNo := '00' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
         ELSIF iLen  = 7 THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
            cMaxLineNo := '0' + cMaxLineNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
         END IF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
     END iF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    INSERT INTO tbl_IndianSTR_SBACTL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
       (REPORTNAME,SNOREPORT,RECORDTYPE,DATEOFREPORT,                                                                                                                                                                                                                                                                                                                                                                                                                                                               
	COMPLETENAMEOFBANK,CATEGORYOFBANK,BSRCODE,UIDISSUEDBYFIU,                                                                                                                                                                                                                                                                                                                                                                                                                                                          
	PRINCIPALOFFICERNAME,PRINCIPALOFFICERDESIGNATION,PRINCIPALOFFICERADDRESS1,                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	PRINCIPALOFFICERADDRESS2,PRINCIPALOFFICERADDRESS3,                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
	PRINCIPALOFFICERADDRESS4,PRINCIPALOFFICERADDRESS5,                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
	PRINCIPALOFFICERPINCODE,PRINCIPALOFFICERTELEPHONE,PRINCIPALOFFICERFAX,                                                                                                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	PRINCIPALOFFICEREMAIL,REPORTTYPE,REASONFORREPLACEMENT,SNOOFORIGINALREPORT,                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	OPERATIONALMODE,DATASTRUCTUREVERSION,NOACCTLINKEDTOSUSTRAN,                                                                                                                                                                                                                                                                                                                                                                                                                                                        
	NUMBEROFTRANSACTIONS,NOOFINDIVIDUALPERSONS,NOOFLEGALPERSONENTI,                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	SUSPICIONDUETOIDENTITYOFCLIENT,SUSPDUETOBGOFCLIENT,SUSPONDUETOMULTIACCT,                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	SUSPDUETOACTINACCT,SUSPONDUETONATUREOFTRANS,SUSPONDUETOVALUEOFTRANS,                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
	GROUNDSOFSUSPICION,DETAILSOFOTHERINVESTIGATIONS,                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
	ACKNOWLEDGEMENTNUMBER,DATEOFACKNOWLEDGEMENT,GENERATED)      --cMaxLineNo                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
     SELECT Distinct 'SBA', To_Number(cMaxLineNo), 'CTL' AS ReportType, ReportSendingDate, princNameOfBank,princBankCategory,                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                    princBSRCode, princIDFIUIND, princOfficerName, princDesignation, princBuildingNo, princStreet,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                    princLocality, princCity, princState, princPinCode, princTelNo, princFax, princEmail, 'N' AS ReportType,                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                    'N' AS ReasonforReplacement, '00000000' SNOOfOriginalReport, 'P' OperationalMode, '1' AS DataStructureVerson,                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                    nACC AS NOOFACCOUNTSLINKEDTOSUSPTRANS, nTRN AS NumberofTransactions , nINP AS NOofIndividualPersons,                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                    nLPE AS NOofLegalPersonentities , 'Y' AS SUSPICIONIDENTITYOFCLIENT, 'Y' AS SUSPICIONBACKGROUND,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                    'N' AS SUSPICIONDUETOMULTIPLEACCOUNTS, 'Y' AS SUSPICIONACTIVITYINACCOUNTS,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                    'Y' AS SUSPICIONNATUREOFTRANSACTIONS, 'Y' AS SUSPICIONVALUEOFTRANSACTIONS,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                    Part7SusGrounds AS GroundsofSuspicion, 'info' AS Detailsofotherinvestigations,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                    '0000000000' AS AcknowledgementNumber, SYSTIMESTAMP AS DateofAcknowledgement, 'N' AS Generated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
             FROM tbl_IndianSTRManualFormDetails a                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                  INNER JOIN (SELECT DISTINCT * FROM Tbl_IndianSTRs_File WHERE UPPER(Status) = 'APPROVED') test ON a.AlertNo = test.AlertNo;                                                                                                                                                                                                                                                                                                                                                                                                                                                        
   --END IF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
   Execute Immediate 'Truncate Table Tbl_IndianSTRs_File';                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
EXCEPTION                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    WHEN NO_DATA_FOUND THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
      NULL;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    WHEN OTHERS THEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
      RAISE_APPLICATION_ERROR(SQLCODE, SQLERRM, TRUE);                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
END;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:

Select allOpen in new window

 

by: jitendrakalyanPosted on 2009-03-01 at 04:19:40ID: 23767910

at line no 157 in the above proc .. i am calling another proc .. .

Find in the snippet .

create or replace PROCEDURE STPR_ACCOUNTSSUMMARY_STR AS
dtFromDate varchar2(10);
dtToDate varchar2(10);
nCount int:=0;
begin
 
 
Execute Immediate 'delete from tbl_AccountsSummary_STR';
 
  Execute Immediate 'Delete from  tbl_STR_Account' ;
  
  insert into tbl_STR_Account Select Distinct AccountNo from tbl_IndianSTRAccountDetails Where AlertNo in
                   (Select AlertNo from Tbl_IndianSTRs_File Where Upper(Status)='APPROVED') ; -- Changed by jitendra for IOB 27 Feb
 
 
dtFromDate := TO_TIMESTAMP('01/'|| TO_CHAR(sysdate,'MM') || '/' || TO_CHAR(sysdate,'YYYY'), 'DD/MM/YYYY');
dtToDate   := LAST_DAY(dtFromDate);
 
INSERT into tbl_AccountsSummary_STR 
 Select AccountNo,SUM(CUMULDEBITTURNOVER) CUMULDEBITTURNOVER, SUM(CUMULCREDITTURNOVER) CUMULCREDITTURNOVER,
		   SUM(CUMULCASHDEPOSITTURNOVER) CUMULCASHDEPOSITTURNOVER, SUM(CUMULCASHWITHDRAWALTURNOVER) CUMULCASHWITHDRAWALTURNOVER,
		   MIN(STARTDATE) STARTDATE, MAX(ENDDATE) ENDDATE, SYSTIMESTAMP UPDATETIMESTAMP,'SA' SECURITYID from
(
SELECT AccountNo,
	     SUM(CASE WHEN DepositOrWithDrawal = 'W' THEN Amount ELSE 0.0 END) AS CUMULDEBITTURNOVER,
	     SUM(CASE WHEN DepositOrWithDrawal = 'D' THEN Amount ELSE 0.0 END) AS CUMULCREDITTURNOVER,
	     SUM(CASE WHEN DepositOrWithDrawal = 'D' AND SUBSTR(TRANSACTIONTYPE,1,1) = 'C' THEN Amount ELSE 0.0 END) AS CUMULCASHDEPOSITTURNOVER,
	     SUM(CASE WHEN DepositOrWithDrawal = 'W' AND SUBSTR(TRANSACTIONTYPE,1,1) = 'C' THEN Amount ELSE 0.0 END) AS CUMULCASHWITHDRAWALTURNOVER,
	     TO_TIMESTAMP(dtFromDate, 'DD/MM/YYYY') STARTDATE,
	     TO_TIMESTAMP(dtToDate,'DD/MM/YYYY') ENDDATE
		   FROM TBL_TRANSACTIONS 
      -- WHERE AccountNo in (select AccountNo from tbl_AccountsSummary_STR) AND -- Commented by jitendar for IOB 27 feb 
       WHERE AccountNo in (select AccountNo from tbl_STR_Account) AND
       TRANSACTIONDATETIME >= TO_TIMESTAMP(dtFromDate, 'DD/MM/YYYY') 
       AND TRANSACTIONDATETIME < TO_TIMESTAMP(dtToDate,'DD/MM/YYYY')+1
       GROUP BY AccountNo
      UNION ALL
      Select Accountno,CUMULDEBITTURNOVER, CUMULCREDITTURNOVER, CUMULCASHDEPOSITTURNOVER, CUMULCASHWITHDRAWALTURNOVER,STARTDATE, ENDDATE 
      from tbl_AccountsSummary where AccountNo in (select AccountNo from tbl_AccountsSummary_STR) 
      and monthofsummary = TO_CHAR(dtFromDate-1,'MM') and yearofsummary = TO_CHAR(dtFromDate-1,'YYYY')
) Group by AccountNo ;
 
 
 
End STPR_ACCOUNTSSUMMARY_STR;
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

Select allOpen in new window

 

by: angelIIIPosted on 2009-03-01 at 13:51:27ID: 23769913

>To track the error i have inserted values in to a temporary table for each statement that is execurted in the procedure.

I don't see any COMMIT (or autonomeous transaction), so ALL of your actions shall be rolled back (apart those after a truncate, which performs an implicit commit)

so, considering that, it could be any of the statements before that truncate, resp after the truncate before that truncate...

 

by: jitendrakalyanPosted on 2009-03-23 at 20:13:11ID: 31552430

Thanks!!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...