Tuning pl/sql block

Hi All
I have two tables
1.purchase
2.sold
i have written pl/sql code to restart the fifo-first in first out match where i found a mistake in the existing data.here operator has enterd a wrong data.i.e.,it can be rate or quantity in any of the two tables.so can this code be tuned and reduce the number of cursors.
purchase table
SNO P_SCODE DOP PQTY RATE VALUEQTY SOLD
1 ATL 01-SEP-04 100 15.75 1575
2 BPL 02-SEP-04 800 20.00 16000
3 ATL 04-SEP-04 500 17.00 8500
4 ATL 06-SEP-04 750 20.00 15000
5 BPL 07-SEP-04 250 15.00 3750
6 ATL 07-SEP-04 100 15.00 1500
7 ATL 08-SEP-04 250 16.00 4000
8 BPL 09-SEP-04 300 17.00 5100
SOLD TABLE
SNO S_SCODE DOS S_QTY RATE VALUE COSTPROFIT
1 ATL 02-SEP-04 50 16.00 800
2 ATL 06-SEP-04 500 15.00 7500
3 ATL 08-SEP-04 300 20.00 6000
4 BPL 07-SEP-04 300 25.00 7500
5 ATL 10-SEP-04 100 15.00 1500
6 ATL 08-SEP-04 250 16.00 4000
7 BPL 10-SEP-04 1000 18.00 18000
8 ATL 11-SEP-04 400 20.00 8000
CREATE OR REPLACE PROCEDURE my_shares
( new_code IN VARCHAR2,
type IN VARCHAR2,
sno IN NUMBER,
new_qty IN NUMBER,
new_rate IN NUMBER)
IS
ls_qty NUMBER:=0;
ls_rate NUMBER:=0;
lcost_price NUMBER:=0;
lp_qty NUMBER:=0;
lqty_sold NUMBER:=0;
lp_rate NUMBER:=0;
lprofit NUMBER:=0;
lvalue NUMBER:=0;
sum_pur NUMBER:=0;
sum_sale NUMBER:=0;
error_row NUMBER:=0;
before_qty NUMBER:=0;
s_error NUMBER:=0;
p_error NUMBER:=0;
temp NUMBER:=0;
before_cp NUMBER:=0;
new_svalue NUMBER:=0;
old_rate NUMBER:=0;
cannot_sell EXCEPTION;
wrong_code EXCEPTION;
/*FETCHES SALES RECORD FROM THE EFFECTED SALE ROW*/
CURSOR sales IS
SELECT * FROM s_shares WHERE s_no>=s_error AND s_code=new_code ORDER BY s_date;
s1 sales%ROWTYPE;
/*FETCHES PURCHASE RECORD FROM THE EFFECTED PURCHASE ROW*/
CURSOR purchase IS
SELECT * FROM p_shares
WHERE p_code=s1.s_code AND p_qty-qty_sold> 0 AND p_no>=p_error ORDER BY p_date;
p1 purchase%ROWTYPE;
/*FETCHES ALL RECORDS ORDER BY SHARECODE*/
CURSOR sales_rec IS
SELECT * FROM s_shares WHERE s_code = new_code ORDER BY s_code, s_date;
s2 sales%ROWTYPE;
/*FETCHES PURCHASE RECORDS OF SAME SHARECODE FETCHED BY SALES_REC*/
CURSOR purchase_rec IS
SELECT * FROM p_shares WHERE p_code = new_code ORDER BY p_code, p_date;
p2 purchase%ROWTYPE;
BEGIN
/* IF ERRORTABLE IS SALE THEN THIS LOOP EXECUTES*/
IF
type='S' THEN
/*GIVES SUM OF SALE QTY BEFORE ERROR ROW*/
SELECT SUM(s_qty) INTO sum_sale FROM s_shares WHERE s_no < sno AND s_code = new_code;
UPDATE s_shares SET cost_price = 0,profit=0 WHERE s_no >= sno AND s_code = new_code;
OPEN purchase_rec;
LOOP
FETCH purchase_rec INTO p2;
EXIT WHEN purchase_rec%NOTFOUND;
sum_pur := sum_pur + p2.p_qty; /*SUM OF PUR RECORDS BEFORE ERROR ROW*/
before_qty := sum_pur-sum_sale;
IF
before_qty < 0
THEN
error_row := p2.p_no+1; /*EFFECTED PURCHASE ROW FOR SALE UPDATE*/
lqty_sold := sum_sale - sum_pur;/*MATCHED SOLD QTY*/
ELSE
UPDATE p_shares SET qty_sold=0 WHERE p_no=p2.p_no;
END IF;
END LOOP;
CLOSE purchase_rec;
new_svalue:=new_qty*new_rate;
UPDATE s_shares SET s_qty=new_qty , s_rate=new_rate ,s_value=new_svalue WHERE s_no=sno;
UPDATE p_shares SET qty_sold=lqty_sold WHERE p_no=error_row;
s_error := sno; /*LIMIT FOR CURSOR SALES*/
p_error := error_row; /*LIMIT FOR CURSOR PURCHASE*/
/* IF ERRORTABLE IS PURCHASE THEN THIS LOOP EXECUTES*/
ELSIF
type='P' THEN
/*SUM OF PURCHASE QTY OF ALL ROWS ABOVE ERROR ROW*/
SELECT SUM(p_qty) INTO sum_pur FROM p_shares WHERE p_no < sno AND p_code = new_code;
UPDATE p_shares SET qty_sold = 0 WHERE p_no >= sno AND P_code = new_code;
UPDATE p_shares SET p_value = new_qty*new_rate WHERE p_no = sno;
SELECT p_rate INTO old_rate FROM p_shares WHERE p_no=sno;
OPEN sales_rec;
LOOP
FETCH sales_rec INTO S2;
sum_sale := sum_sale + s2.s_qty;
before_qty := sum_sale - sum_pur; /*BEFORE SALE QTY*/
error_row := s2.s_no; /*EFFECTED SALE ROW FOR PURCHASE UPDATE*/
EXIT WHEN before_qty > 0 ; /*EXITS FROM LOOP WHEN EFFECTED ROW FOUND*/
END LOOP;
before_cp:=s2.cost_price - (before_qty*old_rate);
CLOSE sales_rec;
UPDATE s_shares SET cost_price = 0,profit=0 WHERE s_no > sno AND s_code=new_code;
UPDATE s_shares SET cost_price = before_cp WHERE s_no=error_row;
UPDATE p_shares SET p_qty=new_qty,p_rate=new_rate WHERE p_no=sno;
p_error := sno; /*LIMIT FOR CURSOR PURCHASE*/
s_error := error_row; /*LIMIT FOR CURSOR SALES*/
temp:=1;
ELSE RAISE wrong_code;
END IF;
OPEN sales;
LOOP
FETCH sales INTO s1;
EXIT WHEN sales%NOTFOUND;
IF
temp = 0 THEN ls_qty:=s1.s_qty;
ELSE
ls_qty:=before_qty;
END IF;
ls_rate:=s1.s_rate;
lvalue:=s1.s_value;
lcost_price:=s1.cost_price;
OPEN purchase;
LOOP
FETCH purchase INTO p1;
IF
purchase%NOTFOUND THEN
RAISE cannot_sell;
ELSE
lp_qty:=p1.p_qty;
lp_rate:=p1.p_rate;
lqty_sold:=p1.qty_sold;
IF
ls_qty > (lp_qty-lqty_sold) THEN
lcost_price:=lcost_price+(lp_qty-lqty_sold)*lp_rate;
lprofit:=lvalue-lcost_price;
UPDATE p_shares SET qty_sold=lp_qty WHERE p_no=p1.p_no AND p_code=p1.p_code;
UPDATE s_shares SET cost_price=lcost_price,profit=lprofit WHERE s_no=s1.s_no AND s_code=s1.s_code;
ls_qty:=ls_qty-(lp_qty-lqty_sold);
ELSE
lqty_sold:=lqty_sold+ls_qty;
lcost_price:=lcost_price + (ls_qty*lp_rate);
lprofit:=lvalue-lcost_price;
UPDATE p_shares SET qty_sold=lqty_sold WHERE p_no=p1.p_no AND p_code=p1.p_code;
UPDATE s_shares SET cost_price=lcost_price ,profit=lprofit WHERE s_no=s1.s_no AND s_code=s1.s_code;
ls_qty:=0;
temp:=0;
END IF;
IF
ls_qty=0
THEN
CLOSE purchase;
EXIT;
END IF;
END IF;
END LOOP;
END LOOP;
CLOSE sales;
EXCEPTION
WHEN cannot_sell THEN RAISE_APPLICATION_ERROR(-20001,'CANNOT SELL SHARE FOR NOT PURCHASED');
WHEN wrong_code THEN RAISE_APPLICATION_ERROR(-20002,'ENTER P OR S');
END;
Thanks in Advance
Sasidhar.
Regards
Sasidhar

