Oracle Package is a pl/sql block

Hello ,
I am having a simple doubt on oracle package .
A pl/sql block (executable section) must have a begin and end .
But oracle package is having only the end part ,
so is it a pl/sql block or what ........................
Thanks

>
A pl/sql block (executable section) must have a begin and end .
But oracle package is having only the end part ,
so is it a pl/sql block or what ........................
>
No - a package is not a block.
When you have basic questions like this ALWAYS start with the Oracle documentation.
In this case that would be the PL/SQL language reference
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/overview.htm#sthref18
From Chapter 1 Overview of PL/SQL is the definition of a block
>
PL/SQL Blocks
The basic unit of a PL/SQL source program is the block, which groups related declarations and statements.
A PL/SQL block is defined by the keywords DECLARE, BEGIN, EXCEPTION, and END. These keywords partition the block into a declarative part, an executable part, and an exception-handling part. Only the executable part is required.
Declarations are local to the block and cease to exist when the block completes execution, helping to avoid cluttered namespaces for variables and subprograms.
Blocks can be nested: Because a block is an executable statement, it can appear in another block wherever an
>
And from Chapter 10 Using PL/SQL Packages
>
What is a PL/SQL Package?
A package is a schema object that groups logically related PL/SQL types, variables, and subprograms. Packages usually have two parts, a specification ("spec") and a body; sometimes the body is unnecessary.
The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines the queries for the cursors and the code for the subprograms.
You can think of the spec as an interface and of the body as a black box. You can debug, enhance, or replace a package body without changing the package spec.
>
This clearly shows that a package is not a block.

