How to use an Object Type from Another Database

Hi,
I have this requirement that I need to call a stored procedure from another DB (db1) but I am having a problem with this because one of the input parameters uses an object type defined in that DB (db1). Is it possible to use an object type from another database? TIA!

Sven W. wrote:
At least for queries, but I think also for procedure arguments..You (both) probably missed my post?
We can't use a remote type as procedure argument, even with the same OID.
It's OK for query on a remote object column though :
SQL> conn remote_user@remote_db
Entrez le mot de passe :
Connecté.
SQL> create type mytype oid '19A57209ECB73F91E03400400B40BBE3'
  2  as object (att1 number);
  3  /
Type créé.
SQL> create table mytable (col1 mytype);
Table créée.
SQL> insert into mytable values (mytype(777));
1 ligne créée.
SQL> create or replace function myfunc (p_in in mytype) return number
  2  is
  3  begin
  4   return p_in.att1;
  5  end;
  6  /
Fonction créée.
SQL> disconn
Déconnecté de Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> conn my_user@local_db
Entrez le mot de passe :
Connecté.
SQL> create type mytype oid '19A57209ECB73F91E03400400B40BBE3'
  2  as object (att1 number);
  3  /
Type créé.
SQL> select * from mytable@test_dbl;
COL1(ATT1)
MYTYPE(777)
SQL> declare
  2   res number;
  3  begin
  4   res := myfunc@test_dbl(mytype@test_dbl(777));
  5  end;
  6  /
res := myfunc@test_dbl(mytype@test_dbl(777));
ERREUR à la ligne 4 :
ORA-06550: Ligne 4, colonne 26 :
PLS-00331: référence non valide à REMOTE_USER.MYTYPE@TEST_DBL.WORLD
ORA-06550: Ligne 4, colonne 2 :
PL/SQL: Statement ignored
SQL> declare
  2   res number;
  3  begin
  4   res := myfunc@test_dbl(mytype(777));
  5  end;
  6  /
res := myfunc@test_dbl(mytype(777));
ERREUR à la ligne 4 :
ORA-06550: Ligne 4, colonne 9 :
PLS-00306: numéro ou types d'arguments erronés dans appel à 'MYFUNC'
ORA-06550: Ligne 4, colonne 2 :
PL/SQL: Statement ignored