Hi;
What is your Db and EBS version ,also please mention OS
If you search as RELEVANT OBJECT: SQL statement with SQL_ID in metalink there are 8 doc avaliable, but i belive its better to move your post on:
Forum Home » Database » SQL and PL/SQL
Regard
Helios

Similar Messages

  • Tune the PL/SQL block with SQL_ID

    Hi There,
    I have found some recommendation in ADDM report as follows.
    "" Action
    Tune the PL/SQL block with SQL_ID "48trcns4mx5bk". Refer to the "Tuning
    PL/SQL Applications" chapter of Oracle's "PL/SQL User's Guide and
    Reference".
    Related Object ""
    can any one let me how to Tune the PL/SQL block with SQL_ID?
    looking forward.
    Db: 11.1.0.7
    OS: OracleLinux5-86*64
    Regards,
    Mohsin

    Hi,
    you can't tune a PL/SQL block directly. Instead, you'll need to profile it first (i.e. see how much time SQL statements inside it consume) using dbms_profiler or some other tool. If you find that the problem is that some SQL is called too frequently because of flawed PL/SQL logic, then you'll need to address that. Otherwise, you'll need to take the top time consuming statement(s) and tune it (them).
    Best regards,
    Nikolay

  • Select from Function PIPELINED on PL/SQL Block

    Hi folks,
    I have a PL/SQL Block and I need this block to show me in a grid the rows from a variable table (Type table) that I have declared.
    I don´t want to create Database objects, that's why I haven´t created tableTest like a type object in the database.
    Example:
    Declare
    type tableTest is table of varchar2(500);
    function test(indName IN VARCHAR2) return tableTest PIPELINED as
    begin
    pipe row (indName);
    pipe row ('teste2');
    return
    end;
    begin
    -- HERE I NEED SHOW ROWS RETURNED BY FUNCTION WAS DECLARED;
    -- Select * from TABLE(test('NAME'));
    end;

    You declare a pipelined table function by specifying the PIPELINED keyword. Pipelined functions can be defined at the schema level with CREATE FUNCTION or in a package. The PIPELINED keyword indicates that the function returns rows iteratively. The return type of the pipelined table function must be a supported collection type, such as a nested table or a varray. This collection type can be declared at the schema level or inside a package. Inside the function, you return individual elements of the collection type. The elements of the collection type must be supported SQL datatypes, such as NUMBER and VARCHAR2. PL/SQL datatypes, such as PLS_INTEGER and BOOLEAN, are not supported as collection elements in a pipelined function.
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm

  • Display an Alert message in PL/SQL block in APEX

    Hi,
    we are getting an oracle exception while inserting a new row. As it is having the unique constaint on a coulumn.
    Now the problem iis we need to Display an "Alert message" based on the input field validation. That java script code for alert has to be embeded nside a PL/SQL block in Oracle APEX Application.
    we tried doing this with below code:
    Begin
    INSERT INTO <<table name>>(ID,NAME) VALUES (s1,:TXT_s2);
    exception when others then
    htp.p('<script language="javascript">');
    htp.p('alert("Exception");');
    htp.p('</script>');
    end;
    If anybody knows .... please reply.
    Thanks,
    Subarna
    Edited by: user9955252 on Apr 21, 2010 1:47 AM

    Hello,
    APEX Forum is here : Oracle Application Express (APEX)
    Regards

  • Display an Alert message from PL/SQL block in APEX

    Hi,
    we are getting an oracle exception while inserting a new row. As it is having the unique constaint on a coulumn.
    Now the problem iis we need to Display an "Alert message" based on the input field validation. That java script code for alert has to be embeded nside a PL/SQL block in Oracle APEX Application.
    we tried doing this with below code:
    Begin
    INSERT INTO <<table name>>(ID,NAME) VALUES (s1,:TXT_s2);
    exception when others then
    htp.p('<script language="javascript">');
    htp.p('alert("Exception");');
    htp.p('</script>');
    end;
    If anybody knows .... please reply.
    Thanks,
    Subarna

    If your end goal is showing a pretty error message instead of the message that the tables unique constraint raises try the following. This logic will show a nice message and not try to insert non-unique data.
    (1) Create a validation of type "Function Returning Error Text".
    (2) Place similar code like the following in your validation. Notice that if the unique name does not exist the no_data_found returns null allowing the validation to pass.
    DECLARE
      v_error varchar2(100);
    BEGIN
      SELECT 'A person by this name already exists.'
      INTO v_error
      FROM your_table
      WHERE your_name = :P1_YOUR_NAME;
      RETURN v_error;
    EXCEPTION
      WHEN no_data_found THEN
        RETURN NULL;
    END;

  • Performance: Operations in Cursor vs. Operations in PL/SQL block

    Why does I have a better performance when I program operations in complex cursors instead of programming the same statement in a pl/sql block in a stored procedure?
    Operation in a Cursor:
    CURSOR c IS
      DECODE(name,'Peter','dog','cat') animal
      ...The same Operation in a PL/SQL block:
    begin
      if name = 'Peter'
      then
          animal = 'dog';
      else
          animal = 'cat';
      end if;
    end;
    ...I know that a parsed cursor is placed in the Shared Pool and reference
    a context area in the PGA.
    Does anybody have an idea?
    Message was edited by:
    mad

    Maybe because if you can write only a SQL query, it is faster than to write PL/SQL code that will do the same job. See following thread for a analog discussion: Re: pl/sql table

  • How to test for différent Select into a single PL/SQL block ?

    Hi,
    I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
    Or, I would like to test for different selects.
    In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
    There are different possibilities : 4 possibilities :
    - USERID Existing or not Existing and
    - Aplication ID found or not found for this particular USERID.
    I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
    The problem is that if one select returns no row, I go to the exception data not found.
    In the example below you see that if no row returned, go to the exception
    DECLARE
    P_USERID VARCHAR2(400) DEFAULT NULL;
    P_APPLICATION_ID NUMBER DEFAULT NULL;
    P_REGISTERED VARCHAR2(400) DEFAULT NULL;
    BEGIN
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
    :P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
    END;I would like to do first this statement :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID Then to do this one if the user is found :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
    I basically don't want to go to the not found exception before having tested the 4 possibilities.
    Do you have a suggestion ?
    Thank you for your kind help !
    Christian

    Surely there are only 3 conditions to check?
    1. The user exists and has that app
    2. The user exists and doesn't have that app
    3. The user doesn't exist
    You could do this in one sql statement like:
    with mimic_data_table as (select 1 userid, 1 appid from dual union all
                              select 1 userid, 2 appid from dual union all
                              select 2 userid, 1 appid from dual),
    -- end of mimicking your table
             params_table as (select :p_userid userid, :p_appid appid from dual)
    select pt.userid,
           pt.appid,
           decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
                           when dt.userid = pt.userid then 2
                           else 3
                      end), 1, 'User and app exist',
                            2, 'User exists but not for this app',
                            3, 'User doesn''t exist') user_app_check
    from   mimic_data_table dt,
           params_table pt
    where  pt.userid = dt.userid (+)
    group by pt.userid, pt.appid;
    :p_userid = 1
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             1          2 User and app exist   
    :p_userid = 1
    :p_appid = 3
        USERID      APPID USER_APP_CHECK                 
             1          3 User exists but not for this app
    :p_userid = 3
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             3          2 User doesn't exist  

  • How to use the WHENEVER SQLERROR EXIT statement in a PL/SQL block.

    Hi,
    I am getting the following error when trying to add the following statement in an PL/SQL block.
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    [exec] ERROR at line 23:
    [exec] ORA-06550: line 23, column 12:
    [exec] PLS-00103: Encountered the symbol "SQLERROR" when expecting one of the
    [exec] following:
    [exec] := . ( @ % ;
    How can i use the above statement in the PL/SQL Block? I have only IF statement in that block( between BEGIN and END).
    Thanks

    Hi,
    Usually there's always more than one solution.
    Can you post an example of what you're trying to accomplish?
    That would be useful.
    (Place the tag before and after your example to maintain formatting en spacing, see the [fac|http://forums.oracle.com/forums/help.jspa] regarding available tags)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • No Data Found: Exception in SQL inside PL/SQL block

    Hi Friends
    I am trying to execute an SQL SELECT stmt inside a PL/SQL block. But when i execute the procedure, it gives me No Data Found Exception.
    I know it is because no row is fetched in the query, but the condition of the SELECT query i have specified is being satisfied, i have checked it by running it on the SQL prompt.
    But somehow, it is not running from inside the PL/SQL procedure.Can anybody help me out on this as to why is this happening?? I am giving my code for reference and have Highlighted the Query inside it:
    CREATE OR REPLACE procedure insert_sfdc_account
    as
    --DECLARE
    CURSOR C1 IS
    SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
    address, city, postal_code, country_key, zzcust_type, vat_code
    FROM load_cust_general
    WHERE account_group = 'ZSIT';
    v_cust_cur c1%ROWTYPE;
    -- type sales_tab is table of load_cust_sales_area%rowtype;
    v_sales_area load_cust_sales_area%ROWTYPE;
    -- v_sales_area sales_tab;
         v_salesorg varchar2(10);
         v_sales_district varchar2(10);
         v_salesoff varchar2(10);
         v_custgrp varchar2(10);
         v_salesgrp varchar2(10);
    v_type varchar2(20);
    v_nature varchar2(10);
    v_partner_code varchar2(10);
    v_parent_cust varchar2(20);
    v_credit_blk varchar2(20);
    BEGIN
    open c1;
    loop
    fetch c1 into v_cust_cur;
    exit when c1%NOTFOUND;
    for i in (SELECT customer_code, salesorg from load_cust_partner
    where customer_code = v_cust_cur.customer_code ) LOOP
    dbms_output.put_line(v_cust_cur.customer_code );
                        SELECT partner_code into v_partner_code from load_cust_partner
    where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
    dbms_output.put_line(v_partner_code||i.customer_code);
    SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
              WHERE customer_code = i.customer_code and salesorg = i.salesorg;
                   dbms_output.put_line(v_salesorg||i.salesorg);
                        SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
    WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G'; dbms_output.put_line(v_parent_cust);
                        SELECT credit_block INTO v_credit_blk from load_cust_company_cod
              WHERE customer_code = i.customer_code;
    dbms_output.put_line(v_credit_blk);
    for j in (SELECT account_group, customer_type from load_cust_general
    where customer_code IN (select customer_code from load_cust_partner
                                  where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
                                                      LOOP
    -- exit when j%NOTFOUND;
         dbms_output.put_line(j.account_group);
    if (j.account_group = 'ZDIS') THEN
    v_type := 'DISAC';
              v_nature := '06';
         --     EXIT ;
    else
    v_type := 'SPACC';
    v_nature := '01';
    END IF;
    dbms_output.put_line(v_type||' '||v_nature);
    END LOOP;
    INSERT INTO sfdc_account
              (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
    INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
    CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
    SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
    VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
    v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
    v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
    v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
    v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
    v_salesgrp, v_nature, v_cust_cur.vat_code);
    end loop;
    end loop;
    CLOSE c1;
    -- Delete data from Load Table
    -- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
    /* truncate table load_cust_partner;
    truncate table load_cust_hierarhy;
    truncate table load_cust_sales_area;
    truncate table load_cust_company_cod;
    commit;
    exception
    when others then
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    END;
    Kindly Help.....
    Thanks and Regards

    Create the procedure again and execute it in SQL*Plus environment and paste the output:
    CREATE OR REPLACE procedure insert_sfdc_account
    as
    --DECLARE
    CURSOR C1 IS
    SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
    address, city, postal_code, country_key, zzcust_type, vat_code
    FROM load_cust_general
    WHERE account_group = 'ZSIT';
    v_cust_cur c1%ROWTYPE;
    -- type sales_tab is table of load_cust_sales_area%rowtype;
    v_sales_area load_cust_sales_area%ROWTYPE;
    -- v_sales_area sales_tab;
    v_salesorg varchar2(10);
    v_sales_district varchar2(10);
    v_salesoff varchar2(10);
    v_custgrp varchar2(10);
    v_salesgrp varchar2(10);
    v_type varchar2(20);
    v_nature varchar2(10);
    v_partner_code varchar2(10);
    v_parent_cust varchar2(20);
    v_credit_blk varchar2(20);
    BEGIN
    open c1;
    loop
    fetch c1 into v_cust_cur;
    exit when c1%NOTFOUND;
    for i in (SELECT customer_code, salesorg from load_cust_partner
    where customer_code = v_cust_cur.customer_code ) LOOP
    SELECT partner_code into v_partner_code from load_cust_partner
    where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
    SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
    WHERE customer_code = i.customer_code and salesorg = i.salesorg;
    dbms_output.put_line('Customer_Code : '|| i.customer_code);
    dbms_output.put_line('SalesOrg : '|| i.salesorg);
    SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
    WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G';
    dbms_output.put_line('Successfully Executed SQL st. Error is somewhere else');
    SELECT credit_block INTO v_credit_blk from load_cust_company_cod
    WHERE customer_code = i.customer_code;
    for j in (SELECT account_group, customer_type from load_cust_general
    where customer_code IN (select customer_code from load_cust_partner
    where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
    LOOP
    -- exit when j%NOTFOUND;
    if (j.account_group = 'ZDIS') THEN
    v_type := 'DISAC';
    v_nature := '06';
    -- EXIT ;
    else
    v_type := 'SPACC';
    v_nature := '01';
    END IF;
    END LOOP;
    INSERT INTO sfdc_account
    (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
    INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
    CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
    SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
    VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
    v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
    v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
    v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
    v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
    v_salesgrp, v_nature, v_cust_cur.vat_code);
    end loop;
    end loop;
    CLOSE c1;
    -- Delete data from Load Table
    -- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
    /* truncate table load_cust_partner;
    truncate table load_cust_hierarhy;
    truncate table load_cust_sales_area;
    truncate table load_cust_company_cod;
    commit;
    exception
    when others then
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    END;
    SQL> set serveroutput on
    SQL> exec insert_sfdc_account;

  • Call to concurrent program in a pl/sql block does not COMMIT data to table

    I have the following PL/SQL block.
                             apps.create_po(x_org_id,x_document_num,x_agent_name,x_vendor_id,x_vendor_site_id,x_ship_to_location,x_bill_to_location,x_creation_date,new_isbn,new_print_key,new_unit_setup_cost,new_unit_run_cost,x_item,x_category_id,x_item_description,x_unit_of_measure,x_quantity,x_unit_price,x_ship_to_org_id,x_promise_date,x_qty_rcv_tolerance, x_deliver_to_location,x_destination_org_id, x_destination_subinventory,x_segment2,x_segment4);
                                  COMMIT;
    FND_GLOBAL.APPS_INITIALIZE(v_user_id,v_resp_id,201);
    v_po_req_id := apps.fnd_request.submit_request('PO','POXPOPDOI',NULL,NULL,NULL,
                                  NULL,'STANDARD',NULL,'Y',NULL,'APPROVED',NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
                                  DBMS_OUTPUT.PUT_LINE('Request ID is:' || v_po_req_id);
                                  IF v_po_req_id <> 0 THEN
                                       dbms_lock.sleep(60);
                                       dbms_output.Put_line('Sleep executed');
                                       COMMIT;
                                       select PHASE_CODE,STATUS_CODE INTO v_phase_code,v_status_code
                                       FROM FND_CONCURRENT_REQUESTS
                                       WHERE REQUEST_ID = v_po_req_id;
                                       dbms_output.put_line('After commit Phase and status codes are = '||v_phase_code || v_status_code);
                                  ELSE
                                       ROLLBACK;
                                  END IF;
                                  dbms_output.put_line('New Po is' || x_document_num);
                                  dbms_output.put_line('Quantity Is'|| x_quantity);
                                  apps.receive_po(x_document_num,x_quantity);
                                  v_rcv_req_id := apps.fnd_request.submit_request('PO','RVCTP',NULL,NULL,NULL,
                                  'BATCH',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
                                  DBMS_OUTPUT.PUT_LINE('Request ID is:' || v_rcv_req_id);
                                  IF v_rcv_req_id <> 0 THEN
                                       COMMIT;
                                       DBMS_OUTPUT.PUT_LINE('COMMITED RECEIVING');
                                  ELSE
                                       ROLLBACK;
                                  END IF;
    Presently when this block runs, i can see the new PO number created. Commit is also successfully executed. The last output for the program is
    New Po is 20651
    Quantity Is 450
    But due to some reason, the receiving program(receive_po) cannot retrieve the same PO from the base table.
    But once this pl/sql block is complete, and i call the receving procedure from a different session, the Po is retrieved and receiving against the PO is executed successfully.
    Can someone please suggest a work around ? Is the code missing something ? Since POXPOPDOI is a concurrent program which is executed as an asyncronous process, the commit statement after the call to concurent program does not work but the commit is executed only after it exits the pl/sql block.

    Thanks for responding.
    receive_po() program just inserts the data into RCV_HEADERS_INTERFACE and RCV_TRANSACTIONS_INTERFACE tables based on the PO that is created in the previous step. So basically the new PO created has to be received and the receive_po() just inserts data into the interface tables so that RVCTP can be called after that for receiving.
    Here is the code for the procedure.
    SET SERVEROUTPUT ON;
    --FND_GLOBAL.APPS_INITIALIZE(3,20707,201);
    --Procedure for receiving interface to load data to RCV_HEADERS_INTERFACE and RCV_TRANSACTIONS_INTERFACE
    CREATE OR REPLACE PROCEDURE receive_po (x_ponum IN VARCHAR2,x_quantity IN NUMBER) AS
    v_vendor_site_id NUMBER;
    v_vendor_id NUMBER;
    v_agent_id NUMBER;
    v_ship_to_organization_id NUMBER;
    v_item_id NUMBER;
    v_uom_code varchar2(25);
    v_subinventory varchar2(25);
    v_ship_to_location_id NUMBER;
    BEGIN
    --header information in variables
    dbms_output.put_line('Entering Receiving Insert Procedure');
    dbms_output.put_line('Po number ='||x_ponum||'$');
    dbms_output.put_line('Quantity is ='||x_quantity||'$');
    select pvsa.vendor_site_id into v_vendor_site_id
    FROM po_headers_all pha,po_vendors pv, po_vendor_sites_all pvsa
    where pha.vendor_id = pv.vendor_id
    and pv.vendor_id = pvsa.vendor_id
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Vendor Site ID is' ||v_vendor_site_id);
    select pv.vendor_id into v_vendor_id
    FROM po_headers_all pha,po_vendors pv, po_vendor_sites_all pvsa
    where pha.vendor_id = pv.vendor_id
    and pv.vendor_id = pvsa.vendor_id
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Vendor ID is' ||v_vendor_id);
    select plla.SHIP_TO_ORGANIZATION_ID into v_ship_to_organization_id
    from PO_HEADERS_ALL pha, PO_LINE_LOCATIONS_ALL plla
    where pha.PO_HEADER_ID = plla.PO_HEADER_ID
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Ship to org is' ||v_ship_to_organization_id);
    select agent_id into v_agent_id
    FROM po_headers_all
    WHERE segment1 = x_ponum;
    dbms_output.put_line('Agent ID is' ||v_agent_id);
    --printing header table information
    dbms_output.put_line('vendor id is:'||v_vendor_id);
    dbms_output.put_line('vendor site id is:'||v_vendor_site_id);
    dbms_output.put_line('agent id is:'||v_agent_id);
    dbms_output.put_line('ship to organization id is:'||v_ship_to_organization_id);
    --line information in variables
    --derive item id
    select pla.item_id into v_item_id
    from po_headers_all pha, po_lines_all pla
    where pha.po_header_id = pla.po_header_id
    and pha.org_id = pla.org_id
    and pha.segment1 = x_ponum;
    --derive uom
    select pla.unit_meas_lookup_code into v_uom_code
    from po_headers_all pha, po_lines_all pla
    where pla.po_header_id = pha.po_header_id
    and pla.org_id = pha.org_id
    and pha.segment1 = x_ponum;
    --derive subinventory
    select pda.destination_subinventory into v_subinventory
    from po_headers_all pha, po_lines_all pla,po_distributions_all pda
    where pha.po_header_id = pla.po_header_id
    and pla.po_header_id = pda.po_header_id
    and pla.po_line_id = pda.po_line_id
    and pha.org_id = pla.org_id
    and pla.org_id = pda.org_id
    and pha.segment1 = x_ponum;
    --derive ship to location id
    select ship_to_location_id into v_ship_to_location_id
    from po_headers_all
    where segment1 = x_ponum;
    --printing transaction table details
    dbms_output.put_line('item id is:'||v_item_id);
    dbms_output.put_line('UOM is:'||v_uom_code);
    dbms_output.put_line('subinventory is:'||v_subinventory);
    dbms_output.put_line('ship to location id is:'||v_ship_to_location_id);
    --insert data into the receiving interface header table
    INSERT INTO RCV_HEADERS_INTERFACE
    HEADER_INTERFACE_ID          ,
    GROUP_ID               ,
    PROCESSING_STATUS_CODE      ,
    RECEIPT_SOURCE_CODE          ,
    TRANSACTION_TYPE          ,
    LAST_UPDATE_DATE          ,
    LAST_UPDATED_BY          ,
    LAST_UPDATE_LOGIN,
    CREATION_DATE               ,
    CREATED_BY               ,
    VENDOR_ID               ,
    VENDOR_SITE_ID               ,
    SHIP_TO_ORGANIZATION_ID ,
    EXPECTED_RECEIPT_DATE          ,
    EMPLOYEE_ID               ,
    VALIDATION_FLAG          
    SELECT
    RCV_HEADERS_INTERFACE_S.NEXTVAL,
    RCV_INTERFACE_GROUPS_S.NEXTVAL,
    'PENDING',
    'VENDOR',
    'NEW', -- 'CANCEL',
    sysdate,
    3,
    3,
    sysdate,
    3,
    v_vendor_id,
    v_vendor_site_id,
    v_ship_to_organization_id,
    sysdate+5,
    v_agent_id,
    'Y'
    FROM DUAL;
    commit;
    --insert data into the interface transaction table
    for i in 1..1 loop
    INSERT INTO RCV_TRANSACTIONS_INTERFACE
    (INTERFACE_TRANSACTION_ID     ,
    HEADER_INTERFACE_ID     ,
    GROUP_ID               ,
    LAST_UPDATE_DATE          ,
    LAST_UPDATED_BY          ,
    CREATION_DATE               ,
    CREATED_BY               ,
    LAST_UPDATE_LOGIN,
    TRANSACTION_TYPE          ,
    TRANSACTION_DATE          ,
    PROCESSING_STATUS_CODE      ,
    PROCESSING_MODE_CODE          ,
    TRANSACTION_STATUS_CODE     ,
    QUANTITY               ,
    UNIT_OF_MEASURE          ,
    ITEM_ID ,
    AUTO_TRANSACT_CODE          ,
    RECEIPT_SOURCE_CODE          ,
    SOURCE_DOCUMENT_CODE          ,
    SUBINVENTORY               ,
    DOCUMENT_NUM               ,
    SHIP_TO_LOCATION_ID           ,
    VALIDATION_FLAG
    SELECT
    RCV_TRANSACTIONS_INTERFACE_S.NEXTVAL,
    RCV_HEADERS_INTERFACE_S.CURRVAL,
    RCV_INTERFACE_GROUPS_S.CURRVAL,
    SYSDATE,
    3,
    SYSDATE,
    3,
    3,
    'RECEIVE', --'RECEIVE', -- 'SHIP', --'06-JAN-1998',--question here
    sysdate,
    'PENDING',
    'BATCH',
    'PENDING',
    x_quantity,
    v_uom_code,
    v_item_id,
    'DELIVER', -- 'RECEIVE', --'DELIVER',
    'VENDOR',
    'PO',
    v_subinventory,
    x_ponum,
    v_ship_to_location_id,
    'Y'
    FROM DUAL;
    end loop;
    commit;
    END receive_po;
    I am really stuck and looking out for work arond. Please help.
    Thanks,
    Natasha

  • My First while loop inside PL/SQL block not working , please help

    Hi ,
    I am new to PL/sql and struck at PL SQL blocks , please help to solve this .
    declare
    v_A number constant :=10 ;
    j number constant := 3 ;
    BEGIN
    WHILE j < v_A
    LOOP
    DBMS_OUTPUT.PUT_LINE('Hai');
    END LOOP;
    END;
    please help as how to resolve this .
    Thanks in advance .

    btw it's a useful habit to use indentation to highlight the block structure. Also it's worth deciding what your convention will be for keywords (I use uppercase, lowercase is also fine as far as I'm concerned but I've set up my editor to uppercase them) and variables, database object names etc (I use lowercase), e.g:
    DECLARE
       v_a CONSTANT PLS_INTEGER := 10;
       j   CONSTANT PLS_INTEGER := 3;
       i PLS_INTEGER := j;
    BEGIN
       WHILE i <= v_a LOOP
          DBMS_OUTPUT.PUT_LINE(i);
          i := i +1;
       END LOOP;
    END;or perhapsdeclare
       v_a constant pls_integer := 10;
       j   constant pls_integer := 3;
       i pls_integer := j;
    begin
       while i <= v_a loop
          dbms_output.put_line(i);
          i := i +1;
       end loop;
    end;When I see "declare" and "BEGIN" in the same block of code I worry about the standard of code I'm going to see...

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

  • Error while invoking webservice using UTL_HTTP from PL/SQL Block

    Hi All,
    I am invoking a webservice (SOAP Request) from a PL/SQL block using UTL_HTTP package.
    I am able to send the complete request and am getting the required instance on the BPEL Console, but the process is erroring out while getting response back.
    and the PL/SQL Block is ending in error mentioned below:
    ERROR at line 1:
    ORA-29266: end-of-body reached
    ORA-06512: at "SYS.UTL_HTTP", line 1321
    ORA-06512: at "APPS.CSM_BPEL_TEST_PKG", line 34
    ORA-06512: at line 1
    Package is completing successfully if i test in local DB and local BPEL.
    But giving above error in client's.
    Can anyone let me know what is the cause of this.
    Thanks in advance

    I got it working by making process Synchronous.
    But with asynchronous process it is still same error.
    Thanks...

  • What is the wrong in this PL/SQL  block

    Hi a...
    Can you please tell what is the wrong in this pl/sql block.
    declare
    TYPE TYP_NT_NUM IS TABLE OF NUMBER ;
    v_tab TYP_NT_NUM := TYP_NT_NUM();
    TYPE uname is VARRAY(30) of varchar2(100) ;
    usr uname := uname ( 'u1','u2','u3','u4' );
    TYPE pwd is VARRAY(30) of varchar2(100) ;
    psw pwd := pwd('p1','p2','p3','p4');
    x number(10):=0;
    Cursor fcid IS Select distinct FC_ID From FCMASTER ;
    Begin
    Open fcid ;
    --for ii in usr.first .. usr.last loop
         Loop
              Fetch fcid Into x ;
              Exit When fcid%NOTFOUND ;
              v_tab(fcid%ROWCOUNT) := x ;
         End loop ;
         For iii IN v_tab.FIRST .. v_tab.LAST Loop
              dbms_output.put_line(v_tab(iii).FC_ID) ;
              End loop ;
    End loop; End of outer loop
    End;
    The error is
    Error
    [row:28,col:36] ORA-06550: line 28, column 36:
    PLS-00487: Invalid reference to variable 'NUMBER'
    ORA-06550: line 28, column 4:
    PL/SQL: Statement ignored
    Thanks in advance,
    Pal

    v_tab(iii).FC_ID
    declare
      type typ_nt_num is table of number;
      v_tab typ_nt_num;
    begin
      select distinct object_id bulk collect into v_tab from all_objects where rownum <= 10;
      for i in 1 .. v_tab.count loop
        dbms_output.put_line(v_tab(i)) ;
      end loop ;
    end;
    /

  • Creating a PL/SQL-Block with Boolean-Return and Check

    Hello folks,
    I have some kind of tricky problem. Actually, I want to integrate a small Task-System on my Apex 2.2 installation. Every task is intended to have a field with a anonymous PL/SQL-block in the shape of:
    Declare
    Begin
    return true/false;
    End;
    It is comparable to the condition-PL/SQL-block you can set for almost ev'ry item.
    It's not the problem to write this block half-automated, but how do I check it? Is there any kind of Database-Function?
    Thanks for your replies.
    Matthias.

    I believe Struct is basically used for SQL types , and your 'T_NACHRICHT' is a type of Objects so please pass the objects array to STRUCT.
    For example if type is :
    CREATE OR REPLACE TYPE T_NACHRICHT AS OBJECT
    ID_Nachricht NUMBER,
    ID_Vorgang NUMBER,
    --datum                 TIMESTAMP(6),
    Betreff VARCHAR2(400),
    -- Nachricht CLOB,
    ID_Antwort NUMBER,
    ist_neu VARCHAR2(5),
    CONSTRUCTOR FUNCTION T_NACHRICHT(
    p_ID_Vorgang NUMBER,
    p_Betreff VARCHAR2) RETURN SELF AS RESULT
    then call the struct in below way:
    STRUCT nachrichtSTRUCT = null;
    StructDescriptor structDesc = StructDescriptor.createDescriptor("T_NACHRICHT", conn);
              Object [] obj = {123456,123456,"ABC",123456,"ABCD"};
    nachrichtSTRUCT = new STRUCT(structDesc, conn, obj);

Maybe you are looking for

  • How to read elements in a xml file sent as a string

    Hi, I am new to BPEL and i am working on a requirement where i receive the XML message as a String from an AQ. And I am not able parse the xml to read the individual elements of it. Appreciate your help on this. The (sample)input message from Q is wh

  • Strange FONT in Adobe Reader 9 with Windows 7

    If a pdf was made from a word document or anything other than a scan the font is very strange, not default arial (see attached picture).  I had this problem in reader X adn downgraded adn still have the problem.  WHen this document is opened in gogle

  • Solaris installation - ORA-27302

    Hi, I was trying to install the Oracle Collaboration Suite on a Solaris box. During the Information storage, I got the following error in the Oracle Database Configuration Assistant: ORA-27302: failure occured at: skgpwreset1 ORA-27303: additional in

  • MIGO for Multiple POs

    Hi Guru's   I need to do migo for multiple POs ( i.e more than 8 PO's) POs  having same material from same vendor differ by QTy. Is there is any Tcode to achieve this. Thanks in advance. regards Anand

  • URL to run from through Application Server

    Hi, Anyboyd would like to tell me URL of calling form through Application Server 10.1.2 like "http://lenovo/forms/frmservlet" what next ? Regards