Similar Messages

  • Unable to Create Quotations in Oracle Apps with named PL/SQL Block

    Dear All,
    I got struced while creating Qotations from the backend using oracle API in a Procedure.But the same API working fine in Anonymous block and creating Qutations in apps.But the in parameters are same in anonymous and named bolck.i have done Debugging also and its returning in parameter values.but quotations not created in apps.
    I am sending the both scripts(named plsql and anonymous blocks) please anybody knows about this correct me where iam doing mistake.
    *******anonymous bolck*********
    DECLARE
    X_ROWID VARCHAR2(200) :=NULL;
    X_PO_HEADER_ID NUMBER :=NULL;
    X_AGENT_ID NUMBER :=25;
    X_TYPE_LOOKUP_CODE VARCHAR2(200) :='QUOTATION';
    X_LAST_UPDATE_DATE DATE :=SYSDATE;
    X_LAST_UPDATED_BY NUMBER :=1318;
    X_SEGMENT1 VARCHAR2(200) :=2477;
    X_SUMMARY_FLAG VARCHAR2(200) :='N';
    X_ENABLED_FLAG VARCHAR2(200) :='Y';
    X_SEGMENT2 VARCHAR2(200);
    X_SEGMENT3 VARCHAR2(200);
    X_SEGMENT4 VARCHAR2(200);
    X_SEGMENT5 VARCHAR2(200);
    X_START_DATE_ACTIVE DATE;
    X_END_DATE_ACTIVE DATE;
    X_LAST_UPDATE_LOGIN NUMBER :=45786;
    X_CREATION_DATE DATE :=SYSDATE;
    X_CREATED_BY NUMBER :=1318;
    X_VENDOR_ID NUMBER :=5;
    X_VENDOR_SITE_ID NUMBER :=6;
    X_VENDOR_CONTACT_ID NUMBER :=181;
    X_SHIP_TO_LOCATION_ID NUMBER :=204;
    X_BILL_TO_LOCATION_ID NUMBER :=207;
    X_TERMS_ID NUMBER :=10013;
    X_SHIP_VIA_LOOKUP_CODE VARCHAR2(200) :='UPS';
    X_FOB_LOOKUP_CODE VARCHAR2(200) :='Origin';
    X_PAY_ON_CODE VARCHAR2(200);
    X_FREIGHT_TERMS_LOOKUP_CODE VARCHAR2(200) :='Due';
    X_STATUS_LOOKUP_CODE VARCHAR2(200) :='A';
    X_CURRENCY_CODE VARCHAR2(200) :='USD';
    X_RATE_TYPE VARCHAR2(200);
    X_RATE_DATE DATE;
    X_RATE NUMBER;
    X_FROM_HEADER_ID NUMBER;
    X_FROM_TYPE_LOOKUP_CODE VARCHAR2(200);
    X_START_DATE DATE;
    X_END_DATE DATE;
    X_BLANKET_TOTAL_AMOUNT NUMBER;
    X_AUTHORIZATION_STATUS VARCHAR2(200);
    X_REVISION_NUM NUMBER;
    X_REVISED_DATE DATE;
    X_APPROVED_FLAG VARCHAR2(200);
    X_APPROVED_DATE DATE;
    X_AMOUNT_LIMIT NUMBER;
    X_MIN_RELEASE_AMOUNT NUMBER;
    X_NOTE_TO_AUTHORIZER VARCHAR2(200);
    X_NOTE_TO_VENDOR VARCHAR2(200);
    X_NOTE_TO_RECEIVER VARCHAR2(200);
    X_PRINT_COUNT NUMBER;
    X_PRINTED_DATE DATE;
    X_VENDOR_ORDER_NUM VARCHAR2(200);
    X_CONFIRMING_ORDER_FLAG VARCHAR2(200);
    X_COMMENTS VARCHAR2(200);
    X_REPLY_DATE DATE;
    X_REPLY_METHOD_LOOKUP_CODE VARCHAR2(200);
    X_RFQ_CLOSE_DATE DATE;
    X_QUOTE_TYPE_LOOKUP_CODE VARCHAR2(200) :='CATALOG';
    X_QUOTATION_CLASS_CODE VARCHAR2(200) :='CATALOG';
    X_QUOTE_WARNING_DELAY_UNIT VARCHAR2(200);
    X_QUOTE_WARNING_DELAY NUMBER :=7;
    X_QUOTE_VENDOR_QUOTE_NUMBER VARCHAR2(200);
    X_ACCEPTANCE_REQUIRED_FLAG VARCHAR2(200);
    X_ACCEPTANCE_DUE_DATE DATE;
    X_CLOSED_DATE DATE;
    X_USER_HOLD_FLAG VARCHAR2(200);
    X_APPROVAL_REQUIRED_FLAG VARCHAR2(200);
    X_CANCEL_FLAG VARCHAR2(200);
    X_FIRM_STATUS_LOOKUP_CODE VARCHAR2(200);
    X_FIRM_DATE DATE;
    X_FROZEN_FLAG VARCHAR2(200);
    X_SUPPLY_AGREEMENT_FLAG VARCHAR2(200) :='L';
    X_GLOBAL_AGREEMENT_FLAG VARCHAR2(200);
    X_ATTRIBUTE_CATEGORY VARCHAR2(200);
    X_ATTRIBUTE1 VARCHAR2(200);
    X_ATTRIBUTE2 VARCHAR2(200);
    X_ATTRIBUTE3 VARCHAR2(200);
    X_ATTRIBUTE4 VARCHAR2(200);
    X_ATTRIBUTE5 VARCHAR2(200);
    X_ATTRIBUTE6 VARCHAR2(200);
    X_ATTRIBUTE7 VARCHAR2(200);
    X_ATTRIBUTE8 VARCHAR2(200);
    X_ATTRIBUTE9 VARCHAR2(200);
    X_ATTRIBUTE10 VARCHAR2(200);
    X_ATTRIBUTE11 VARCHAR2(200);
    X_ATTRIBUTE12 VARCHAR2(200);
    X_ATTRIBUTE13 VARCHAR2(200);
    X_ATTRIBUTE14 VARCHAR2(200);
    X_ATTRIBUTE15 VARCHAR2(200);
    X_CLOSED_CODE VARCHAR2(200);
    X_USSGL_TRANSACTION_CODE VARCHAR2(200);
    X_GOVERNMENT_CONTEXT VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE_CATEGORY VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE1 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE2 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE3 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE4 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE5 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE6 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE7 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE8 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE9 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE10 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE11 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE12 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE13 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE14 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE15 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE16 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE17 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE18 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE19 VARCHAR2(200);
    X_GLOBAL_ATTRIBUTE20 VARCHAR2(200);
    X_MANUAL BOOLEAN;
    X_PRICE_UPDATE_TOLERANCE NUMBER;
    P_SHIPPING_CONTROL VARCHAR2(200);
    P_ENCUMBRANCE_REQUIRED_FLAG VARCHAR2(200);
    BEGIN
    APPS.PO_HEADERS_SV11.INSERT_PO(X_ROWID ,
    X_PO_HEADER_ID ,
    X_AGENT_ID ,
    X_TYPE_LOOKUP_CODE ,
    X_LAST_UPDATE_DATE ,
    X_LAST_UPDATED_BY ,
    X_SEGMENT1 ,
    X_SUMMARY_FLAG ,
    X_ENABLED_FLAG ,
    X_SEGMENT2 ,
    X_SEGMENT3 ,
    X_SEGMENT4 ,
    X_SEGMENT5 ,
    X_START_DATE_ACTIVE ,
    X_END_DATE_ACTIVE ,
    X_LAST_UPDATE_LOGIN ,
    X_CREATION_DATE ,
    X_CREATED_BY ,
    X_VENDOR_ID ,
    X_VENDOR_SITE_ID ,
    X_VENDOR_CONTACT_ID ,
    X_SHIP_TO_LOCATION_ID ,
    X_BILL_TO_LOCATION_ID ,
    X_TERMS_ID ,
    X_SHIP_VIA_LOOKUP_CODE ,
    X_FOB_LOOKUP_CODE ,
    X_PAY_ON_CODE ,
    X_FREIGHT_TERMS_LOOKUP_CODE ,
    X_STATUS_LOOKUP_CODE ,
    X_CURRENCY_CODE ,
    X_RATE_TYPE ,
    X_RATE_DATE ,
    X_RATE ,
    X_FROM_HEADER_ID ,
    X_FROM_TYPE_LOOKUP_CODE ,
    X_START_DATE ,
    X_END_DATE ,
    X_BLANKET_TOTAL_AMOUNT ,
    X_AUTHORIZATION_STATUS ,
    X_REVISION_NUM ,
    X_REVISED_DATE ,
    X_APPROVED_FLAG ,
    X_APPROVED_DATE ,
    X_AMOUNT_LIMIT ,
    X_MIN_RELEASE_AMOUNT ,
    X_NOTE_TO_AUTHORIZER ,
    X_NOTE_TO_VENDOR ,
    X_NOTE_TO_RECEIVER ,
    X_PRINT_COUNT ,
    X_PRINTED_DATE ,
    X_VENDOR_ORDER_NUM ,
    X_CONFIRMING_ORDER_FLAG ,
    X_COMMENTS ,
    X_REPLY_DATE ,
    X_REPLY_METHOD_LOOKUP_CODE ,
    X_RFQ_CLOSE_DATE ,
    X_QUOTE_TYPE_LOOKUP_CODE ,
    X_QUOTATION_CLASS_CODE ,
    X_QUOTE_WARNING_DELAY_UNIT ,
    X_QUOTE_WARNING_DELAY ,
    X_QUOTE_VENDOR_QUOTE_NUMBER ,
    X_ACCEPTANCE_REQUIRED_FLAG ,
    X_ACCEPTANCE_DUE_DATE ,
    X_CLOSED_DATE ,
    X_USER_HOLD_FLAG ,
    X_APPROVAL_REQUIRED_FLAG ,
    X_CANCEL_FLAG ,
    X_FIRM_STATUS_LOOKUP_CODE ,
    X_FIRM_DATE ,
    X_FROZEN_FLAG ,
    X_SUPPLY_AGREEMENT_FLAG ,
    X_GLOBAL_AGREEMENT_FLAG ,
    X_ATTRIBUTE_CATEGORY ,
    X_ATTRIBUTE1 ,
    X_ATTRIBUTE2 ,
    X_ATTRIBUTE3 ,
    X_ATTRIBUTE4 ,
    X_ATTRIBUTE5 ,
    X_ATTRIBUTE6 ,
    X_ATTRIBUTE7 ,
    X_ATTRIBUTE8 ,
    X_ATTRIBUTE9 ,
    X_ATTRIBUTE10 ,
    X_ATTRIBUTE11 ,
    X_ATTRIBUTE12 ,
    X_ATTRIBUTE13 ,
    X_ATTRIBUTE14 ,
    X_ATTRIBUTE15 ,
    X_CLOSED_CODE ,
    X_USSGL_TRANSACTION_CODE ,
    X_GOVERNMENT_CONTEXT ,
    X_GLOBAL_ATTRIBUTE_CATEGORY ,
    X_GLOBAL_ATTRIBUTE1 ,
    X_GLOBAL_ATTRIBUTE2 ,
    X_GLOBAL_ATTRIBUTE3 ,
    X_GLOBAL_ATTRIBUTE4 ,
    X_GLOBAL_ATTRIBUTE5 ,
    X_GLOBAL_ATTRIBUTE6 ,
    X_GLOBAL_ATTRIBUTE7 ,
    X_GLOBAL_ATTRIBUTE8 ,
    X_GLOBAL_ATTRIBUTE9 ,
    X_GLOBAL_ATTRIBUTE10 ,
    X_GLOBAL_ATTRIBUTE11 ,
    X_GLOBAL_ATTRIBUTE12 ,
    X_GLOBAL_ATTRIBUTE13 ,
    X_GLOBAL_ATTRIBUTE14 ,
    X_GLOBAL_ATTRIBUTE15 ,
    X_GLOBAL_ATTRIBUTE16 ,
    X_GLOBAL_ATTRIBUTE17 ,
    X_GLOBAL_ATTRIBUTE18 ,
    X_GLOBAL_ATTRIBUTE19 ,
    X_GLOBAL_ATTRIBUTE20 ,
    X_MANUAL ,
    X_PRICE_UPDATE_TOLERANCE ,
    P_SHIPPING_CONTROL ,
    P_ENCUMBRANCE_REQUIRED_FLAG );
    END;
    ***************************plsql named block****************
    CREATE OR REPLACE Procedure p6(p_row_id IN OUT VARCHAR2
    ,p_po_header_id IN OUT NUMBER
    ,p_segment1 IN OUT VARCHAR2
    ,p_Type_Lookup_Code IN VARCHAR2
                             ,p_agent_id IN NUMBER
    ,p_vendor_id IN NUMBER
    ,p_vendor_site_id IN NUMBER
    ,p_Ship_To_Location_Id IN NUMBER
    ,p_Bill_To_Location_Id IN NUMBER
    ,p_terms_id IN NUMBER
    ,p_fob_lookup_code IN VARCHAR2
    ,p_Freight_Terms_Lookup_Code IN VARCHAR2
    ,p_Currency_Code IN VARCHAR2
    --,p_Start_Date IN DATE
                             ,p_Quote_Type_Lookup_Code IN VARCHAR2
    --,p_quote_warning_delay IN VARCHAR2
    --,p_Vendor_Quote_Number IN VARCHAR2
    ,p_last_update_date IN DATE
    ,p_last_updated_by IN NUMBER
    ,p_last_update_login IN NUMBER
    ,p_creation_date IN DATE
    ,p_created_by IN NUMBER
    ,p_Ship_Via_Lookup_Code IN varchar2
                             ,p_Vendor_Contact_Id IN NUMBER
    --,p_res_ship_via IN VARCHAR2
    ,p_Comments IN VARCHAR2
    ,P_Supply_Agreement_Flag IN VARCHAR2
    ,p_organization_id IN VARCHAR2
    --,p_procurement_channel IN VARCHAR2
    --,p_Manual IN BOOLEAN
    --,p_return_status OUT VARCHAR2
    ,P_Authorization_Status IN VARCHAR2
                             -- ,p_error_msg OUT VARCHAR2
                        ,p_Summary_Flag in varchar2
                        ,p_Enabled_Flag in varchar2
                        ,p_Status_Lookup_Code in varchar2
                        ,p_Quotation_Class_Code in varchar2
                        ,p_Approval_Required_Flag in varchar2
                        --,X_shipping_control VARCHAR2 -- <INBOUND LOGISTICS FPJ>
    --,X_encumbrance_required_flag VARCHAR2
                        ) AS
    v_segment1 varchar2(50):=null;
    v_po_header_id number:=null;
    v_row_id varchar2(50):=null;
    BEGIN
    po_headers_sv11.insert_po(X_Rowid => v_row_id --VARCHAR2
    ,X_Po_Header_Id => v_po_header_id --NUMBER
    ,X_Agent_Id => p_agent_id --NUMBER
    ,X_Type_Lookup_Code => p_Type_Lookup_Code
    ,X_Segment1 => v_segment1 --VARCAHR2
    ,X_Summary_Flag => p_Summary_Flag
    ,X_Enabled_Flag => p_Enabled_Flag
    ,X_Vendor_Id => p_vendor_id --NUMBER
    ,X_Vendor_Site_Id => p_vendor_site_id --NUMBER
    ,X_Ship_To_Location_Id => p_Ship_To_Location_Id --NUMBER
    ,X_Bill_To_Location_Id => p_Bill_To_Location_Id --NUMBER
    ,X_Terms_Id => p_terms_id --NUMBER
    ,X_Fob_Lookup_Code => p_fob_lookup_code --VARCHAR
    ,X_Freight_Terms_Lookup_Code => p_Freight_Terms_Lookup_Code --VARCHAR
    ,X_Status_Lookup_Code => p_Status_Lookup_Code -- Active
    ,X_Currency_Code => p_Currency_Code --VARCHAR
    ,X_Start_Date =>NULL--p_start_date --DATE
    ,X_Reply_Date => NULL--p_Start_Date --DATE
    ,X_Quote_Type_Lookup_Code => p_Quote_Type_Lookup_Code --VARCHAR
    ,X_Quotation_Class_Code => p_Quotation_Class_Code
    ,X_Quote_Warning_Delay => NULL--p_quote_warning_delay --VARCHAR
    ,X_Quote_Vendor_Quote_Number => NULL--p_Vendor_Quote_Number --VARCHAR
    ,X_Approval_Required_Flag => p_Approval_Required_Flag
    ,X_Last_Update_Date => p_last_update_date --DATE
    ,X_Last_Updated_By => p_last_updated_by --NUMBER
    ,X_Segment2 => NULL
    ,X_Segment3 => NULL
    ,X_Segment4 => NULL
    ,X_Segment5 => NULL
    ,X_Start_Date_Active => NULL
    ,X_End_Date_Active => NULL
    ,X_Last_Update_Login => p_last_update_login --NUMBER
    ,X_Creation_Date => p_creation_date --DATE
    ,X_Created_By => p_created_by --NUMBER
    ,X_Vendor_Contact_Id => p_vendor_contact_id --NUMBER
    ,X_Ship_Via_Lookup_Code => p_Ship_Via_Lookup_Code
    ,X_Pay_On_Code => NULL
    ,X_Rate_Type => NULL
    ,X_Rate_Date => NULL
    ,X_Rate => NULL
    ,X_From_Header_Id => NULL
    ,X_From_Type_Lookup_Code => NULL
    ,X_End_Date => NULL
    ,X_Blanket_Total_Amount => NULL
    ,X_Authorization_Status => P_Authorization_Status
    ,X_Revision_Num => NULL
    ,X_Revised_Date => NULL
    ,X_Approved_Flag => NULL
    ,X_Approved_Date => NULL
    ,X_Amount_Limit => NULL
    ,X_Min_Release_Amount => NULL
    ,X_Note_To_Authorizer => NULL
    ,X_Note_To_Vendor => NULL
    ,X_Note_To_Receiver => NULL
    ,X_Print_Count => NULL
    ,X_Printed_Date => NULL
    ,X_Vendor_Order_Num => NULL
    ,X_Confirming_Order_Flag => NULL
    ,X_Comments => NULL
    ,X_Reply_Method_Lookup_Code => NULL
    ,X_Rfq_Close_Date => NULL
    ,X_Quote_Warning_Delay_Unit => NULL
    ,X_Acceptance_Required_Flag => NULL
    ,X_Acceptance_Due_Date => NULL
    ,X_Closed_Date => NULL
    ,X_User_Hold_Flag => NULL
    ,X_Cancel_Flag => 'N'
    ,X_Firm_Status_Lookup_Code => NULL
    ,X_Firm_Date => NULL
    ,X_Frozen_Flag => NULL
    ,X_Supply_Agreement_Flag => P_Supply_Agreement_Flag
    ,X_Global_Agreement_Flag => NULL
    ,X_Attribute_Category => NULL
    ,X_Attribute1 => NULL
    ,X_Attribute2 => NULL
    ,X_Attribute3 => p_organization_id
    ,X_Attribute4 => NULL
    ,X_Attribute5 => NULL
    ,X_Attribute6 => NULL
    ,X_Attribute7 => NULL
    ,X_Attribute8 => NULL
    ,X_Attribute9 => NULL
    ,X_Attribute10 => NULL
    ,X_Attribute11 => NULL
    ,X_Attribute12 => NULL
    ,X_Attribute13 => NULL
    ,X_Attribute14 => NULL
    ,X_Attribute15 => NULL
    ,X_Closed_Code => NULL
    ,X_Ussgl_Transaction_Code => NULL
    ,X_Government_Context => NULL
    ,X_Global_Attribute_Category => NULL
    ,X_Global_Attribute1 => NULL
    ,X_Global_Attribute2 => NULL
    ,X_Global_Attribute3 => NULL
    ,X_Global_Attribute4 => NULL
    ,X_Global_Attribute5 => NULL
    ,X_Global_Attribute6 => NULL
    ,X_Global_Attribute7 => NULL
    ,X_Global_Attribute8 => NULL
    ,X_Global_Attribute9 => NULL
    ,X_Global_Attribute10 => NULL
    ,X_Global_Attribute11 => NULL
    ,X_Global_Attribute12 => NULL
    ,X_Global_Attribute13 => NULL
    ,X_Global_Attribute14 => NULL
    ,X_Global_Attribute15 => NULL
    ,X_Global_Attribute16 => NULL
    ,X_Global_Attribute17 => NULL
    ,X_Global_Attribute18 => NULL
    ,X_Global_Attribute19 => NULL
    ,X_Global_Attribute20 => NULL
    ,X_Manual => NULL
    ,X_Price_Update_Tolerance => NULL
                             ,p_shipping_control=> NULL--X_shipping_control -- <INBOUND LOGISTICS FPJ>
    ,p_encumbrance_required_flag=> NULL--X_encumbrance_required_flag
                             commit;
    dbms_output.put_line('agent_id:'||p_agent_id);
    dbms_output.put_line('segment1:'||P_segment1);
    dbms_output.put_line('SHIP_TO_LOCATION_ID:'||P_SHIP_TO_LOCATION_ID);
    dbms_output.put_line('BILL_TO_LOCATION_ID:'||P_BILL_TO_LOCATION_ID);
    dbms_output.put_line('VENDOR_SITE_ID:'||P_VENDOR_ID);
    dbms_output.put_line('VENDOR_SITE_ID:'||P_VENDOR_SITE_ID);
    dbms_output.put_line('SUPPLY_AGREEMENT_FLAG:'||P_SUPPLY_AGREEMENT_FLAG);
    dbms_output.put_line('QUOTE_TYPE_LOOKUP_CODE:'||p_QUOTE_TYPE_LOOKUP_CODE);
    dbms_output.put_line('FREIGHT_TERMS_LOOKUP_CODE:'||P_FREIGHT_TERMS_LOOKUP_CODE);
    dbms_output.put_line('AUTHORIZATION_STATUS:'||P_AUTHORIZATION_STATUS);
    dbms_output.put_line('ORGANIZATION_ID:'||p_ORGANIZATION_ID);
    dbms_output.put_line('VENDOR_CONTACT_ID:'||P_VENDOR_CONTACT_ID);
    dbms_output.put_line('Type_Lookup_Code:'||p_Type_Lookup_Code);
    dbms_output.put_line('Summary_Flag:'||p_Summary_Flag);
    dbms_output.put_line('Enabled_Flag:'||p_Enabled_Flag);
    dbms_output.put_line('Comments:'||p_Comments);
    dbms_output.put_line('Currency_Code:'||p_Currency_Code);
    dbms_output.put_line('Authorization_Status:'||P_Authorization_Status);
    dbms_output.put_line('Status_Lookup_Code:'||p_Status_Lookup_Code);
    dbms_output.put_line('Quotation_Class_Code:'||p_Quotation_Class_Code);
    dbms_output.put_line('Approval_Required_Flag:'||p_Approval_Required_Flag);
    dbms_output.put_line('last_update_login:'||p_last_update_login);
    dbms_output.put_line('created_by:'||p_created_by);
    dbms_output.put_line('last_update_date:'||p_last_update_date);
    dbms_output.put_line('Vendor_Contact_Id:'||p_Vendor_Contact_Id);
    dbms_output.put_line('fob_lookup_code:'||p_fob_lookup_code);
    EXCEPTION
    WHEN OTHERS THEN
    --p_return_status :='E';
    --p_error_msg     :='ERROR during Insert in PO_HEADERS.'||CHR(10)||SQLERRM;
    raise;
    END p6;
    Regards,
    YellaGoud

    What is your current Oracle user ?
    show userTry to identify the table owner:
    select owner from dba_tables where table_name='CE1LAOC';And add <table owner> as prefix to table name:
    CREATE INDEX Z05 ON <table_owner>.CE1LAOC (MANDT, PALEDGER, BUKRS, PERIO, VRGAR, VKORG, HZDAT);

  • How to re-execute anonymous PL/SQL block in package definition ?

    Hi all,
    I implemented a package which contains procedures and an anonymous PL/SQL block.
    This anonymous PL/SQL block is executed only once when the package is called.
    and charge in-memory the content of table to avoid multiple SQL access each
    time one procedure is called.
    As my application open many sessions to the Oracle database, I would like to try
    a solution to signal all sessions to reload the content of table when the content
    of table is modified. The solution to stop and to restart the connection is not
    acceptable.
    Best regards
    Sylvain

    > .. to avoid multiple SQL access each time one procedure is called.
    As I understand your posting, this is the actual technical requirement. You want to force serialisation of PL/SQL code. Correct? (only one session at a time can run the procedure)
    This feature typically used to accomplish this in o/s code is called a semaphore. PL/SQL does not specifically support semaphores. However, it supports a range of IPC (Inter Process Communication) methods - from message queues to pipes.
    One of these IPC interfaces is DBMS_LOCK - which allows a unique lock to be defined and processes to manage their resource usage/execution/etc via this lock using the DBMS_LOCK API.
    I've found this a pretty clean and manageable solution to enforce serialisation. Of course, it is even better not to enforce serialisation. Rather design the code to be thread safe and capable of multi-processing/parallel processing.
    Personally, I would not use a table as an IPC mechanism as Oracle already provides better IPC mechanisms for PL/SQL code. As for "signalling sessions to re-load the table" - not possible as Oracle sessions cannot register callbacks to handle events. Oracle sessions are not event driven processes from a PL/SQL (application development) perspective.

  • Write an UPdate statement using the logic used in PL/SQL block (oracle 10g)

    Hi All,
    I have written the following PL/SQL block. I want to write an UPDATE statement using the logic used in the following PL/SQL block. can any one please help me out in this regards.
    DECLARE
       v_hoov_fag   gor_gold_post.hoov_flg%TYPE;
       v_b49n          gor_gold_post.b49n%TYPE;
       CURSOR c
       IS
          SELECT bs_id, loyalty_date, loyalty_period, contract_date
            FROM gor_gold_post
           WHERE tariff_code IN (169, 135, 136);
    BEGIN
       FOR rec IN c
       LOOP
          IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE) < 304
             OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                            - SYSDATE
                           ) IS NULL
                 AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
          THEN
             v_hoov_flg := 1;
          ELSE
             v_hoover_flag := 99;
          END IF;
          IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE) < 121.6
             OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                            - SYSDATE
                           ) IS NULL
                 AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
          THEN
             v_b49n := 1;
          ELSE
             v_b49n := 99;
          END IF;
          UPDATE gor_gold_post
             SET hoov_flg = v_hoov_flg,
                 b49n = v_b49n
           WHERE bs_id = rec.bs_id AND tariff_code IN (169, 135, 136);
          COMMIT;
       END LOOP;
    END;Thank you,

    Using case statement.
    UPDATE gor_gold_post
       SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
                                   OR
                                   (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END,
           b49n      = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
                             OR
                             (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END
    WHERE tariff_code IN (169, 135, 136);Note: Code not tested.

  • Oracle pl/sql  block in java

    Hi,
    Everybody I just want to know how we execute the pl/sql (oracle9i)block(not store Procedure)
    in java that have explicit cursor and how we print or display the value in cursor..
    pl/sql block declare
    v_id number;
    cursor cv1 IS
    select request_id from requests where sys_id = 3
    begin\n
    open cv1;
    loop
    fetch cv1 into v_id;
    exit when cv1%notfound;
    dbms_output.put_line(v_id);
    end loop; \n"
    end;;
    i try it like simple sql query
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    conn = DriverManager.getConnection(url, name, pass);
    stmt = conn.createStatement();
    rs = stmt.executeQuery(pl/sql block);
    I want display the value store in cursor............in java....
    kindly help me........
    regard's
    paritosh tomar

    Paritosh,
    You can execute anonymous PL/SQL blocks in JDBC.
    I suggest searching this forum's archives for the word "anonymous".
    If I remember correctly, there should be a relevant post from David Rolfe from a few years ago.
    Good Luck,
    Avi.

  • Try block in oracle package

    I need to add a try and throw an exception in an oracle package.
    Im refreshing a mv from local to a remote database. I need to do the following.
    try thrice for 15 minutes and after that throw exception while refreshing the mv.
    Please give me the syntax for this.

    912835 wrote:
    I need to add a try and throw an exception in an oracle package.What do you mean by "I need to add a Try"?
    As in Java Try..Catch ?
    Im refreshing a mv from local to a remote database. I need to do the following.
    try thrice for 15 minutes and after that throw exception while refreshing the mv.You can read about exception handling from FAQ: {message:id=9360013}
    Please give me the syntax for this.In that case you need to pay me ;)

  • Call DLL from PL-SQL block

    Hello all,
    I want to call a function located in an external DLL from a PL-SQL block. I execute the followin steps :
    1. Create a database library pointing to the external DLL :
    create or replace library libstk as 'C:\SUMMIT\libstkdte_s_trade1.dll'
    2. Create the definition and the body package :
    CREATE OR REPLACE PACKAGE dllcall IS
         FUNCTION s_trade (
              s_in VARCHAR2 )
    RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES(s_trade, WNDS);
    end dllcall;
    show errors
    CREATE OR REPLACE PACKAGE BODY dllcall IS
    FUNCTION s_trade (s_in IN VARCHAR2) RETURN VARCHAR2
    IS EXTERNAL
    NAME "s_trade"
    LIBRARY libstk
    PARAMETERS (s_in           STRING,
    RETURN STRING);
    END dllcall;
    show errors
    set serveroutput on
    3. Start the PL-SQL block calling the external function. And I got the foolowing error :
    1 begin
    2 dbms_output.put_line ( dllcall.s_trade ( '<Request> ' ||
    3 '<CurveId>MYCURVE</CurveId> ' ||
    4 '<Mode>02</Mode> ' ||
    5 '<ExpCcy>GBP</ExpCcy> ' ||
    6 '<AsOfDate>20001023</AsOfDate> ' ||
    7 '<Entity>***SUMMIT-XML***</Entity> ' ||
    8 '</Request>') );
    9* end;
    10
    11 /
    begin
    ERROR à la ligne 1 :
    ORA-06520: PL/SQL: Error loading external library
    ORA-06522: Unable to load DLL
    ORA-06512: at "V31.DLLCALL", line 0
    ORA-06512: at line 2
    The "Read - Execute permissions" of the DLL file was given to "Authentified users" .
    What's wrong ?
    TIA
    PS : NT2K environment, DB 8.1.7
    R. Charles Emile

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • Alter database statement in anonymous pl/sql block

    Is it possible to include an alter database statement in an anonymous pl/sql block?
    When I execute this code to query user_tables for all table names, disable their constraints and drop the table, I got the following error:
    ***MY CODE
    -- DECLARE VARIABLE(S)
    DECLARE
         v_TABLE_NAME TABLE_NAME.USER_TABLE%TYPE;
    -- DECLARE AND DEFINE CURSOR
    CURSOR c_GETTABLES is
         SELECT TABLE_NAME from USER_TABLES;
    BEGIN
    OPEN c_GETTABLES;
    LOOP
    FETCH c_GETTABLES into v_TABLE_NAME;
    EXIT when c_GETTABLES%notfound;     
    ALTER TABLE v_TABLE_NAME DISABLE PRIMARY KEY CASCADE;
    DROP TABLE v_TABLE_NAME;
    END LOOP;
    CLOSE c_GETTABLES;
    END;
    ***RESPONSE FROM SERVER
    ALTER TABLE v_TABLE_NAME DISABLE PRIMARY KEY CASCADE;
    ERROR at line 15:
    ORA-06550: line 15, column 1:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge
    <a single-quoted SQL string> pipe
    Thanks

    When you want to perform ddl statements in a (anonymous) PL/SQL block, you have to use dynamic SQL because ddl is not possible in pl/sql.
    Dynamic sql means that you sort of execute ddl statements in a sql manner. To use dynamic sql, two options exist:
    - dbms_sql package : for oracle before 8i. To use this package is not always easy. Read about it carefully first before using.
    - Native Dynamic SQL : implemented in 8i and very easy to use. An example would be :
    declare
    lv_statement varchar2(32676);
    begin
    lv_statement := 'ALTER TABLE MY_TABLE DISABLE CONSTRAINT MY_TABLE_CK1';
    execute immediate lv_statement;
    lv_statement := 'ALTER TABLE MY_TABLE ENABLE CONSTRAINT MY_TABLE_CK1';
    execute immediate lv_statement;
    end;
    Good luck.
    Edwin van Hattem

  • Cursor query retrieves records in anon pl/sql block but no data in store pr

    Hello,
    Can any one please help me,
    I am using the below query, to get the table name and constraint name
    select table_name,constraint_name
    from all_constraints
    where constraint_type in ('R','P')
    and status = 'ENABLED'
    and owner='IRIS_DATA'
    order by constraint_type desc;
    The below query retrieves data in anonymous pl/sql block and retrieve no data when i use the same cursor with the same query in procedure inside the package.
    CREATE USER CLONEDEV
    IDENTIFIED BY CLONE123
    DEFAULT TABLESPACE IRIS
    TEMPORARY TABLESPACE TEMP;
    GRANT DBA TO CLONEDEV;
    the user from which i am executing this query is granted dba role.
    My oracle version is 10.2.0.4
    Please update if you any other information.
    Please advice.
    Thanks

    >
    Roles cannot be used by pl/sql.
    >
    NOT TRUE!
    That is an oft quoted myth. There are many posts in the forum that mis-state this.
    Roles can be, and are used by PL/SQL. In fact, OP stated and demonstrated that in their question: their anonymous block worked.
    The Oracle docs provide a very clear explanation - the core restriction is for NAMED PL/SQL blocks that use DEFINER's rights (the default):
    >
    Roles Used in Named Blocks with Definer's Rights
    All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
    >
    The Database Security Guide has the information in the section 'How Roles Work in PL/SQL Blocks (which, of course, wouldln't be needed if they didn't work. ;) )
    http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#i1007304
    >
    The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer's rights or invoker's rights.
    Roles Used in Named Blocks with Definer's Rights
    All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
    The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer's rights queries SESSION_ROLES, then the query does not return any rows.
    See Also:
    Oracle Database Reference
    Roles Used in Named Blocks with Invoker's Rights and Anonymous PL/SQL Blocks
    Named PL/SQL blocks that execute with invoker's rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker's rights PL/SQL block. You can use dynamic SQL to set a role in the session.

  • Use Chains, or PL/SQL Block of calls.

    I currently have a half dozen cron jobs that kick off different batches of processing. Originally, these were generally a sequence of C programs that did different operations (fetch student info from student record system and load into IdM system, process directory changes, etc). Over the years, most of the program logic has been rewritten as PL/SQL packages and the cron jobs basically drop into SQL*PLUS and do things like:
    prompt "Do Spbpers delta"
    execute simon.employee_maint.Spbpers_Delta;
    commit;
    prompt "Do People.Update_From_Employees"
    execute simon.People_Maint.Update_From_Employees;
    commit;
    prompt "Do SGBSTDN_Full"
    execute Simon.Bstudent_Maint.Sgbstdn_Full;
    commit;
    prompt "Do SPRIDEN_Full (Student)"
    execute Simon.Bstudent_Maint.Spriden_Full;
    These procedures generally connect to other Oracle databases and get or push data around, and are hitting a number of different databases. The biggest of these scripts has 45 execute statements in it. (This script started in 1992.....)
    Anyway, we are getting some issues with and it is time to clean things up. This is my first foray into Scheduler and I am hoping to get some philosophical guidance on how best I should restructure things. One obvious thing, is to break up the big script into a couple of smaller ones. In some cases, order matters and in other, it doesn't - although I would prefer not to have several jobs hitting the admin system at the same time.
    I have been playing a bit with the scheduler, mostly via the EM web interface, and have come up with a few questions - some pretty specific, others more stylistic.
    1) Procedures as jobs - it seemed to want stand alone procedures, and NOT procedures that were part of a package. True?
    2) How fine grained should I make the steps in a chain? For example, I call 5 procedures in the same package (student_maint), each to to some specific aspect of the processing (each represents a different source table). Should I create 5 programs, and make them 5 steps in the chain, or just have 5 calls in a PL/SQL block in one program?
    3) I don't care what order these 5 run in, but I don't want more than one running at once - thoughts on approaches to this?
    4) I will on occasion want to turn off sets of these tasks (like when the remote system is going to be down for an upgrade) - how best to structure things to make this easy to do (and how do I do this?)
    The Scheduler system seems to be a very rich and flexible environment, with a lot more options and features than I need, but I feel I should do more than just scheduling a single program with 45 procedure calls in it....

    Hi,
    I can try to answer some of these questions
    1) Procedures as jobs - it seemed to want stand alone procedures, and NOT procedures that were part of a package. True?
    False. The EM interface does have this restriction, but if you use dbms_scheduler directly there is no such restrisction. Even in the EM interface you can workaround this by using a PL/SQL block which calls the package procedure (although argument handling is a little less flexible this way).
    2) How fine grained should I make the steps in a chain? For example, I call 5 procedures in the same package (student_maint), each to to some specific aspect of the processing (each represents a different source table). Should I create 5 programs, and make them 5 steps in the chain, or just have 5 calls in a PL/SQL block in one program?
    The answer to this depends on what you are doing. If the 5 steps run serially one after the other, using one pl/sql block may be easier. If you want some pieces to run in parallel, then creating a simple chain is better. A bit more effort spent setting up the chain will result in much faster execution times if you can run pieces in parallel.
    3) I don't care what order these 5 run in, but I don't want more than one running at once - thoughts on approaches to this?
    This has come up on the forum a few times and there are basically two different approaches. One is to use dbms_lock to ensure that only one runs at a time. This is the easiest way and the way that I recommend.
    The other way is to set up a job class with a resource consumer group and put into effect a resource consumer plan that specifies that only one session from that resource consumer group can run at a time. This is easily extensible to cases where you want 2 or more running at a time from a certain job class (which dbms_lock doesn't support).
    Code on how to set this up and more discussion is located here
    Run Jobs One After Another
    4) I will on occasion want to turn off sets of these tasks (like when the remote system is going to be down for an upgrade) - how best to structure things to make this easy to do (and how do I do this?)
    Jobs and programs can be disabled. But if a job or chain tries to run a disabled program it will result in a failure (though it will be retried if you say that the job can be restarted).
    [ 5) ] The Scheduler system seems to be a very rich and flexible environment, with a lot more options and features than I need, but I feel I should do more than just scheduling a single program with 45 procedure calls in it....
    The Scheduler was intended to accommodate a wide range of usage from simple one-off background tasks to complex sequences of interrelated tasks. As with any other software development you should use it in the simplest way possible that does what you need it to do.
    Hope this helps. Feel free to post any further questions.
    -Ravi

  • Spawning multiple Processes in PL/SQL Block

    Hi All
    Does anyone know if it is possible within PL/SQL block to 'spawn' multiple versions of a procedure as parallel processes.
    What I would like to do is something like
    WHILE x = 'CONTINUE LOOP
    load process1...load process2..load process3.
    I could create a UNIX script to run the procedure as a background process multiple times but I would prefer to use PL/SQL solution if one exists.
    Many thanks inadvance

    Hi Martin,
    you should have a look into the package "dbms_Job". With the routines in this package it is possible to submit the execution of stored procedures by the Oracle job scheduler.
    If you are in 10g you could alternatively use the "dbms_Scheduler" package.
    Have a nice day.
    Björn Hachmann

  • Call VB dll in pl/sql block

    Hi Every 1
    How to call VB dll in pl/sql block.
    Is there any inbuilt oracle package?
    please give me sample code for this.
    Thanx
    Anil

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • How to update PL/SQL block/Specs in Repository without cut/paste ?

    (cross-posted in METALINK form also)
    Hello,
    Question: How to quickly update PL/SQL block/specs in a package
    Repository Object Browser? (without cut/paste)
    Tools: Designer 9i, ROB 9.0.2.6
    Detailed description of a problem:
    -- there is no good pl/sql IDE working with ROB
    (JDeveloper can not work with NOT PRIVATE repository workspace)
    -- I use Toad and develop/generate pl/sql object
    directly in database.
    -- I have to synchronize my work with repository as often
    as possible the following way (we do not use read-server model
    because afraid of getting 1000s of atomik func and proc):
    ---- navigate to the pl/sql package
    ---- select properties
    ---- click on pl/sql block - get old code in editor
    ---- copy all new code from Toad into editor
    ---- remove CREATE OR REPLACE and last line
    ---- save
    ---- do the same with specifications
    I am looking for some way to do this with some script or
    one-button click...
    For example, for text files it is possible to use command line
    Repository Tool. But I did not found the possibility to make
    a script like this:
    checkout
    update workarea/container/plsql_definition/package_name/body....
    .....with new_package_body.txt
    checkin
    Thanks in advance for any help/advice,
    Alex V.

    Hi Alex,
    I just had an "Ah! I see!" moment. I now understand why you're having trouble and I can explain things so you can move on... I hope!
    First it's important to understand that Oracle SCM is designed to support versioning of both files and Oracle Designer objects. Designer objects are stored as rows in specially structured tables that support that specific product. When you look at PL/SQL definitions in the RON you're looking at Designer definitions - not files. As I mentioned before, these are not the definitions of 'real' PL/SQL objects in the data dictionary, but definitions used by Designer (from which the real things can be generated - but that's another story).
    If you're using TOAD you should probably avoid accessing the Designer objects. You need to work with files.
    Here's a suggestion for a sequence of operations:
    - In the RON check out & download the file (e.g. mypkg.plb)
    - In TOAD load the package (from DB, or downloaded file), edit, update package in DB
    - In TOAD save as mypkg.plb (overwriting the downloaded copy)
    - IN RON upload mypkg.plb and check in
    If you've not stored the file in Oracle SCM yet, jsut omit the first step.
    You could even automate this to an extent using SQL to query the data dictionary views (e.g. USER_SOURCE) after making changes to get the code and edit/overwrite the file contents that way.
    Does this help at all?
    Keith.

  • 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

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

Maybe you are looking for