Similar Messages

  • How to get the field type from the database dictionary in screen painter

    hi,
    I wanted to create a new input field that input field should have the data element from the structure that i have created. How to get the data field type from the database dictionary in the screen painter

    hi
    good
    there is two kinds of evernt
    PROCESS ON HELP-REQUEST
    PROCESS ON VALUE-REQUEST.
    which ll help you to give two types of help one is f1 help and another one is f4 help
    go through this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/47/e07f622b9911d2954f0000e8353423/content.htm
    thanks
    mrutyun

  • How do you know the object is from another database through db link

    I have a table named a2z_people. I searched dba_objects, I found this is a public synonym.
    How can I know the real table name in the another database. Where is this table come from? In another words, what's the source database?
    Thanks!

    In DBA_SYNONYMS, there is a DB_LINK column that names the database link being used (assuming the real object is on a remote database). Is that what you're looking for?
    Justin

  • How to use same collection type in different database

    i have created a synonym for a package whcih uses a collection type as input and when i am calling through that synonym it is throwing an error b'coz of the collection type saying wrong no. of arguements...
    declare
    collection_type collection_type:=collection_type('value');
    begin
    package_synonym1.procedure1(collection_type);
    END;
    how to rectify it can someone suggest....
    a quick response would be highly appreciated

    i have a package in schema A in which my input in a procedure is of type
    like
    create or replace package abc as
    procedure efg (
    ptbl_service_id in tbl_input_list,
    pn_error_code_out OUT NUMBER,
    pv_error_msg_out OUT VARCHAR2
    and in schema A the type is created.the package is working fine
    but when i am trying to test this package from database b with script as
    declare
    xyz tbl_input_list :=tbl_input_list('abcdefgh');
    begin
    abc.efg(
    xyz,
    pn_error_code_out,
    pv_error_msg_out
    end;
    then it gives an error saying wrong no. of arguements ORA-06550
    I have created the type in this database with the same OID as well and i have also tried the option of creating a synonym or calling it through a database link...
    Is there any other way through which we can use it.....
    A Quick Response will be highly appreciated...

  • How to edit an objects propertys from another VI

    Hi,
    I am running my main vi. I have a preferences.vi window that opens.
    The preferenecs.vi opens using an invoke node.
    the preferences.vi needs to be able to fill up the menu items for a Ring control that lives in the main.vi
    Normally I would you a property node, but as this object is in a different vi how do I communicate with it.
    I realise that a global variable only seems to be able to pass values between object, and not change the behavoiur of objects.
    Can any one help please!
    Many thanks, Alec
    Solved!
    Go to Solution.

    It should look like this.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Mian VI.vi ‏6 KB
    Sub VI.vi ‏6 KB

  • HT2309 I need info on how to use a SIM card from another country to have service on iPhone 4 & 5 while traveling

    I need to know any problems I might have getting a SIM card in another country and swapping it w current card in my iPhones (4 and 5).
    Need both phone and internet access while there. My carrier has no service (verizon)
    Also assume all apps and data on phones will still work?

    The GSM section of your Verizon iPhone 5 is unlocked and will work with any nano-SIM card. 
    Not all iPhone features such as FaceTime, iMessage, visual voicemail, etc, may work if using a carrier that doesn't support iPhones.  If using an unofficial carrier, you may need to enter APN settings to get cell data. LTE may not be compatable.

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • How to return object  type from external c procedure ?

    Hello all,
    I'm trying for the first time to return an object type as the return value of an external stored procedure (in C ).
    I don't have any issue to use an object type parameter for the function but not to return one to the caller.
    each time I try I get "ORA-03113: end-of-file on communication channel" and the connection is dropped.
    Thanks for any help,
    Roye Avidor
    here is the code :
    => object type
    SQL>create or replace type address as object ( age number, salary float );
    => address typ file
    CASE=SAME
    TYPE address as address
    => building the dependences structures.
    $>ott userid=scott/tiger intype=address.type code=c hfile=address.h
    => the package description
    create or replace package userTypeDefined_PKG
    is
    function getAddr( addr address ) return address;
    end;
    create or replace package body userTypeDefined_PKG
    is
    function getAddr( addr address ) return address
    AS LANGUAGE C
    NAME "addr"
    LIBRARY userTypeDefinedLib
    WITH CONTEXT
    PARAMETERS
    ( CONTEXT,
    addr,
    addr INDICATOR STRUCT ,
    return address,
    return INDICATOR STRUCT
    end;
    => The C code for the library in
    address* addr(OCIExtProcContext ctx, address address_obj, address_ind address_obj_ind, address_ind ret_ind){
    unsigned int tt;
    OCIEnv *envh;
    OCIError *errh;
    OCISvcCtx *svch;
    sword err;
    address* ret = NULL;
    int inum = 69;
    float fnum = 12.34;
    /* get OCI Environment */
    err = OCIExtProcGetEnv(ctx, &envh, &svch, &errh) ;
    /* allocate space for return sturcture*/
    ret = (address *)OCIExtProcAllocCallMemory(ctx, sizeof(address));
    /* set the AGE value */
    if ( OCINumberFromInt ( errh, &inum, sizeof(inum), OCI_NUMBER_SIGNED, &(ret->AGE) ) == OCI_ERROR )
    OCIExtProcRaiseExcp(ctx,(int)1476); // raise 1476 is fail
    /* set the SALARY value */
    if ( OCINumberFromReal ( errh, &fnum, sizeof(fnum), &(ret->SALARY) ) == OCI_ERROR )
    OCIExtProcRaiseExcp(ctx,(int)1477);// raise 1477 is fail
    // set the indicators for the structure as not null
    ret_ind->atomic = OCIIND_NOTNULL;
    ret_ind->AGE = OCI_IND_NOTNULL;
    ret_ind->SALARY = OCI_IND_NOTNULL;
    return (ret);
    }

    The return indicator should be declared as double pointer, and need to be allocated in the function body.

  • How to update date in a table from another database

    Hello,
    I am trying to code a way to Update my Testing database from another database. In the coding below the database that has the updated data ends in Restore.
    Use ClientDB_MASTER_Restore
    Truncate Table ClientDB_MASTER_Testing.dbo.Activity_Tracking_AZ
    GO
    SELECT * INTO ClientDB_Master_Testing.dbo.Activity_Tracking_AZ
    FROM Activity_Tracking_AZ
    Go
    I know with this Technique the table must be truncated if not deleted first.  There is probably a better way to do this which I'm very open to.  I'm also looking for coding that will roll back any changes made should an error occur.
      As always, any help is greatly appreciated.
    David92595

    USE ClientDB_MASTER_Testing
    go
    SET XACT_ABORT ON
    BEGIN TRANSACTION
    Truncate Table dbo.Activity_Tracking_AZ
    -- SET IDENTITY_INSERT dbo.Activity_Tracking_AZ ON
    INSERT dbo.Activity_Tracking_AZ (col1, col2, ...)
    SELECT col1, col2,
    FROM ClientDB_MASTER_Restore.dbo.Activity_Tracking_AZ
    -- SET IDENTITY_INSERT dbo.Activity_Tracking_AZ OFF
    COMMIT TRANSACTION
    If you find it boring to type the column lists, just find the table in Object Explorer, and drag the columns node to where you want the column list.
    You need the SET IDENTITY_INSERT command if the table has an IDENTITY column.
    By wrapping the code in a transaction, you are not left with an empty table if the INSERT fails. The command SET XACT_ABORT ON makes sure that the batch is aborted and rolled back in case of an error.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to use  Business Object like Vendor or PurchasingInfo

    Hi,
    How to use Business Object ( like Vendor or PurchasingInfo ) from my Object?
    For example:
    CLASS myEntity DEFINITION.
              PUBLIC SECTION.
                   METHODS: getVendor EXPORTING pVendor TYPE Vendor.
               PRIVATE SECTION.
               DATA: aVendor TYPE REF TO Vendor.
    ENDCLASS.
    CLASS myEntity IMPLEMENTATION.
    METHOD getVendor
               pVendor = aVendor .
    ENDMETHOD.
    ENDCLASS

    Hi,
    I am giving u a demo Program for ur doubt.
    REPORT demo_class_counter .
    CLASS counter DEFINITION.
      PUBLIC SECTION.
        METHODS: set IMPORTING value(set_value) TYPE i,
                 increment,
                 get EXPORTING value(get_value) TYPE i.
      PRIVATE SECTION.
        DATA count TYPE i.
    ENDCLASS.
    CLASS counter IMPLEMENTATION.
      METHOD set.
        count = set_value.
      ENDMETHOD.
      METHOD increment.
        ADD 1 TO count.
      ENDMETHOD.
      METHOD get.
        get_value = count.
      ENDMETHOD.
    ENDCLASS.
    DATA number TYPE i VALUE 5.
    DATA cnt TYPE REF TO counter.
    START-OF-SELECTION.
      CREATE OBJECT cnt.
      CALL METHOD cnt->set EXPORTING set_value = number.
      DO 3 TIMES.
        CALL METHOD cnt->increment.
      ENDDO.
      CALL METHOD cnt->get IMPORTING get_value = number.
      WRITE number.
    For more demo programs type 'abapdocu' in the command field
    U will be getting some demo programs.
    There select the abap objects.
    Regards,
    Jagadish

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How do I control my mac from another mac not in the same network?

    How do I control my mac from another mac not in the same network? Thanks

    You can do it manually, but it is much simpler if you use a tool such as Back To My Mac, LogMeIn, or something like that. Those programs enable you to connect to your computer through your router without you having to adjust the router settings manually.

  • How to open Adobe Reader file from another native IOS application?

    There is an existing thread, but I want to re-open it because I think this is an important feature that we need badly.  I was wondering if there is any plan to add this feature so we can open PDFs directly into Adobe from the web / other apps.
    How to open Adobe Reader file from another native IOS application?
    Basically, we just want to use a custom URL scheme to open a specific document in the App.  Currently, this only opens the app but does not load the file.
    APB

    Not to hijack the conversation but I can explain why this would be useful for both the above case and another.
    What I believe Pavel is talking about is setting up a "URL Scheme" for the Adobe Acrobat iOS application so that you can easily open a PDF specifically in Adobe Acrobat iOS from other native applications and even from web applications opened within Safari. This is particularly useful if your application requires some of the specific features in Adobe Reader iOS to grant them the best experience possible and you want to encourage this.
    Another case: If you're using Adobe Livecycle's document security modules (that encrypts PDF files so that Adobe Acrobat must "phone home" to decrypt and view the document), these PDF's can only be viewed inside the Adobe Acrobat application and appear as blank in most other PDF readers. Having a URL scheme allows your application utilising this functionality to have a 1 click step to view the PDF rather than the current non-user friendly process:
    - Within Safari, touch the PDF link (appears as blank in the default Safari PDF reader, which in itself is confusing)
      - Touch "Open in..."
      - Touch "Adobe Acrobat"
    We have an immediate need for this functionality for the example above. I can resubmit it in a separate post if necessary.

  • How to use same Data Type and Length for two fields

    How to use same data type and length for two fields when using 'FOR ALL ENTRIES IN' in a select statement? For instance the select queries are :
    SELECT bukrs gjahr belnr lifnr budat bldat zlspr dmbtr waers shkzg
    FROM bsik
    INTO TABLE it_bsik
    WHERE bukrs = p_bukrs
    AND lifnr IN s_lifnr.
    IF it_bsik IS NOT INITIAL.
    SELECT belnr gjahr awkey awtyp
    FROM bkpf
    INTO TABLE it_bkpf
    FOR ALL ENTRIES IN it_bsik
    WHERE belnr = it_bsik-belnr
    AND gjahr = it_bsik-gjahr.
    IF it_bkpf IS NOT INITIAL.
    SELECT belnr gjahr lifnr xblnr
    FROM rbkp
    INTO TABLE it_rbkp
    FOR ALL ENTRIES IN it_bkpf
    WHERE belnr = it_bkpf-awkey+0(10)
    AND gjahr = it_bkpf-awkey+10(4).
    ENDIF.
    ENDIF.
    Here it gives an error in the 3rd select query that 'When you use the addition "FOR ALL ENTRIES IN itab", the fields "GJAHR" and "IT_BKPF2-AWKEY+10(4)" must have the same type and the same length.'
    Kindly clarify.

    Hi Saurabh,
    Please see the example code that I have developed for you. It will help you solve the problem.
    REPORT ZTEST_3 .
    tables : BKPF.
    data : begin of it_bkpf occurs 1,
             belnr type RE_BELNR,
             awkey type awkey,
             awtyp type awtyp,
             gjahr type GJAHR,
           end of it_bkpf.
    data : begin of it_bkpf1 occurs 1,
             belnr type RE_BELNR,
             awkey type gjahr,              " change the data type
             awtyp type awtyp,
             gjahr type GJAHR,
           end of it_bkpf1.
    data : begin of it_rbkp occurs 1,
             belnr type BELNR_D,
             gjahr type gjahr,
             lifnr type LIFRE,
             xblnr type XBLNR,
           end of it_rbkp.
    select belnr
           awkey
           awtyp
           gjahr
           from bkpf
           into table it_bkpf
           where BUKRS = 'TELH'.
    loop at it_bkpf.
    it_bkpf1-belnr = it_bkpf-belnr.
    it_bkpf1-awkey = it_bkpf-awkey+10(4).           "Here only append the required length.
    it_bkpf1-awtyp = it_bkpf-awtyp.
    it_bkpf1-gjahr = it_bkpf-gjahr.
    append it_bkpf1.
    clear it_bkpf1.
    endloop.
    select  belnr
            gjahr
            lifnr
            xblnr
            from RBKP
            into table it_rbkp
            for all entries in it_bkpf1
            where belnr = it_bkpf1-belnr
    This is just an example. Change the fields according to your requirement.
    Regards
    Abhii
    Edited by: Abhii on Mar 9, 2011 9:08 AM

  • Stored procedure scope: using sp from another database

    Good day,
    I hava a stored procedure named sp_emps (simple select from an employees table) in a database named Employees.
    I would like use this procedure in a another database named New_Employees.
    Is this possible, without creating / copying the sp to the other database ?
    Also I did not want to make the sp a system object
    Please assist

    Hi Zimiso,
    The problem here is that no matter from where you execute your procedure, its context will always be the "Employees" database.
    What you ask for is possible, but only by using Dynamic SQL.
    You can have a @Database parameter on your procedure, and then concatenate the value in this parameter to wherever needed in your dynamic queries.
    For example:
    CREATE PROCEDURE sp_emps
    @Database NVARCHAR(200)
    AS
    DECLARE @Command NVARCHAR(MAX);
    SET @Command = 'SELECT * FROM ' + QUOTENAME(@Database) + '.dbo.MyEmployees'EXECUTE(@Command)
    More information about dynamic SQL:
    http://www.mssqltips.com/sqlservertip/1160/execute-dynamic-sql-commands-in-sql-server/
    This isn't an ideal solution because there are lots of possible risks and problems that come along with dynamic SQL (for example, SQL Injection).
    The better solution, in my opinion, would be to create the stored procedure as a system object (create it in the "master" database). This will make its context change based on the database from whence it was executed.
    Eitan Blumin; SQL Server Consultant - Madeira Data Solutions;

Maybe you are looking for

  • How do I connect my NI USB-6259 properly to SCXI?

    I have a NI USB-6259 DAQ Module a SCXI-1001 Chassis 3 SCXI-1143 8 Channel Low Pass Filter Modules and a SCXI-1180 Front End Plate I use a SH68-68-EPM Cable for Connecting the USB-6259(Connector 0) to a SCXI-1349. Is it wise to use another Cable to co

  • Datamerge merges same info through out layout instead of going off of csv file

    i cannot figure out why, but when i click to create merged document it previews perfectly. i unclick preview (have read it can cause issues during merge) and merge the document. Instead of it merging like the preview i literally get 31 pages of the s

  • Intel 5300 agn keeps disconnecting on brand new X301

    Hi, I just received a new X301 today with Windows 7 64 bit and I've been quite happy with it except that the wireless card keeps losing the signal and then reconnecting. I am not sure why and this does not occur with other laptops on this network. Wh

  • The underlying task reported failure on exit

    Hi All, I keep getting the following message when I try to verify disk and like to know if this is a known issue. Perhaps someone has solution for it, thanks for reading: Verifying volume "Macintosh HD" Checking HFS Plus volume. Checking Extents Over

  • My computer will not opload windows updates

    Recently, when my computer goes to update Windows, many of the updated do not install. I've tried the fixes offered by windows forums, but I wondered if you had any ideas on this.