Problem: PL/SQL + Stored Procedure + Sequence + Trigger + Transaction + Violation Key

I have a violation key when i insert some datas from a stored procedure. Why ???
This is my script :
1) The script of the table :
CREATE TABLE OLLMULTI (
     IDO int NOT NULL ,
     IDL int NOT NULL ,
     T1 varchar2 (2) NOT NULL ,
     IDR int NOT NULL ,
     Constraint pk_outilsllmulti PRIMARY KEY (IDO, IDL, T1) ,
     Constraint u_outilsllmulti unique (IDR) );
2) Now, i want to manage automatic increment field on IDR :
I create a sequence :
create sequence OLLMULTI_sequence increment by 1 start with 1;
I create the trigger :
create or replace trigger OLLMULTI_trigger
before insert on OLLMULTI
for each row when (new.IDR is null)
begin
select OLLMULTI_sequence.nextval into :new.IDR from dual;
end;
3) Now i create my store procedure and, in my procedure i want to insert 6 rows :
Procedure Insert_OLLMULTI( i_IDO in OLLMULTI.IDO%type)
is
pragma AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,2,'GJ');
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,5,'ND');
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,12,'AC');
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,120,'AH');
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,10,'ZG');
INSERT INTO OLLMULTI (IDO,IDL,T1)
VALUES (i_IDO,5,'RB');
commit;
EXCEPTION
WHEN OTHERS THEN
rollback;
raise;
END;
END;
4) The problem :
The violation key on the constrainst u_outilsllmulti appears sometimes on a randome insert. Never the same !
Why ? I think that the sequence is the problem... Or is the problem is the "pragma AUTONOMOUS_TRANSACTION" command ?
Anyone can help me ?

Two ideas:
- Is it possible that there are already records in the table that were
created without using the sequence? A sequence initially starts at 1,
if you already got data you first have to increment it.
- May it be that some inserts happen without your procedure? The trigger
allows to create IDs without using the sequence. Correct, there are already records in my table !!
Thanks. That's right.

