Calling HANA procedures and Views in oracle DB as secondary DB

Hi Experts
I have a doubt
we know using secondary database connection we can access HANA DB
My primary database is Oracle and Secondary DB is HANA
While creating secondary database connection we need to define default schema.
As we know we can access only the tables present in default schema
Can we access view and procedures created in the default schema or _SYS_BIC schemas  in ECC report running on oracle db using ADBC ?
Message was edited by: Jens Weiler

Hi Pawan,
not sure if I understand your use case correctly.
You can use a secondary DB to the HANA system. Via this secondary DB connection (e.g. in ADBC) you can create views/procedures in the HANA system. And (using again a secondary DB connection) you can consume the views/procedures.
You should not define a schema explicitely in the DDL/DML statements, this is done kind of automatically when you use the secondary database connection.
On the other hand, you have your Oracle DB. You can as well define views/procedures in the Oracle DB via ADBC and consume them (of course with Oracle DB specific syntax :-)). You can use the connection to your primary database, i.e. Oracle DB. You can even use a secondary database connection to your primary database.
What's the concrete use case you'd like to do?
Cheers,
  Jasmin

Similar Messages

  • How to handle Stored Procedure and Views

    Dear All
    While dealing with Oracle database related scenario. I came across Stored Procedures and Views. Which are complex in nature. Using SAP XI how we can handle them ?
    Is JDBC adaptor is capable of that.? Can you help me Data type structure for oracle.
    How max occur play important role in that. How to identify root and item level structure for oracle
    I am dealing with stored procedures while inserting data. and using views i need to get data from oracle database.
    What is the syntax of query we use to put while using JDBC adaptor?
    Please help and provide bit detail information over this so that i can execute scenario
    Thanks
    Gaurav

    1) jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:sid
    2)Occurence==> o,1, >1 , Unbounded
    Occurrence=> ready to accept 0 / 1 / more than 1/ multiple record  (for source) and how it will be passed to target.
    http://help.sap.com/saphelp_erp2004/helpdata/en/b6/0b733cb7d61952e10000000a11405a/frameset.htm
    3)
    <StatementName5>
    <storedProcedureName action=” EXECUTE”>
        <table>realStoredProcedureeName</table>
    <param1 [isInput=”true”] [isOutput=true] type=SQLDatatype>val1</param1>
    </storedProcedureName >
      </StatementName5>
    refer
    http://help.sap.com/saphelp_nw04/helpdata/en/22/b4d13b633f7748b4d34f3191529946/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm

  • Two related questions: using htmldb_Get to call stored procedure and passing in an array of items

    I have the need to save dynamically generated ApEx items via AJAX.  I am using APEX_ITEM API to generate the items.  At run-time, I have no idea how many of items will be generated on the page, but I know that they will all have discreet and distinct "name" attributes, i.e. f01, f02, f03, etc.  As a basic example, if I have to generate a select list, I know that the "p_idx" parameter of the APEX_ITEM call is say "3", so all select lists that get generated will have a "name" attribute in the DOM of "f03", all text items will be "f01", etc.
    I want to save this data to the database via AJAX.  It is typical to call the standard htmldb_Get javascript function for use of an on-demand process, but I am interested in using the rarely-called-upon "procedure" and queryString" options of that javascript function so that I can build the queryString on the fly based on what is on the DOM when the tries to save the data they entered into these APEX_ITEM-generated items.  Does anyone have any good examples of how to use the "procedure" and "queryString" parameters of the htmldb_Get javascript function?
    I have found a smattering of some blogs, posts, etc. online related to this, but mostly just people regurgitating the documentation.  I found this post (https://forums.oracle.com/thread/2549237) which had a glimpse of hope to be able to pass an array (which is something I will need) as a parameter, but would like someone to sanity check this before I go down that road.
    Shane.
    ApEx 4.2.1

    Shane
    Since you mention you are on APEX 4.2  I would recommend using apex.server.process which is the documented replacement of the officially undocumented htmldb_Get.
    In the documentation it is set that the first parameter is the ajaxidentifier but it actually is the process name.
    The data object would be something like
    var lData ={f01 : get_value_array('f01')}
    Where get_value_array is
    function get_value_array(pColumnName) {
      var l_values =[];
      apex.jQuery('[name="'+pColumnName+'"]').each(
       function(){
        var l_value;
        l_value = apex.item(this.id).getValue();
        l_values.push(l_value);
      return l_values
    For a working example see this demo.
    Nicolette

  • DB adapter calling stored procedure and change database schema

    Hello,
    when I create DB adapter which call stored procedure I find that is reference to DB schema in JCA file. Other DB adapter operation (select, insert, delete) store only connection-factory location.
    What happend when I move procedure to another DB schema or rename DB schema?
    It is only about change SchemaName in JCA file?
    Thank you.

    It sounds excelent.
    I try it. Change JCA file and redeploy SCA of service.
    Next I change user in data source (password is the same for both schemas). Save and activate changes. Update deployment of DBAdapter.
    Select operation on service works but return data from old schema.
    Call stored procedure fail with exception:
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'delete' failed due to: Stored procedure invocation error. Error while trying to prepare and execute the NEW_SCHEMA.PKG_UTILS.SERVICE_REMOVE API. An error occurred while preparing and executing the NEW_SCHEMA.PKG_UTILS.SERVICE_REMOVE API. Cause: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'NEW_SCHEMA.PKG_UTILS' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Check to ensure that the API is defined in the database and that the parameters match the signature of the API. This exception is considered not retriable, likely due to a modelling mistake. To classify it as retriable instead add property nonRetriableErrorCodes with value "-6550" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers. ". The invoked JCA adapter raised a resource exception.

  • Error converting SQL Server DDL and views to Oracle

    I am trying to convert SQL Serve 2008 on windows to Oracle 11g using SQL Developer 3.2.20.09. I am using the jtds-1.2.7 drivers to connect to SQL Server.
    I have made several attempts to run the conversion and am getting the tables, indexes, and triggers converted with no issue. However, my Procedures and views are not coming across. All of them are giving similar errors as:
    "Failed To Convert Stored Procedure get_compvision > esp3.dbo.get_compvision:unexpected end of subtree: Line 0 Column 0"
    When I log into the source SQL Server environment using SQL Developer, I get an empty SQL Editor window with "null" when I try to {right-click -> "Open"} on the Procedure.
    Logging into SQL Server Administrator as the same user I can see the source code, so the issue appears to be related to SQL Developer and not my user privleges. I am a dbo alias in SQL Server.
    In addition, if I click on a view, I can see the data and metadata, but not the SQL that defines the view. I see tabs for column, data, triggers, and details.
    In addition, if I go to the "capture" for my Migration project and drill down to procedures, I can see them listed, but each and every procedure gives me a "/* DDL not accesible */" error. I get teh same results for views, triggers and indexes.
    Can someone help me? I have been googling for days!
    Edited by: user4714217 on Jan 24, 2013 12:54 PM

    SELECT v.vnd_c, CASE v.use_parent_addr_flg WHEN 0 THEN a.str_1 ELSE pa.str_1 END AS str_1,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.str_2 ELSE pa.str_2 END AS str_2,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.str_3 ELSE pa.str_3 END AS str_3,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.city ELSE pa.city END AS city,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.state ELSE pa.state END AS state,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.zipcode ELSE pa.zipcode END AS zipcode,
    CAST((CASE v.use_parent_addr_flg WHEN 0 THEN (CASE a.foreign_flg WHEN 1 THEN 'Y' ELSE 'N' END)
    ELSE (CASE pa.foreign_flg WHEN 1 THEN 'Y' ELSE 'N' END) END) AS char(1)) AS foreign_flg,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.country ELSE pa.country END AS country,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.cre_d ELSE pa.cre_d END AS cre_d,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.mod_d ELSE pa.mod_d END AS mod_d,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.mod_by ELSE pa.mod_by END AS mod_by
    FROM dbo.om_vendor AS v LEFT OUTER JOIN
    dbo.om_address AS a ON a.vnd_id = v.vnd_id AND a.addr_c = 1 INNER JOIN
    dbo.om_owner AS o ON v.owr_id = o.owr_id INNER JOIN
    dbo.om_address AS pa INNER JOIN
    dbo.primary_vendors AS pv ON pa.vnd_id = pv.vnd_id ON o.part_id = pv.part_id
    WHERE (pa.addr_c = 1)
    WHICH TRANSLATES TO
    SELECT v.vnd_c ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_1
    ELSE pa.str_1
    END str_1 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_2
    ELSE pa.str_2
    END str_2 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_3
    ELSE pa.str_3
    END str_3 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.city
    ELSE pa.city
    END city ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.STATE
    ELSE pa.STATE
    END STATE ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.zipcode
    ELSE pa.zipcode
    END zipcode ,
    (CASE v.use_parent_addr_flg
    WHEN 0 THEN (CASE a.foreign_flg
    WHEN 1 THEN 'Y'
    ELSE 'N'
    END)
    ELSE (CASE pa.foreign_flg
    WHEN 1 THEN 'Y'
    ELSE 'N'
    END)
    END) foreign_flg ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.country
    ELSE pa.country
    END country ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.cre_d
    ELSE pa.cre_d
    END cre_d ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.mod_d
    ELSE pa.mod_d
    END mod_d ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.mod_by
    ELSE pa.mod_by
    END mod_by
    FROM om_vendor v
    LEFT JOIN om_address a
    ON a.vnd_id = v.vnd_id
    AND a.addr_c = 1
    JOIN om_owner o
    ON v.owr_id = o.owr_id
    JOIN om_address pa
    JOIN primary_vendors pv
    ON pa.vnd_id = pv.vnd_id
    ON o.part_id = pv.part_id
    WHERE ( pa.addr_c = 1 );
    Edited by: user4714217 on Jan 24, 2013 1:43 PM

  • JOB execution fails due to Access failure to procedures and views using certificates (encryption)

    Job execution fails using SQLServerAgent account but runs successfully under another windows personal account.
    Both have same security access on server and DB.
    The Windows account is mapped to dbo on the database .
    The package uses procedures and views which are using encryption by certificates.
    Please advice on how to provide security so that job runs from the agent

    Hi Prady26,
    If the SQL Server Agent Service account and the proxy account generated based on a Windows user account have the same permissions on both the SQL Server database and the File System of the server, it may be related to the protection level of the package.
    If the package is set to encrypt with UserKey, the job will fail unless it runs under the security context of the Windows user that designs the package in BIDS/SSDT. You can check the
    ProtectionLevel of the package in the BIDS/SSDT to see if it is EncryptSensitiveWithUserKey or EncryptAllWithUserKey, if it is, re-deploy/reinstall the package and set the package protection
    level to “Relay on server storage for encryption”.
    If the issue persists, post the error message in the job history for further analysis.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Trying to call HANA procedure via ABAP

    Hi everyone,
       I am using ABAP in Eclipse in order to call a HANA procedure within a BPC process chain. While referring to an SCN blog written by Baris Cekic, I have put together a working ABAP Class. This works as my proxy to a functioning HANA stored procedure. My issue is with the ABAP program I am using for the process chain. I believe that I'm passing my input parameter using the wrong format. Please bear with me, as I am not an ABAP programmer! Any help would be much appreciated! Please take a look at the screenshots. Thanks!
    ABAP CLASS - ZCL_BPC_AMDP:
    HANA PROCEDURE - ZPROC_BPC_AMDP:
    ABAP PROGRAM - ZBW_BPC_AMDP:
    This is my issue!! -----> INPUT of SP Name: (I've tried with and without the schema):
    ABAP PROGRAM ERROR:

    Hi Anand,
    you should preferentially use "NVARCHAR" instead of the non-unicode derivate "VARCHAR". As ABAP supports both unicode and non-unicode systems, we only allow the mapping of Strings/character literals from ABAP to NVARCHAR variables in HANA in all ABAP on HANA systems.
    Please find an example of a _SYS_BIC procedure in an AMDP in class CL_EPM_OIA_SIMP_BP_CLSF_AMDPDT (method AMDP_GET_BP_CLASSIFICATION). Should be available in your system.
    And you can additionally try to execute the call you put into the AMDP directly in the HANA SQL console.
    Cheers,
      Jasmin

  • How to Call HANA Procedure in ABAP

    Hi Everyone,
    I am new to ABAP
    I have created a procedure in HANA that accepts two input parameters and outputs a table
    I am using HANA as a Secondary Database
    How can I call this procedure in my ABAP program?
    Regards,
    Vivek

    Hi Vivek,
    depends on how you would like to call it :-)
    1. Use native SQL to call the procedure (see report ADBC_DEMO_PROC_CALLS_HDB; available in any system with a minimum NetWeaver release 7.40 SP5).
    2. Create a DB Procedure Proxy and call the DB Procedure Proxy (Tutorial: How to consume SAP HANA Procedures in ABAP; only "directly" available if HANA is the primary DB underlying your system, for secondary DB system see discussion Execute Procedure with input parameters as table from ABAP).
    3. (Method of choice available as of NetWeaver 7.4 SP5): Create an ABAP managed DB procedure (instead of the native HANA procedure) as described in ABAP Managed Database Procedures - Introduction
    Cheers,
      Jasmin

  • Calling a Procedure and Variables with a : vs. a ?

    Sorry, this is a long one, but I'm trying to provide as much background as possible.
    The below code (from a procedure called view_ibba_for_maint) is a snippet of code from a much larger SQL package. The package is called from a web browser.
    htp.tableOpen('CELLSPACING=1 CELLPADDING=1 width="50%"
    bordercolor="#669966"', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    *'nfdw_budadmn.del_ibba_warn:2'||'fyear='||fyear||'&'||*
    *'budorg='||budorg||'&'||'appr_unit='||appr_unit||'&'||*
    *'obje_ocat='||obje_ocat||'&'||*
    *'bud_auth_amount='||bud_auth_amount||'&'||*
    *'appr_name='||appr_name||'&'||*
    *'fy_id='||fycode||'&'||*
    *'borg_id='||borg_id||'&'||*
    *'appr_id='||appr_id||'&'||*
    *'obje_id='||obje_id||*
    *'"onMouseOver=" window.status=''Click to Remove IBBA Budget Line.'';*
    return true','Remove Budget'),calign=>'CENTER');
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    *'nfdw_budadmn.mod_ibba_inp'||*
    *'"onMouseOver=" window.status=''Click to Return to Query Form.'';*
    return true','Return To Query Form'),calign=>'CENTER');
    htp.tableRowClose;
    htp.tableClose;
    This portion of code calls a procedure called del_ibba_warn (in the nfdw_budadmn package). Both procedures are in the nfdw_budadmn package. view_ibba_for_maint calls del_ibba_warn a few times in the procedure. Anyway, when we were on Oracle 8i, the package and procedures worked fine. However, when we upgraded to 10g, it fails. (see the following web_browser link and error that is generated)
    Internet Explorer Address Bar:     http://orasrv2/fdotdwat/nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION%20SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968
    Error:
    Bad Request
    Your browser sent a request that this server could not understand.
    mod_plsql: /fdotdwat/nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968 HTTP-400 Name "nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968" is longer than 30 chars
    We believe it is a problem with the way del_ibba_warn is called. In the original code it is called like this: 'nfdw_budadmn.del_ibba_warn:2'. So I try to replace the :2 with a ? (like this: 'nfdw_budadmn.del_ibba_warn?' (also tried nfdw_budadmn.del_ibba_warn?2'), but it still fails. The program actually replaces the new ? that I put into the code with a :1 in the internet explorer address bar when I run it.. (Not sure why a :1 and not a :2.) But, if I go and substitute the :1 with a ? in the address bar that is generated after I attempt to call the procedure, it works. I change the address bar to this:
    http://orasrv2/fdotdwat/nfdw_budadmn.del_ibba_warn?fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount= 0&appr_name=INFORMATION%20SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968
    Hit enter, and the procedure goes forward like it should. So, the overall question is why is the IE address bar forcing the :2 or :1 to show up in the address bar? Why won't it take my ? I put in? Why was it necessary for the original programer to label the del_ibba_warn calls with a : or a :2 at all? (Again, del_ibba_warn is called a few times in the procedure). And, it used to work when we were on 8i.
    We have been trying to figure this out (on and off) for some time now. We feel like we're right there for figuring this out, but can't quite get it. Any ideas? Please let me know if I can provide any additional info. Thanks!

    Darn, didn't work. I still get the same error.......
    The address bar:
    http://orasrv2/fdotdwat/nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION%20SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968
    The Error:
    Bad Request
    Your browser sent a request that this server could not understand.
    mod_plsql: /fdotdwat/nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968 HTTP-400 Name "nfdw_budadmn.del_ibba_warn:2fyear=2008&budorg=B065&appr_unit=466026&obje_ocat=8130&bud_auth_amount=0&appr_name=INFORMATION SERVICES&fy_id=6497&borg_id=65775&appr_id=263566&obje_id=23968" is longer than 30 chars
    Now, I pasted the changes you suggested and the package did compile. But notice how it forces the ":2" into the address bar and the error message? That, I just don't get. Would it help if I posted the two procedures involved? I'll avoid posting the whole package (it's way big).
    Here are the two procedures involved.
    view_ibba_for_maint (before I made your suggested changes) & del_ibba_warn
    procedure view_ibba_for_maint(
    fyear IN VARCHAR2,
    budorg IN VARCHAR2,
    appr_unit IN VARCHAR2,
    obje_ocat IN VARCHAR2,
    password IN VARCHAR2)
    IS
    CURSOR c1 (c1_fyr_id IN NUMBER,
    c1_borg_id IN NUMBER,
    c1_appr_id IN NUMBER,
    c1_obje_id IN NUMBER,
    c1_fmonth IN NUMBER) IS
    select appr_budget_account_code, appr_budget_account_category, appr_name,
    orga_organization, obje_object_code, ibba_budget_authorized_amount
    from internal_budget_balances, appropriations, organizations, objects
    where ibba_fiscal_year_code = c1_fyr_id
    and ibba_fiscal_month_code = c1_fmonth
    and ibba_organization_id = c1_borg_id
    and orga_organization_id = ibba_organization_id
    and ibba_appropriation_id = c1_appr_id
    and appr_appropriation_id = ibba_appropriation_id
    and ibba_object_id = c1_obje_id
    and obje_object_id = ibba_object_id
    order by orga_organization,
    appr_budget_account_code||appr_budget_account_category,
    obje_object_code;
    CURSOR c2 (c2_fyr_id IN NUMBER,
    c2_borg_id IN NUMBER,
    c2_appr_id IN NUMBER,
    c2_ocat IN VARCHAR2,
    c2_fmonth IN NUMBER) IS
    select appr_budget_account_code, appr_budget_account_category, appr_name,
    orga_organization, ibba_budget_authorized_amount,
    ibba_object_category
    from internal_budget_balances, appropriations, organizations
    where ibba_fiscal_year_code = c2_fyr_id
    and ibba_fiscal_month_code = c2_fmonth
    and ibba_organization_id = c2_borg_id
    and orga_organization_id = ibba_organization_id
    and ibba_appropriation_id = c2_appr_id
    and appr_appropriation_id = ibba_appropriation_id
    and ibba_object_category = c2_ocat
    order by orga_organization,
    appr_budget_account_code||appr_budget_account_category,
    ibba_object_category;
    p_app VARCHAR2(40) :='nfdw_budadmn.mod_ibba_inp';
    c1_rec c1%ROWTYPE;
    c2_rec c2%ROWTYPE;
    dh_aelg_rec application_error_log%ROWTYPE;
    its_an_obje VARCHAR2(1) := 'F';
    valid_combo number := 0;
    obje_id objects.obje_object_id%TYPE;
    obje_name objects.obje_name%TYPE;
    borg_id organizations.orga_organization_id%TYPE;
    appr_id appropriations.appr_appropriation_id%TYPE;
    appr_name appropriations.appr_name%TYPE;
    report_date VARCHAR2(35) := to_char(sysdate, 'Month DD, YYYY');
    bud_auth_amount internal_budget_balances.ibba_budget_authorized_amount%TYPE;
    password_upper VARCHAR2(10);
    v_budadmn_password VARCHAR2(10);
    fmcode time.time_time_code%TYPE;
    fycode time.time_time_code%TYPE;
    fonth     VARCHAR2(100) :=
    '<font face="Verdana, Arial, Helvetica, sans-serif" size=2>';
    fontx VARCHAR2(100) :=
    '<font face="Verdana, Arial, Helvetica, sans-serif" size=3>';
    NULL_EXCEPTION EXCEPTION;
    INVALID_DOC EXCEPTION;
    PASSWORD_FAIL EXCEPTION;
    BEGIN
    SELECT distinct budadmn_password
    INTO v_budadmn_password
    FROM budadmn_password;
    v_budadmn_password := upper(v_budadmn_password);
    v_budadmn_password := rtrim(v_budadmn_password);
    password_upper := upper(password);
    password_upper := rtrim(password_upper);
    IF password_upper = v_budadmn_password
    THEN
    NULL;
    ELSE
    RAISE PASSWORD_FAIL;
    END IF;
    dh_aelg_rec.app_marker := 'GFYD';
    nfdw_budadmn.get_fiscal_data('NONE', fyear, fmcode, fycode, dh_aelg_rec);
    IF dh_aelg_rec.app_error_mesg = 'FAIL'
    THEN
    RAISE NULL_EXCEPTION;
    END IF;
    -- get appr id
    dh_aelg_rec.app_marker := 'APPR';
    nbdm_web.g_appr_id(substr(appr_unit,1,4), substr(appr_unit,5,2), fyear,
    appr_id, dh_aelg_rec);
    IF dh_aelg_rec.app_error_mesg = 'FAIL'
    THEN
    RAISE NULL_EXCEPTION;
    END IF;
    -- get budget org id
    dh_aelg_rec.app_marker := 'ORGA';
    nbdm_web.g_orga_id(budorg, fyear, borg_id, dh_aelg_rec);
    IF dh_aelg_rec.app_error_mesg = 'FAIL'
    THEN
    RAISE NULL_EXCEPTION;
    END IF;
    -- determine id search is by obje or ocat.
    IF length(obje_ocat) > 2
    THEN
    its_an_obje := 'T';
    dh_aelg_rec.app_marker := 'OBJE';
    nbdm_web.g_obje_id(obje_ocat, fyear, obje_id, obje_name,
    substr(appr_unit,1,4), dh_aelg_rec);
    IF dh_aelg_rec.app_error_mesg = 'FAIL'
    THEN
    RAISE NULL_EXCEPTION;
    END IF;
    END IF;
    IF its_an_obje = 'T'
    THEN
    dh_aelg_rec.app_marker := 'CHK1';
    SELECT COUNT(1)
    INTO valid_combo
    FROM internal_budget_balances
    WHERE ibba_fiscal_year_code = fycode
    AND ibba_organization_id = borg_id
    AND ibba_appropriation_id = appr_id
    AND ibba_object_id = obje_id;
    ELSE
    dh_aelg_rec.app_marker := 'CHK2';
    SELECT COUNT(1)
    INTO valid_combo
    FROM internal_budget_balances
    WHERE ibba_fiscal_year_code = fycode
    AND ibba_organization_id = borg_id
    AND ibba_appropriation_id = appr_id
    AND ibba_object_category = obje_ocat;
    END IF;
    IF valid_combo < 1
    THEN
    RAISE INVALID_DOC;
    END IF;
    IF its_an_obje = 'T'
    THEN
    -- Get max(ibba_fiscal_month_code)
    dh_aelg_rec.app_marker := 'FMC1';
    select max(ibba_fiscal_month_code)
    into fmcode
    from internal_budget_balances
    where ibba_fiscal_year_code = fycode
    and ibba_organization_id = borg_id
    and ibba_appropriation_id = appr_id
    and ibba_object_id = obje_id;
    nfdw_budadmn.nfdw_budadmn_rep_head(
    'Budget Maintenance',
    'BMAINT02',
    fyear,
    'N',
    'B',
    'N',
    'N');
    htp.tableOpen('border cellspacing=1 cellpadding=1');
    htp.p('<tr bgcolor=lightblue>');
    htp.tableHeader(fonth||(htf.bold('Orgn')), cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Unit')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Name')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Obje/Cat')),cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Auth Budget Amount')),
    cattributes=>'WIDTH="2%"', calign=>'center');
    htp.tableRowClose;
    OPEN c1(fycode, borg_id, appr_id, obje_id, fmcode);
    LOOP
    FETCH c1 INTO c1_rec;
    EXIT WHEN c1%NOTFOUND;
    BEGIN
    -- Create HTP
    htp.tableRowOpen;
    htp.tableData(fonth||nvl(c1_rec.orga_organization,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(c1_rec.appr_budget_account_code||
    c1_rec.appr_budget_account_category,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(c1_rec.appr_name,'-'),
    cnowrap=>'nowrap', calign=>'center');
    appr_name := c1_rec.appr_name;
    htp.tableData(fonth||nvl(obje_ocat,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||to_char(c1_rec.ibba_budget_authorized_amount,
    '9,999,999,999.99'), cnowrap=>'nowrap', calign=>'right');
    bud_auth_amount := c1_rec.ibba_budget_authorized_amount;
    htp.tableRowClose;
    htp.tableClose;
    END;
    END LOOP;
    CLOSE c1;
    ELSE
    -- Get max(ibba_fiscal_month_code)
    dh_aelg_rec.app_marker := 'FMC2';
    select max(ibba_fiscal_month_code)
    into fmcode
    from internal_budget_balances
    where ibba_fiscal_year_code = fycode
    and ibba_organization_id = borg_id
    and ibba_appropriation_id = appr_id
    and ibba_object_category = obje_ocat;
    nfdw_budadmn.nfdw_budadmn_rep_head(
    'Budget Maintenance',
    'BMAINT02',
    fyear,
    'N',
    'B',
    'N',
    'N');
    htp.tableOpen('border cellspacing=1 cellpadding=1');
    htp.p('<tr bgcolor=lightblue>');
    htp.tableHeader(fonth||(htf.bold('Orgn')), cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Unit')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Name')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Obje/Cat')),cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Auth Budget Amount')),
    cattributes=>'WIDTH="2%"', calign=>'center');
    htp.tableRowClose;
    OPEN c2(fycode, borg_id, appr_id, obje_ocat, fmcode);
    LOOP
    FETCH c2 INTO c2_rec;
    EXIT WHEN c2%NOTFOUND;
    BEGIN
    -- Create HTP
    htp.tableRowOpen;
    htp.tableData(fonth||nvl(c2_rec.orga_organization,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(c2_rec.appr_budget_account_code||
    c2_rec.appr_budget_account_category,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(c2_rec.appr_name,'-'),
    cnowrap=>'nowrap', calign=>'center');
    appr_name := c2_rec.appr_name;
    htp.tableData(fonth||nvl(c2_rec.ibba_object_category,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||to_char(c2_rec.ibba_budget_authorized_amount,
    '9,999,999,999.99'), cnowrap=>'nowrap', calign=>'right');
    bud_auth_amount := c2_rec.ibba_budget_authorized_amount;
    htp.tableRowClose;
    htp.tableClose;
    END;
    END LOOP;
    CLOSE c2;
    END IF;
    -- Links
    htp.br;
    htp.br;
    htp.br;
    htp.line;
    htp.tableOpen('CELLSPACING=1 CELLPADDING=1 width="50%"
    bordercolor="#669966"', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    'nfdw_budadmn.del_ibba_warn:2'||'fyear='||fyear||'&'||
    'budorg='||budorg||'&'||'appr_unit='||appr_unit||'&'||
    'obje_ocat='||obje_ocat||'&'||
    'bud_auth_amount='||bud_auth_amount||'&'||
    'appr_name='||appr_name||'&'||
    'fy_id='||fycode||'&'||
    'borg_id='||borg_id||'&'||
    'appr_id='||appr_id||'&'||
    'obje_id='||obje_id||
    '"onMouseOver=" window.status=''Click to Remove IBBA Budget Line.'';
    return true','Remove Budget'),calign=>'CENTER');
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    'nfdw_budadmn.mod_ibba_inp'||
    '"onMouseOver=" window.status=''Click to Return to Query Form.'';
    return true','Return To Query Form'),calign=>'CENTER');
    htp.tableRowClose;
    htp.tableClose;
    EXCEPTION
    WHEN NULL_EXCEPTION THEN
    dh_aelg_rec.app_error_mesg := 'FAIL';
    dh_aelg_rec.comments :=
    'Parameters are: fyear='||fyear||
    ', budorg='||budorg||
    ', appr_unit='||appr_unit||
    ', obje_ocat='||obje_ocat||
    ', password='||password;
    dh_aelg_rec.app_hierarchy := ' nfdw_budadmn.view_ibba_for_maint:';
    util_web.util_return_page
    ('An application error has occurred.',
    'Please contact the I.S. Helpdesk.',
    p_app);
    WHEN INVALID_DOC THEN
    util_web.util_return_page
    ('Requested Data Is Not Available.',
    'Check Request and Try Again.',
    p_app);
    WHEN PASSWORD_FAIL THEN
    util_web.util_return_page
    ('Invalid Password.',
    'Please Reenter.',
    p_app);
    WHEN OTHERS THEN
    dh_aelg_rec.app_error_mesg := 'FAIL';
    dh_aelg_rec.ora_error_number := SQLCODE;
    dh_aelg_rec.ora_error_mesg := substr(SQLERRM, 1, 100);
    dh_aelg_rec.comments :=
    'Parameters are: fyear='||fyear||
    ', budorg='||budorg||
    ', appr_unit='||appr_unit||
    ', obje_ocat='||obje_ocat||
    ', password='||password;
    dh_aelg_rec.app_hierarchy := ' nfdw_budadmn.view_ibba_for_maint:';
    util_web.util_log_app_error(dh_aelg_rec);
    util_web.util_return_page
    ('An application error has occurred.',
    'Please contact the I.S. Helpdesk.',
    p_app);
    END view_ibba_for_maint;
    procedure del_ibba_warn(
    fyear IN VARCHAR2,
    budorg IN VARCHAR2,
    appr_unit IN VARCHAR2,
    obje_ocat IN VARCHAR2,
    bud_auth_amount IN NUMBER,
    appr_name IN VARCHAR2,
    fy_id IN NUMBER,
    borg_id IN NUMBER,
    appr_id IN NUMBER,
    obje_id IN NUMBER)
    IS
    p_app          VARCHAR2(40) :='nfdw_budadmn.mod_ibba_inp';
    exp_ck     number := 0;
    dh_aelg_rec     application_error_log%ROWTYPE;
    fontx          VARCHAR2(100) :=
    '<font face="Verdana, Arial, Helvetica, sans-serif" size=3>';
    fonth          VARCHAR2(100) :=
    '<font face="Verdana, Arial, Helvetica, sans-serif" size=2>';
    BEGIN
    -- Check if budget line has expenditures in the NOEM.
    IF length(obje_ocat) > 2
    THEN
    dh_aelg_rec.app_marker := 'SEL1';
    SELECT count(1)
    INTO exp_ck
    FROM nbdm_object_expense_fmon
    WHERE fiscal_year = fyear
    AND fiscal_month = '12'
    AND budget_org = budorg
    AND budget_account = substr(appr_unit,1,4)
    AND budget_category = substr(appr_unit,5,2)
    AND object = obje_ocat
    AND fytd_expended_amount > 0;
    ELSE
    dh_aelg_rec.app_marker := 'SEL2';
    SELECT count(1)
    INTO exp_ck
    FROM nbdm_object_expense_fmon
    WHERE fiscal_year = fyear
    AND fiscal_month = '12'
    AND budget_org = budorg
    AND budget_account = substr(appr_unit,1,4)
    AND budget_category = substr(appr_unit,5,2)
    AND object_category = obje_ocat
    AND fytd_expended_amount > 0;
    END IF;
    htp.p('<BR>');
    htp.p('<BR>');
    htp.tableOpen('BORDER=0 BGCOLOR=WHITE', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.bold('WARNING!! WARNING!! WARNING'));
    htp.tableRowClose;
    htp.tableClose;
    htp.p('<BR>');
    IF exp_ck > 0
    THEN
    htp.tableOpen('BORDER=0 BGCOLOR=WHITE', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.bold('THE CHOSEN BUDGET HAS VALID EXPENDITURES '));
    htp.tableData(fontx||htf.bold('AND CANNOT BE REMOVED'));
    htp.tableRowClose;
    htp.tableClose;
    ELSE
    htp.tableOpen('BORDER=0 BGCOLOR=WHITE', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.bold('YOU ARE ABOUT TO PERMANANTLY REMOVE '));
    htp.tableData(fontx||htf.bold('THE FOLLOWING'));
    htp.tableRowClose;
    htp.tableClose;
    htp.tableOpen('BORDER=0 BGCOLOR=WHITE', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.bold('AUTHORIZED BUDGET FROM THE NDOT'));
    htp.tableData(fontx||htf.bold('FINANCIAL DATA WAREHOUSE'));
    htp.tableRowClose;
    htp.tableClose;
    htp.p('<BR>');
    END IF;
    htp.tableOpen('border cellspacing=1 cellpadding=1');
    htp.p('<tr bgcolor=lightblue>');
    htp.tableHeader(fonth||(htf.bold('Orgn')), cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Unit')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Appr Name')),cnowrap=>'nowrap',
    cattributes=>'WIDTH="4%"',calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Obje/Cat')),cattributes=>'WIDTH="2%"',
    calign=>'center');
    htp.tableHeader(fonth||(htf.bold('Auth Budget Amount')),
    cattributes=>'WIDTH="2%"', calign=>'center');
    htp.tableRowClose;
    htp.tableRowOpen;
    htp.tableData(fonth||nvl(budorg,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(appr_unit,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(appr_name,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||nvl(obje_ocat,'-'),
    cnowrap=>'nowrap', calign=>'center');
    htp.tableData(fonth||to_char(bud_auth_amount,
    '9,999,999,999.99'), cnowrap=>'nowrap', calign=>'right');
    htp.tableRowClose;
    htp.tableClose;
    htp.br;
    htp.br;
    htp.br;
    htp.line;
    IF exp_ck > 0
    THEN
    htp.tableOpen('CELLSPACING=1 CELLPADDING=1 width="50%"
    bordercolor="#669966"', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    'nfdw_budadmn.mod_ibba_inp'||
    '"onMouseOver=" window.status=''Click to Return to Query Form.'';
    return true','Return To Query Form'),calign=>'CENTER');
    htp.tableRowClose;
    ELSE
    htp.tableOpen('CELLSPACING=1 CELLPADDING=1 width="50%"
    bordercolor="#669966"', calign=>'center');
    htp.tableRowOpen;
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    'nfdw_budadmn.del_ibba_line:1'||
    'fy_id='||fy_id||'&'||
    'borg_id='||borg_id||'&'||
    'appr_id='||appr_id||'&'||
    'obje_id='||obje_id||'&'||
    'obje_ocat='||obje_ocat||'&'||
    'fyear='||fyear||'&'||
    'budorg='||budorg||'&'||
    'appr_unit='||appr_unit||
    '"onMouseOver=" window.status=''Click to Remove IBBA Budget Line.'';
    return true','Remove Budget'),calign=>'CENTER');
    htp.tableData(fontx||htf.anchor(owa_util.get_owa_service_path||
    'nfdw_budadmn.mod_ibba_inp'||
    '"onMouseOver=" window.status=''Click to Return to Query Form.'';
    return true','Return To Query Form'),calign=>'CENTER');
    htp.tableRowClose;
    END IF;
    htp.tableClose;
    EXCEPTION
    WHEN OTHERS THEN
    dh_aelg_rec.app_error_mesg := 'FAIL';
    dh_aelg_rec.ora_error_number := SQLCODE;
    dh_aelg_rec.ora_error_mesg := substr(SQLERRM, 1, 100);
    dh_aelg_rec.app_hierarchy := ' nfdw_budadmn.del_ibba_warn:';
    dh_aelg_rec.comments :=
    'Parameters are: fyear='||fyear||
    ', budorg='||budorg||
    ', appr_unit='||appr_unit||
    ', obje_ocat='||obje_ocat||
    ', bud_auth_amount='||bud_auth_amount||
    ', appr_name='||appr_name||
    ', fy_id='||fy_id||
    ', borg_id='||borg_id||
    ', appr_id='||appr_id||
    ', obje_id='||obje_id;
    util_web.util_log_app_error(dh_aelg_rec);
    util_web.util_return_page
    ('An application error has occurred.',
    'Please contact the I.S. Helpdesk.',
    p_app);
    END del_ibba_warn;

  • Calling stored procedure and returning multiple resultsets

    Hello,
    Is it possible to create a procedure that return multiple result sets?
    e.g.
    procedure GetDataFromTables() is
    begin
    select * from table_one;
    select * from table_two;
    end GetDataFromTables;
    And I want to call this procedure that returns multiple resultsets (one for table_one and another for table_two)
    I have referred to the OCCI sample occiproc.cpp, but I am not sure how to handle multiple resultsets.
    Your help is highly appreciated.

    Thank You,
    Got the REF cursor in storedproc.cpp.
    But as it is documented, getCursor() gets the REF CURSOR value of an OUT parameter as a ResultSet.
    So, is it true that if I have to write a procedure that selects * from 50 tables (50 SQL statements) , I have to set 50 OUT parameters to get the result sets.?
    Is there any better way of doing this?
    e.g. in DB2, we can open multiple cursors in the procedure body and then get the result set one after another.
    CREATE PROCEDURE get_staging_data ()
    RESULT SETS 1 <no. of result sets>
    LANGUAGE SQL
    BEGIN ATOMIC
    DECLARE L_SQL varchar(5000);
    DECLARE c CURSOR WITH RETURN TO CLIENT FOR L_STMT;
    SET L_SQL = '';
    SET L_SQL = 'SELECT * FROM ';
    SET L_SQL = L_SQL || IN_Tab_Name ;
    SET L_SQL = L_SQL || ' WHERE VERIFY_FLAG=''S'' FOR READ ONLY OPTIMIZE FOR 2000 ROWS' ;
    PREPARE L_STMT FROM L_SQL;
    OPEN c; < can open multiple cursors in the prodedure body>
    END

  • Where do i see all the default tables and views in oracle 10g

    hi,
    I have installed oracle 10g in the linux os.
    I just wanna see the list of deffault tables and views created by oracle.
    can anyoone hlep me on this
    thanx in advance....

    Check DBA_OBJECTS for all seeded objects in an Oracle database. For tables, check DBA_TABLES. For views, check DBA_VIEWS. All of this is documented in the fine documentation - take some time out to read thru it.
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_4156.htm#REFRN23146
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_5056.htm#sthref2482
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_5085.htm#sthref2521
    HTH
    Srini

  • Help with calling stored procedure and preparing statement

    hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();
                con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
                *cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
    ERROR:
    Incompatible Types
    Found : java.sql.Statement
    Required: java.sql.CallableStatement

    Nevermind guys..i got it..
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();           
                cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
                }     Edited by: daimous on Jan 31, 2008 6:04 PM

  • The Relation between tables and views in oracle financial

    Dears
    I am work in oracle e business r12
    and i need to build report as xml
    when run my select its need big time to view data i have a huge of data so i need to clear the relation of this tables if there is miss and if there another technique in select statement
    this is my select statement
    select
    j_hdr.je_header_id je_header_id,
    hdr.VENDOR_NAME supplier,
    SEGMENT1||'-'||SEGMENT2||'-'||SEGMENT3||'-'||SEGMENT4||'-'||SEGMENT5||'-'||SEGMENT6||'-'||SEGMENT7||'-'||SEGMENT8||'-'||SEGMENT9 Account_number,
    hdr.gl_date gl_date,
    j_hdr.CURRENCY_CODE CURRENCY_CODE,
    inv_lin.DESCRIPTION DESCRIPTION,
    j_lin.ENTERED_DR ENTERED_DR,
    j_lin.ENTERED_CR ENTERED_CR,
    j_lin.ACCOUNTED_DR ACCOUNTED_DR,
    j_lin.ACCOUNTED_CR ACCOUNTED_CR,
    j_hdr.JE_SOURCE JE_SOURCE,
    j_hdr.DEFAULT_EFFECTIVE_DATE Transaction_DATE,
    hdr.INVOICE_NUM INVOICE_NUM,
    QUICK_PO_NUMBER PO_NUMBER,
    null ASSET_CATEGORY_ID,
    hdr.VENDOR_ID VENDOR_ID
    from gl_je_headers j_hdr,gl_je_lines_v j_lin,ap_invoice_distributions dist,ap_invoices_v hdr,ap_invoice_lines_v inv_lin
    where code_combination_id = DIST_CODE_COMBINATION_ID
    and hdr.invoice_id = inv_lin.INVOICE_ID
    and dist.invoice_id = inv_lin.INVOICE_ID
    and j_hdr.JE_HEADER_ID = j_lin.JE_HEADER_ID
    and j_hdr.status = 'P'
    and nvl(:P_SOURCE,'Payables') = 'Payables'
    and je_source = 'Payables'
    and j_lin.CODE_COMBINATION_ID between ( select CODE_COMBINATION_ID
    from gl_code_combinations_kfv
    where CONCATENATED_SEGMENTS = :P_FROM_COMBINATION_CODE)
    and ( select CODE_COMBINATION_ID
    from gl_code_combinations_kfv
    where CONCATENATED_SEGMENTS = :P_TO_COMBINATION_CODE)
    AND TRUNC(dEFAULT_EFFECTIVE_DATE) BETWEEN NVL(:P_FROM_DATE, DEFAULT_EFFECTIVE_DATE) AND NVL(:P_to_DATE, DEFAULT_EFFECTIVE_DATE)
    Thanks in advance

    Welcome to the world of complicated Oracle Application queries. Didn't fully understand your question, so a few guesses -
    I think that you are asking how to make your query faster? I would reference the FAQ section on how to post a question regarding performance.
    Your title indicates you want to understand the relationship between tables and views. In general, Oracle Applications uses views for 2 reasons - to join data from multiple tables for display, and to differentiate data from different organizations. (I am still on 11i and have heard organizations are handled differently in 12 so I can't speak to that for sure).
    To understand the relationship between tables in a view, you can access the view's source code, either through a development tool such as PL/SQL Developer or TOAD (I'm guessing Oracle's tool does this also, but have never used it), or by querying the source from the dba_source table.
    select * from dba_source where name = (name of view) and type = 'VIEW' order by line;without the ( ) just the view name, in all capital letters i.e. , 'GL_JE_LINES_V'
    Good luck!

  • Calling a Procedure and Function over a db link

    I am experiencing some errors with the following and would greatly appreciate the advice of some experts here.
    My use-case is to insert some records into a table via a database link. The records to be inserted will be queried from an identical table in the local data dictionary. Everything works, but occasionally I will get a unique constraint violation if I try to insert a duplicate record so I wrote a simple function to check for the scenario. My issue is that I can run my procedure using the db link and I can run my function using the db link, but I can't use them both together without getting errors.
    My test case just uses the standard emp table:
    create or replace procedure test_insert(p_instance varchar2)
    IS
    l_sql varchar2(4000);
    begin
        l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP)';
    execute immediate l_sql;
    END;
    BEGIN
    test_insert('myLink');
    END;
    This works fine and the insert occurs without any issues.
    If I run the same procedure a second time I get:
    00001. 00000 -  "unique constraint (%s.%s) violated" which is what I expect since EMPNO has a unique constraint. So far so good.
    Now I create a function to test whether the record exists:
    create or replace function record_exists(p_empno IN NUMBER, p_instance IN varchar2) return number
    IS
    l_sql varchar2(4000);
    l_count number;
    BEGIN
    l_sql := 'select count(*) from EMP@'||p_instance||' where empno = '||p_empno;
    execute immediate l_sql into l_count;
    IF
    l_count > 0
    THEN return 1;
    ELSE
    return 0;
    END IF;
    END;
    I test this as follows:
    select record_exists(8020, 'myLink') from dual;
    RECORD_EXISTS(8020,'myLink')
                                              1
    That works ok, so now I will add that function to my procedure:
    create or replace procedure test_insert(p_instance varchar2)
    IS
    l_sql varchar2(4000);
    begin
        l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP WHERE record_exists( EMPNO, '''||p_instance||''') = 0)';
    execute immediate l_sql;
    END;
    I test this as follows:
    BEGIN
    test_insert('myLink');
    END;
    Result is:
    Error report:
    ORA-02069: global_names parameter must be set to TRUE for this operation
    ORA-06512: at "FUSION.TEST_INSERT", line 6
    ORA-06512: at line 2
    02069. 00000 -  "global_names parameter must be set to TRUE for this operation"
    *Cause:    A remote mapping of the statement is required but cannot be achieved
               because global_names should be set to TRUE for it to be achieved
    *Action:   Issue alter session set global_names = true if possible
    I don't know why I am getting this. The function works, the procedure works, but when I combine them I get an error. If I set the global names parameter to true and then rerun this I get:
    02085. 00000 -  "database link %s connects to %s"
    *Cause:    a database link connected to a database with a different name.
               The connection is rejected.
    *Action:   create a database link with the same name as the database it
               connects to, or set global_names=false.
    Any advice is much appreciated. I don't understand why I can run the procedure and the function each separately over the db link but they don't work together.
    thank you,
    john

    The proper procedure depends on what how you define failure and what it should mean - error back to caller, log and continue, just continue. Constraints are created to ensure invalid data does not get into a table. Generally they provide the most efficient mechanism for checking for invalid data, and return useful exceptions which the caller can handle. You are also doubling the work load of the uniqueness check by adding in your own check.
    In general I'd say use Exceptions, they are your friend

  • Dynamically calling stored procedure and getting result set c++

    Hello,
    I am trying to write some c++ code that will dynamically bind values to a stored procedure and excute the procedure and get back a resultset. The problem I am running into is how to get back the resultset. Any help or example would be highly appreciated.

    int main(int argc, char* argv[])
    OCIError* pOciError;
    char* pConnectChar = "dbname";
    char* pUsernameChar = "scott";
    char* pPasswordChar = "tiger";
    int answer;
    OCIStmt* pOciStatement;
    char* sqlCharArray = "BEGIN :success := sp_ListEmp; END;";
    int id;
    char ename[40];
    OCIEnv* g_pOciEnvironment = NULL;
    OCIServer* g_pOciServer = NULL;
    OCISession* g_pOciSession = NULL;
    OCISvcCtx* g_pOciServiceContext = NULL;
    sb2* pIndicator=0;
    sb2* pIndicator2=0;
    sb2* pIndicator3=0;
    OCIDefine* pOciDefine;
    OCIDefine* pOciDefine2;
    OCIBind* pBind;
    OCIStmt* cursor;
    answer = OCIInitialize(OCI_THREADED, NULL, NULL, NULL, NULL);
    answer = OCIEnvInit(&g_pOciEnvironment, OCI_DEFAULT, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciSession, OCI_HTYPE_SESSION, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServer, OCI_HTYPE_SERVER, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    answer = OCIServerAttach(g_pOciServer, pOciError, (unsigned char *)pConnectChar, strlen(pConnectChar),
    OCI_DEFAULT);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pUsernameChar, strlen(pUsernameChar),
    OCI_ATTR_USERNAME, pOciError);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pPasswordChar, strlen(pPasswordChar),
    OCI_ATTR_PASSWORD, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciServer, 0, OCI_ATTR_SERVER, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciSession, 0, OCI_ATTR_SESSION, pOciError);
    answer = OCISessionBegin(g_pOciServiceContext, pOciError, g_pOciSession, OCI_CRED_RDBMS, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&pOciStatement), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray, strlen(sqlCharArray),
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&cursor), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIBindByPos(pOciStatement,&pBind, pOciError, 1, &cursor, 0,SQLT_RSET,
    pIndicator2, 0,NULL, 0,0,OCI_DEFAULT);
    answer = OCIStmtExecute(g_pOciServiceContext, pOciStatement, pOciError, 1, 0, NULL, NULL,
    OCI_COMMIT_ON_SUCCESS);
    answer = OCIDefineByPos(cursor,&pOciDefine, pOciError,2,&id,sizeof(int),
    SQLT_INT,pIndicator, 0, 0,OCI_DEFAULT);
    answer = OCIDefineByPos(cursor,&pOciDefine2, pOciError,1,ename,40,
    SQLT_STR,pIndicator3, 0, 0,OCI_DEFAULT);
    if (answer == 0)
    while ((answer = OCIStmtFetch(cursor,pOciError, 1,OCI_FETCH_NEXT,OCI_DEFAULT)) == 0)
    printf("fetched id %d and name %s\n",id,ename);
    answer = OCIHandleFree(pOciError, OCI_HTYPE_ERROR);
    return 0;

Maybe you are looking for