Similar Messages

  • Problem in executing Stored Procedure from Trigger

    Hi,
    Case1.
    I am executing a stored procedure form a trigger. The stored procedure is not executing fully.
    Case 2.
    But when when I execute Stored Procedure alone it is executing.
    CREATE OR REPLACE TRIGGER mhubadmin.call_proc_ratesheet_new
    after INSERT OR delete ON mhubadmin.pvt_br_ratesheet
    FOR EACH ROW
    declare
    var_orgid number;
    begin
    if inserting then
    select org_child_id into var_orgid from business_relationship where br_id=:new.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    else
    select org_child_id into var_orgid from business_relationship where br_id=:old.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    end if;
    end;
    CREATE OR REPLACE PROCEDURE proc_ratesheet_new(var_orgid in number)
    IS
    cursor c3 is select distinct(purs.user_id) from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid;
    cursor c1(varUser_id number) is select purs.user_id,purs.ratesheet_id from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid and purs.USER_ID=varUser_id;
    cursor c2(varUser_id number) is select hu.user_id,pbr.ratesheet_id from HUBUSER hu
                             inner join BUSINESS_RELATIONSHIP br on hu.ORG_ID=br.ORG_CHILD_ID
                             inner join PVT_BR_RATESHEET pbr on br.BR_ID=pbr.BR_ID
                                  where hu.user_id in(select distinct(purs.USER_ID) from hubuser hu
                                       inner join PVT_USER_RATESHEET purs
                                                                     on hu.USER_ID=purs.USER_ID
                                                 where hu.ORG_ID=var_orgid) and hu.user_id=varUser_id;
    foundFlag boolean;
    incrFound integer;
    insertFound integer;
    deleteFound integer;
    str varchar2(4000);
    BEGIN
         incrFound:=0;
         insertFound:=0;
         for c3var in c3 loop
    for c2var in c2(c3var.user_id) loop
              insert into test values ('Step3:'||c2var.user_id);
              foundFlag:=false;
              for c1var in c1(c3var.user_id) loop
                   if c2var.ratesheet_id=c1var.ratesheet_id then
                        foundFlag:=true;
                             incrFound:=incrFound+1;
                             exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --insert into pvt_user_ratesheet (username_ratesheet_id,user_id,ratesheet_id) values (SEQ_USER_RATESHEET.nextval,c3var.user_id,c2var.ratesheet_id);
                   dbms_output.put_line('Inserted for user :'||c3var.user_id||' is - ratesheet :'||c2var.ratesheet_id);
                   insertFound:=insertFound+1;
                   end if;
              end loop;
    end loop;
         commit;
         incrFound:=0;
         deleteFound:=0;
         for c3var in c3 loop
              for c1var in c1(c3var.user_id) loop
              foundFlag:=false;
              for c2var in c2(c3var.user_id) loop
                        if c1var.ratesheet_id=c2var.ratesheet_id then
                        foundFlag:=true;
                        incrFound:=incrFound+1;
                        exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --delete from pvt_user_ratesheet where user_id=c3var.user_id and ratesheet_id=c1var.ratesheet_id;
                        --dbms_output.put_line('Deleted for userid:'||c3var.user_id||' for ratesheet :'||c1var.ratesheet_id);
                        deleteFound:=deleteFound+1;
                   end if;
              end loop;
    end loop;
         commit;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line (SQLCODE||' '|| SQLERRM);
    END;
    Regards,
    Mathew

    In general, I would suggest that you only catch errors that you can handle reasonably. If you know that a SELECT INTO might return 0 rows for example, handle the NO_DATA_FOUND exception. Having a WHEN OTHERS, particularly without re-raising the exception, only serves to hide the source of the problem. I would much rather that my code fail quickly and explicitly than hope that I see an error message in the output and that other code doesn't start failing because the system wasn't left in an appropriate state.
    As Mark suggests, you may choose to implement a comprehensive logging framework using autonomous transactions, in which case a WHEN OTHERS would be reasonable, but you would still want to propagate exceptions you cannot handle.
    If you see a WHEN OTHERS clause and there is no RAISE, you probably have an error waiting to happen.
    Justin

  • MS SQL Stored Procedure problem

    Hi,
    I am using BO XI R2, Crystal Report XI and MS SQL Database.
    I found a strange error when generating the report using my java application if the crystal report is using MS SQL stored procedure. The error encountered :
    com.crystaldecisions.sdk.occa.managedreports.ras.internal.a: Cannot open report document. --- Custom table prefix specified in the InfoStore does not exist.  This is a configuration problem. Please contact your system administrator.
    cause:com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Custom table prefix specified in the InfoStore does not exist.  This is a configuration problem. Please contact your system administrator.---- Error code:-2147467259 Error code name:failed
    detail:Cannot open report document. --- Custom table prefix specified in the InfoStore does not exist.  This is a configuration problem. Please contact your system administrator.
    This is when the code executed is:
       reportClientDocument = reportAppFactory.openDocument(report, 0, Locale.ENGLISH);
    If the report does not use the stored procedure, it's ok.
    If i run the report  (with stored procedure) from CMC using the default table prefix (in database config tab), it's able to generate the report.
    If i select custom table prefix and specify the custom table prefix value with the same value as in the default table prefix, it could not generate the report and error stated that the table could not be found.
    Please enlighten me if you have use MS SQL database for reporting with BO XI R2.
    Thanks.

    That means it's not a SDK-specific error. 
    Once it's resolved in InfoView, it'll likely be resolved with your app.
    You might want to open a support case with SAP. 
    Sincerely,
    Ted Ueda

  • Migrating Transact SQL Stored Procedure & Funtions  to Oracle 9i Procedures

    Is it possible to Migrate Transact SQL Stored Procedure & Funtions in MS-SQL to Oracle 9i Procedures & Funtion . I am an Bigginer in Oracle and SQL.Is their any tool available for this?

    This feature is currently available in the Oracle Migration Workbench. with the Microsoft SQL Server plugins.
    Have you tried it?
    Regards,
    Niall

  • Calling SQL stored procedure dynamically

    Hallo,
    could anybody tell me how to call HANA SQL stored procedure dynamically?
    The coding looks like this:
    v_ProcedureName := '"' || KpiNamespace || '::' || KpiName || '"';
    v_SQL := 'CALL ' || :v_ProcedureName || '( lt_outKPI )';
    EXEC :v_SQL;
    For this call I get the error message:
    "Transaction rolled back by an internal error: wrong number or types of parameters in call: Physical table is not allowed in OUT table variable position: LT_OUTKPI: line 1 col 55 (at pos 54)"
    The procedure to be called dynamically has a table output parameter.
    Thanks in advance,
    Best Regards,
    Alexey Romanov.
    Hi Alex,
    Can you share your requirement on exactly what is the need to call the procedure dynamically?
    For your question, have a look on the below:
    1) Have a procedure named EMPLOYEE_DETAILS
    http://scn.sap.com/servlet/JiveServlet/downloadImage/2-14895702-415799/236-170/pastedImage_0.png
    2) Created one more procedure named Dynamically as shown below:
    CREATE PROCEDURE Dynamically ()
    AS
    BEGIN
    DECLARE QUERY VARCHAR(1000);
    QUERY := 'call  EMPLOYEE_DETIALS(?)';
    EXECUTE IMMEDIATE (:QUERY);
    END;
    3) Output:
    http://scn.sap.com/servlet/JiveServlet/downloadImage/2-14895702-415800/210-189/pastedImage_3.png
    Regards,
    Krishna Tangudu
    Hi Krishna,
    Thanks for your reply!
    Unfortunately, I can neither go to ‘full discussion’, nor open the pictures, you have attached, nor see you reply.
    That’s why I just add my reply to the problem description.
    The procedure name is composed out of 2 parts on-the-fly, that is why I have to call it dynamically:
    create local temporary table "#KPIEvals"(           
              "KpiNamespace" NVARCHAR(256) CS_STRING,           
              "KpiName" NVARCHAR(32) CS_STRING,               
              "KpiText" NVARCHAR(256) CS_STRING,           
              "Responsible" NVARCHAR(256) CS_STRING );
    FOR cur_row as c_cursor DO        
         v_SQL := '';     
         v_ProcedureName :=  '"' || cur_row."KpiNamespace" || '::' || cur_row."KpiName" || '"';     
         v_SQL := 'CALL ' || :v_ProcedureName || '( lt_outKPI )';     
         EXEC :v_SQL;                
         v_SQL := 'INSERT INTO "#KPIEvals" SELECT * FROM :lt_out_kpi';     
         EXEC :v_SQL;                
    END FOR;
    I guess there might be 2 reasons for the problem:
    1.     All the procedures are called dynamically in a loop.
    2.     All the procedures have an output parameter, which is a table.
    Hope that helps,
    Best Regards,
    Alex.

    Hi Alexey, I think what you may need to do in this case is to do the insert into your temp table from within the dynamically called procedure, therefore no need for output param in your procedure call. You can then select from the temp table in your main procedure. Hope that makes sense.
    Peter

  • Pass date range parameter  to SQL stored procedure.

    Hi,
    I'd like to pass a date range parameter from Crystal Reports to a sql stored procedure. Does anyone know if this is possible?
    I've had no problem passing standard datetime (single value) paramaters to and from but am struggling with getting a range value parameter to work.
    Environment: Crystal Reports 10/XI and SQL 2000 MSDE version or SQL 2005 Express Edition.
    Any help would be appreciated.

    C5112736 wrote:>
    > And then these 2 formulas 'Formula # 1' and 'Formula # 2' can be used to pass on to the stored procedure.
    Can someone please demonstrate exactly how to use formula results as date parameters to a SQL stored procedure?  Keep in mind, there are two parameters to the stored procedure.
    I have gleaned this much: Use Add Command and insert the procedure with
    EXEC ServerName.dbo.usp_sprocName;1 '{?StringParameter}'
    but if I try to do
    {CALL ServerName.dbo.usp_SprocName({@Formula1},{@Formula2})}
    then it gives the error "No value given for one or more required parameters". 
    Both of the parameters are VARCHAR(50).
    I have finally found this link: [http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx|http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx]
    This Microsoft site defines the format of the ODBC escape sequences, but I still do not know how to convince Crystal to insert it's parameter results or formula results.
    Pulling what's left of my hair out . . .
    ~ Shaun

  • Big PL/SQL stored procedure optimization.

    Hi There,
    Can any one let me the basic steps for optimization or tuning of a PL/SQL stored procedure for better performance.
    DB: 11.2.0
    OS: Solaris 10
    looking forward.
    Regards,

    >
    Can any one let me the basic steps for optimization or tuning of a PL/SQL stored procedure for better performance.
    >
    Seriously - how do you expect anyone to give you any specific things to do when you don't provide any specific information about your procedure?
    A procedured is comprised of one or more steps. So to tune it you need to determine which steps are 'slow' and make them 'fast'! ;)
    There are several common causes of performance problems with PL/SQL are:
    1. Using PL/SQL when SQL should have been used. Don't use PL/SQL to begin with - always use SQL unless it just can't do the job required. The 'PL' in PL/SQL means 'Procedural Language' and should be used for transactional (multi-step) processing or when 'procedural' operations are needed that aren't available in SQL.
    2. Using slow-by-slow (row by row) processing instead of BULK processing.
    3. Using multiple nested LOOPs when a more complex query could have allowed a single loop to be used.
    4. Using COMMITs more frequently than required. Search this forum and you will find far too many questions about how to do a COMMIT after 10,000 rows (or some other number). A COMMIT should be performed AFTER a transaction has been completed, not during the middle of it. Frequent commits generally use more resources, degrade performance and risk the famous 'snapshot too old' message.
    The very first step of performance 'tuning' is to first verify that any 'tuning' is even required. Too many people suffer from CTD - compulsive tuning disorder.
    The second step is to identify what step, or steps, of the process are performing below par.
    Which means the best developers are proactive - they plan ahead.
    1. Create an explain plan BEFORE the code goes to production. Once the code has been tested and believed to perform properly an execution plan should be created and SAVED for future reference. That saved plan can then be used later, when you suspect a performance issue, to detect changes that might have affected performance: create a new plan and compare it to the baseline.
    2. Create explains for ALL key queries. As suggested by step #1 performance is all about comparison: performance 'now' COMPARED TO performance 'then'. If the don't know the performance 'then' it can be difficult to know if the performance has changed. If a query has a 'now' execution time of 2 minutes is that 'fast' or 'slow'? Well - compared to WHAT? You can't know 'fast' or 'slow' if you don't know 'then' and 'now'. How fast was it yesterday, last week or last month?
    3. Instrument your procedural code. That means measure, for EACH STEP, how long it took to execute and how much data it worked with. That information needs to be logged. Your logging and data collection can be static (it ALWAYS happens) or dynamic. Oracle's own code is HEAVILY instrumented. Some operations and activity are always logged and available in the data dicitionary views or various performance reports such as AWR.
    Other operations, such as the extended trace facility, only collect data on request.
    IMHO your first step should be to begin the 'proactive' steps above.

  • Why doesn't SSRS like an IF Statement in my SQL Stored Procedure???

    I have multiple IF Statements at the end of my SQL Stored Procedure Process that utilizes a @ReportTypeName Parameter to produce the chosen report result set
    IF @ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
    BEGIN
    SELECT DISTINCT
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
    CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
    FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
    FROM [#TempTable_Distinct_Individual_Member_All_Info]
    WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans])
    ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    END
    IF @ReportTypeName = 'HMO-POS Renewals'
    BEGIN
    SELECT DISTINCT
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
    CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
    FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
    FROM [#TempTable_Distinct_Individual_Member_All_Info]
    INNER JOIN [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]
    ON [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR] = [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    END
    Microsoft Visual Studio and SQL Server Reporting Services did not like this! When I added my dataset and parameters accordingly, my Dataset had no fields...almost as if running the Stored Procedure in the background to get its Metadata was not working. I
    know this works because I tested it as a result of a straight EXEC Command. Why doesn't Microsoft Visual Studio and SQL Server Reporting Services not like this IF? I did end up getting around this by parameterizing the WHERE clause based on the @ReportTypeName
    chosen.
    WHERE (@ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
    AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
    OR (@ReportTypeName = 'HMO-POS Renewals'
    AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
    I appreciate your review and am hopeful for a reply.
    Thanks!

    Hi ITBobbyP,
    I have tested on my local environment and can reproduce the issue, the issue can be caused by the temp table you are using which will also cause the data not display.
    I have use below sample table and record to have a test and details information below for your reference:
    Right click the DataSet to select the "DataSet Properties" and click the query designer to execute the stored procedure by click the "!" to check if you can get the data:
    If you got some error, the issue can be cause by the temp table invalid, so please make sure you have add the query to create and insert  recored to temp table like below:
    CREATE PROCEDURE vickytest0311_1
    @ReportTypeName nvarchar(50)
    AS
    create table #VickyTest
    column1 int,
    column2 varchar(20)
    insert into #VickyTest values (1,'Test1')
    insert into #VickyTest values (2,'Test2')
    insert into #VickyTest values (3,'Test3')
    IF @ReportTypeName ='Test1'
    BEGIN
    select * from #VickyTest
    where Column1=1
    END
    IF @ReportTypeName ='Test2'
    BEGIN
    select * from #VickyTest
    where Column1=2
    END
    GO
    3. I recommend you to not use the temp table and you will not need to add the create and insert statement in the stored procedure.
    4. If you still got no data, please try to click the "Refresh fields" as below:
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • PL/SQL Stored procedures vs C# code.

    Hi All
    We are going to start designing a kind of transactional application with huge volume of data (150 million records per month). Our selected DB engine is Oracle 10.g while C# is selected development language.
    Because of big volume of data performance is one of the most important factors for us, and the technical design should gain the best level of performance.
    What i'm looking for and studing for it is to define which kind of operation shall be done by Stored Procedure which will be written by PL/SQL or by C# classes?
    I don't interested in to handle complicated and complex jobs using PL/SQL stored procedures while the performance really deserve it.

    Hello,
    Well, my philosophy is to leverage the database as much as possible. I have worked with applications that had no "select", "insert", "update" or "delete" statements in them. Instead, stored procedures and functions inside of PL/SQL packages and bodies were used. Some people will argue strongly against that, but I belong to the "thick database" group rather than the "the database is just a persistence layer that I have to deal with" group. To me it makes sense to co-locate the code that works on the data with the data. If you are working with large volumes of data, I find the bulk operations available via PL/SQL to be very handy.
    Here's an AskTom thread that deals with this general issue:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:12083187196917
    Whilst the thread is primarily about Java, you can substitute just about any other language and the meaning will still carry over.
    Regards,
    Mark

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • How to call pl/sql stored procedure in JDBC query dialogbox

    Hi,
    how to call pl/sql stored procedure in JDBC query dialogbox(reports 9i) .
    Cheers,
    Raghu

    please refer : Re: problem If you have more doubts, please ask in that question.

  • STORED PROCEDURE & DATABASE TRIGGER

    제품 : FORMS
    작성날짜 : 1995-11-07
    * STORED PROCEDURE
    1. Oracle Forms 4.5에서는 PL/SQL Code를 Server-Side에 저장하거나 Forms 내 Trigger, Procedure로 갖을 수도 있다.
    다음과 같은 경우 Procedure를 Database Server에 저장하는 방법을 선택하는
    것이 좋다.
    - Procedure가 Standard한 기능을 제공하여 다른 Tool이 공유할 수 있을 때.
    - Procedure가 중요한 DML 기능을 가질 경우.
    - Oracle Forms 4.5에서는 PL/SQL의 Version을 1.1까지 지원하므로, PL/SQL
    Version 2.X 의 기능이 필요한 경우.
    2. Stored Procedure의 제한사항
    (1) Server가 7.0 이상이어야 한다.
    (2) Pass되는 Variable은 2000 Byte이하이어야 한다.
    - 2000이 넘으면 Truncate가 되고, PL/SQL에서 Value_Error Exception이
    발생한다.
    (3) Menu PL/SQL에서는 Stored Procedure와 Function을 부를 수 없다.
    (4) Stored Subprogram의 정의가 바뀐 경우, Forms를 다시 Server와 Connect
    하기 전에는 영향을 주지 않는다.
    3. Oracle 7 Server 에서 제공하는 Standard Package들
    - dbms_alert
    - dbms_ddl
    - dbms_describe
    - dbms_lock
    - dbms_mail
    - dbms_output
    - dbms_pipe
    - dbms_session
    - dbms_snapshot
    - dbms_standard
    - dbms_transaction
    - dbms_utility
    < Oracle7 Developers Guide 참조>
    4. Calling Stored Procedures
    (1) Database Procedure는 Server-Side PL/SQL Engine에 의해 실행되도록
    Design된 PL/SQL Block이다.
    (2) Stored Procedure를 Call하기 위해서는 EXECUTE Privilege가 필요하다.
    (3) Server-Side Procedure와 Forms에서의 PL/SQL의 중요한 차이점은
    Server-Side 에서는 Forms의 Bind Variable (:Block_Name.Item_Name 등)
    을 인식하지 못한다는 것이다.
    (4) Parameter/Return이 가능한 Data Type
    - VARCHAR2 : Maximum of Varchar2(2000)
    - NUMBER
    - DATE
    - BOOLEAN
    제한사항
    - TABLE%ROWTYPE, TABLE.COLUMN%ROWTYPE으로 정의된 것은 Reference가
    안된다.
    - Unsupported Parameter나 Return Value를 사용하면 다음의 Error가
    발생한다.
    * PL/SQL error 313 at line xxx, column yyy 'PROCNAME'
    not declared in this scope.
    * PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    (5) Formal Parameter의 Default Value
    - Defulat Value는 제공하지 않는다.
    - User가 임의로 줄 수 있다.
    - Procedure Private_Test(a in VARCHAR2 := 'Hello' b in
    VARCHAR2 := 'There') IS
    BEGIN
    Dbms_Output.Put_Line(a);
    Dbms_Output.Put_Line(b);
    END;
    (6) 다른 User의 Stored Subprogram이나 Remote Database를 Call하려면
    - User Name이나 Database Link명을 숨기기 위하여 Synonym을 생성하여야
    한다.
    - CREATE SYNONYM lib_hr_syn FOR libowner.lib_hr;
    - Program에서 Call할 때에는 ss_num ;= lib_hr_syn.get_ssn(:EMP.EMPNO);
    5. PL/SQL Compiler가 해당 Procedure를 찾는 순서
    (1) Current PL/SQL Block 내에 정의되어 있는가?
    (2) Standard PL/SQL Command인가?
    (3) Oracle Forms 내의 Built-in Procedure 혹은 Function인가?
    (4) User_Named Procedure 혹은 Function인가?
    (5) Server-side에 정의된 DBMS_STANDARD Package인가?
    (6) Current user가 Server-Side의 어떤 Procedure나 Function을 Access
    하는가?
    * 이상의 질문에 대하여 전부 'NO'라는 대답이 나오면 Compiler는 다음과 같은
    Error Message를 준다.
    - PL/SQL error 313 at line xxx, column yyy 'PROCNAME' not declared in
    this scope.
    - PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    * DATABASE TRIGGER
    1. Database Trigger는 Forms에서의 Trigger와 개념적으로 거의 동일하다.
    차이점은 Trigger가 Fire되는 원인을 제공하는 사건과 후속코드가 실행되는
    장소가 틀린 것이다.
    2. Database Trigger는 Table과 연관된 PL/SQL Block들이다. Table에 대한
    UPDATE, INSERT, DELETE 등의 행위에 의해 Fire된다.
    3. Error 발생 시에는 RAISE_APPLICATION_ERROR Built-In Procedure를 사용하
    여 Error를 표시한다.
    RAISE_APPLICATION_ERROR Procedure에서는 Error Number가 20000 - 20999의
    Range를 가진다.
    4. Creating & Editing Database Triggers
    아래와 같은 적절한 권한이 주어진다면 Forms Designer Mode에서 Database
    Trigger를 직접 Create, Edit, Compile, Browse 할 수 있다.
    - Execute Privilege, Create Privilege, Compile Privilege,
    Drop Privilege
    * Create하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - Triggers Nodes를 선택하고 Menu Bar의 Navigator*Create를 선택한다.
    - Database Trigger Editor에서 작성, compile한다.
    * Edit 하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - 원하는 Trigger에서 Double-Click하면 Editor가 나타난다.
    - Database Trigger Editor에서 변경, compile한다.

    not possible via forms
    you can debug it on SQL Developer by using manual INSERT Updates commands

  • Hi i am using oracle 10g how to view the content of the stored procedure or trigger ?

    Hi i am using oracle 10g .How to edit  the content of the stored procedure or trigger ?

    jklopkjl wrote:
    Hi i am using oracle 10g .How to view the content of the stored procedure or trigger ?
    query ALL_SOURCE
    SQL> desc all_source
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    NAME                                               VARCHAR2(30)
    TYPE                                               VARCHAR2(12)
    LINE                                               NUMBER
    TEXT                                               VARCHAR2(4000)

  • Can't create valid PL/SQL stored procedure

    I have two questions about PL/SQL and JDBC:
    Question 1: I'm trying to create and execute a PL/SQL stored procedure, and I can't seem to get the syntax right. I'm trying to create the simplest stored proc I can. Here's the stored procedure:
    create or replace procedure test( inParam char(20) ) is
    begin
    select inParam from dual;
    end;
    When I try to execute it, I'm getting the error:
    PLS-00905: object TEST is invalid
    The creation of the proc, and the execution are being done using the same login.
    Question2: Once I get the stored procedure created, I want to call it from a JDBC application. Is this the correct syntax:
              CallableStatement stmt = connection.prepareCall("begin test('abc'); end;");
    or can I use the standard JDBC escape sequence:
              CallableStatement stmt = connection.prepareCall("{ call test('abc'); }");
    Thanks for your help,
    Jeff

    Forgot to mention, I'm using TimesTen 11.2.1.4.

  • Bulk insert using stored procedure or trigger

    Hi ,
    I have to insert around 40,000 rows in a table querying other database using database link.
    Please advice whether I do using stored procedure or trigger.
    Thanks.

    Here is a basic benchmark that illustrates the difference between maximising SQL, or doing it in PL/SQL instead.
    Care needs to be taken with such a benchmark in order for physical I/O not to negatively impact a test, and then have no impact in the second test as that data read from disk now sits in the cache.
    So I ran it a couple of times in order to "warm up" the cache. I also put the maximise-SQL test first in order to show that it is still faster, despite any physical I/O it may do (which will likely be faster logical I/O with the second test).
    Run on Oracle XE 10.2.0.1.
    SQL> drop table my_objects_copy purge;
    Table dropped.
    SQL> create table my_objects_copy as select * from all_objects;
    Table created.
    SQL>
    SQL> set timing on
    SQL> begin
    2 delete from my_objects_copy;
    3
    4 insert into my_objects_copy
    5 select * from all_objects;
    6
    7 commit;
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.11
    SQL> set timing off
    SQL>
    SQL> drop table my_objects_copy purge;
    Table dropped.
    SQL> create table my_objects_copy as select * from all_objects;
    Table created.
    SQL>
    SQL> set timing on
    SQL> declare
    2 cursor c is select * from all_objects;
    3 objRow ALL_OBJECTS%ROWTYPE;
    4 begin
    5 delete from my_objects_copy;
    6
    7 open c;
    8 loop
    9 fetch c into objRow;
    10 exit when c%NOTFOUND;
    11
    12 insert into my_objects_copy
    13 values objRow;
    14
    15 end loop;
    16 commit;
    17 end;
    18 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.21
    SQL>
    The cursor-fetch-loop is almost 3 times slower. The more rows there are to process, the slower the cursor-fetch-loop will become, as it will create more and more context switching and copying data between the SQL and PL engines and back.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for