Call procedure with MS SQL from linked Oracle server

I have a procedure on a remote server that I can call from SQL*PLUS
set serveroutput on
declare rez varchar2(99); msg varchar2(99); begin radar.test('AL25',rez,msg); dbms_output.put_line('Rez='||rez);
dbms_output.put_line('Msg='||msg);
end;
it gives me the neccessary result.
But I need to call the same procedure with MS SQL from a linked Oracle server, I'm trying to do it through openquery for a while, but no success yet.
Can someone tell me what is the right syntax for that query in OPENQUERY?

Have you tried configuring Oracle Heterogenous Services/ Transparent Gateway? This would let you link Oracle to SQL Server via a database link which should solve your problem.
Justin
Distributed Database Consulting, Inc.
www.ddbcinc.com

Similar Messages

  • TSQL Retrieve from linked Oracle server

    We're porting an Oracle system to SQL server and it's not going well...
    Our system is a data warehouse that extracts data from an Oracle operational system. In the Oracle version we use database links to access Oracle. On SQL Server we've created a linked server. All OK so far.
    When we try to access the linked server in TSQL we have problems:
    - select on a four part name does not pass filters to Oracle and our tables are huge
    - OPENQUERY works fine but won't let us pass parameters
    We therefore seem to be stuck when we want to update SQL server using a single keyed access to Oracle (SQL retrieves the whole table and then filters; we're processing 20,000 records and this is not acceptable!)
    I would appreciate any help you can give; I've spent most of the day searching the web for examples where people have this working, but got nowhere... help!
    Thanks in advance

    Have you tried configuring Oracle Heterogenous Services/ Transparent Gateway? This would let you link Oracle to SQL Server via a database link which should solve your problem.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Calling procedure with 2 parameters from a dynamic link

    I have just another question-
    I have a procedure testing_del_archive which is being called with 2 parameters...from a dynamic link in my SQL Query.
    The following is my code....
    SELECT re.report_exec_id, re.exec_userid,
    NVL(re.batch_exec_date, re.begin_date) report_date,
    re.rows_returned,
    re.status, re.error,
    f_file_url(re.filename) file_url,
    re.comments,
    ''Archive''archive
    FROM metadev.report_execution re, metadev.report r
    WHERE re.report_id = r.report_id
    AND r.spec_number = :v_spec
    AND re.status <> 'DELETED'
    AND re.exec_userid like (DECODE(:v_user_filter,'ALL','%',:v_user_filter))
    ORDER BY begin_date DESC
    The first parameter is the value in the execution id field and the second argument is hardcoded "Archived"...
    IT GIVES AN ERROR....
    Do you guys know where I am going wrong...

    You missed the ampersand symbol in between the parameters.
    This should be
    ''Archive''archive
    instead of
    ''Archive''archive

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Call a UNIX shell script from an oracle stored procedure

    We need to call a UNIX shell script from an oracle stored procedure
    i.e. the control should come back to the procedure once the script completes. Can any body help to achieve this ?

    There are various ways in achieving this.
    For Example, you can call a PRO*C-Library residing on the database server.
    This requires a PL/SQL library to be generated and some changes to the Listener configuration.
    It is also possible to implement a java procedure on the database being invoked by a PL/SQL wrapper class.
    In this way (and if used right) there is also granularity regarding the filestructure permissions given and it may be called during a Forms or other PL/SQL session.
    The article below explains a more generic approach how to invoke shell commands from within an Oracle Instance.
    Be careful with this, because it really works ;)
    Refer to :
    http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
    Message was edited by:
    user434854

  • Calling a Stored Procedure with output parameters from Query Templates

    This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
    We encountered a problem while calling a stored procedure from MII Query Template as follows-
    1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
    a) Input1 - CLOB
    b) Input2 - CLOB
    c) Input3 - CLOB
    d) Output1 - CLOB
    e) Output2 - CLOB
    f) Output3 - Varchar2
    2. There are two ways to get the output back.
    a) Using a Stored Procedure by declaring necessary OUT parameters.
    b) Using a Function which returns a single value.
    3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
    corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
    4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
    5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
    characters)
    6. So the method 2-a is ruled out.
    7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
    Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
    Thanks in Advance.
    Rajesh

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • Call procedure with named parameters

    Call procedure with positional parameters works, but with named parameters gives an ORA-907.
    This post seems similar: Re: Error with report - pkg and bind var
    Run as a script:
    set echo on
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false);
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS');
    begin dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false); end;
    gives:
    set echo on
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false)
    Error starting at line 2 in command:
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false)
    Error report:
    SQL Error: ORA-00907: missing right parenthesis
    00907. 00000 - "missing right parenthesis"
    *Cause:
    *Action:
    call dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS')
    call dbms_stats.delete_table_stats succeeded.
    begin dbms_stats.delete_table_stats ('ZZZMIG', 'CHAINED_ROWS', cascade_columns=>true, no_invalidate=>false); end;
    anonymous block completed
    I like the idea of using call, because the procedure name appears in the feedback - useful in longer scripts.
    I'm using SQL Developer Version 1.5.1 Build MAIN-5440
    on Windows XP SP3
    with database EE 10.2.0.3

    CALL is a SQL command which executes a routine
    (procedure/function)
    http://download-uk.oracle.com/docs/cd/B19306_01/server
    .102/b14200/statements_4008.htm
    whereas EXECUTE is a SQL*Plus command which executes
    a single PL/SQL statement
    http://download-uk.oracle.com/docs/cd/B19306_01/server
    .102/b14357/ch12022.htm#i2697931
    Message was edited by:
    Jens PetersenThank you very much, esp. for the links!

  • Procedures with PL/SQL tables.

    Hi,
    I want to write the procedures with pl/sql tables. Can we write
    if yes can you provide the example or hint. If a person helps me
    i will be great thank ful.
    thanks.
    null

    reddy (guest) wrote:
    : Hi,
    : I want to write the procedures with pl/sql tables. Can we write
    : if yes can you provide the example or hint. If a person helps
    me
    : i will be great thank ful.
    : thanks.
    check the following faq link -- it says not supported yet ...
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
    null

  • Connecting to Windows SQL server from Unix Oracle Server

    How can I connect to Windows MS SQL server from Unix Oracle Server? What installation or package will I need?

    Two options:
    1) Do a search on "Oracle Transparent Gateways" and/or "Heterogenous Services". These are products that are designed solely to connect to other databases from Oracle.
    2) Use a type-4 JDBC driver for SQL Server, installed and running in the JVM of your Oracle server. I'm assuming your Oracle database is sufficiently recent to be java-enabled here.
    Justin

  • Execute sql script in oracle server

    hi how can i run an SQL script in oracle server in every first day of the month? i dont want to run that script manually every first day of the month.

    What OS and version are you running?
    You can schedule this from the OS side as well if you don't want to use the scheduler.
    In linux you can make use of the crontab:
    crontab -e
    #then paste the following lines with the path to your scripts
    #.---------------- minute (0 - 59)
    #|   .------------- hour (0 - 23)
    #|   |   .---------- day of month (1 - 31)
    #|   |   |   .------- month (1 - 12) OR jan,feb,mar,apr ...
    #|   |   |   |  .----- day of week (0 - 7) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat
    #|   |   |   |  |
    #*   *   *   *  *  command to be executed
    00 01 1 * * /<path to your scripts>/script_name.shThe above script will run on the 1st day of every month at 01h00.
    your script (the one you are calling in the cron) will have to call the sql script and should look similar to this:
    #export all your environment variables here
    # for example
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/<your path>
    export ORACLE_SID=ORCL
    export PATH=$ORACLE_HOME/bin:$PATH
    sqlplus user/password@DB @/path/your_sql_script.sqlHope this helps

  • Using archivelog and control file from other Oracle server

    I am still bothered with my backup process.
    I have 2 AIX boxes (same model, say A and B); both have BAAN 5 and Oracle 10g R2 on. Right now my colleague insists to use the export pump (cold backup) from Prod Oracle server (A) to restore the Oracle server on Box B. The Prod server has the archivelog mode turn on. But it will miss any transaction data from import pump till the crash point of Box A. So this is my confusion.
    Can I pass the control files and archivelog files form Box A (prod server) to Box B and use them to restore the Box B as the latest Prod server? How?
    I tried to convince them to use the RMAN backup? But not successful?
    I think the best way is probably to use the Oracle Data guard. However, there is always one concern to my manager and colleague, that such process will cause the data on the restored server (failover, Box B) not recognizable by the BAAN, which define the objects (tables).
    Thanks

    Performing a logical backup is not useful to restore to the point of failure. The only valid and available option is a hot backup/archivelog mode. Your recovery manager backup perform a controlfile and redologfile backup, so those can be restored at the destination. You must take care of the way you perform the backup, and ensure the paths where your backup is being deposited are visible by the second node. A shared storage with same mount points is suitable in this case. A tape robot configured at both nodes is also a suitable solution.
    Recovery manager perfoms a controlfile and spfile restore, too. This rman command perform the action:
    SET DBID <DBID of the database,for which you want to restore the controlfile>;
    RESTORE CONTROLFILE FROM <name_of_backupiece_which_contains_the_controlfile backup>';
    I don't see any problem on the recovery manager side, and technically speaking, on the Oracle side it is perfectly possible to restore your database at a remote location. I don't know what happens on the BAAN side, if you are required to have it configured to be operative on the target node. You could try to clone your database at the node B, configure BAAN and prepare the proceduere in case of failure.
    Configuring a dataguard is also a recomended action. So it is to think about Cold Failed Over clusters. I have recently performed a CFC configuration with BAAN. No problem it works smoothly.
    ~ Madrid.

  • How to prevent from starting oracle server every time i start windows?

    I have winXP professinonal, and i would like to know how to prevent from starting oracle server every time i start windows. Because it really slows starting the windows. Thanks

    The scripts above seems to work as intended with no errors and do indeed stop my five XE services. I created the second script to start them and they do indeed start and are listed as "Started" in the Services panel aferwards.
    My XE installation has the 5 services set up to start automatically.
    I was happy to find the script above because I did not know the starting order and using the XE shortcuts for "Stop Database" and "Start Database" just seemed to cause sqlplus to receive ORA-12514 "listener does not currently know of service..." after trying to use them to restart the database. Using the scripts above seems to leave me with a different error.
    I am pretty sure I eliminated my 9i listener and it is no longer listed in my Services panel or the registry.
    Restarting the laptop does start the services correctly, and now I am on to a more pressing JDBC error, so if I get a chance to use the script again, I will post my results. Thanks.

  • Calling Oracle Stored procedure with OUT parameter from ODI

    Hi,
    I called an oracle stored procedure with following anonymous block in the ODI procedure.
    Declare
    Status varchar2(10);
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
    End;
    I want to capture the OUT parameter STATUS value in a project level variable.
    And based on its va;lue I would like to choose between 2 interfaces in my package.
    Please help me in doing this.

    Hi,
    For that kind of situation I commoly use:
    1) one step with:
    create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
    Status varchar2(10);
    end;
    * transaction 9, for instance
    2) step
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
    End;
    * transaction 9
    3) then, at an ODI variable, use a refresh like:
    select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
    at same logical shema where the package was created.
    Does it make sense to you?

  • Problem calling Procedure with parameter from Dynamic Page

    I received an error saying the Page not found
    here's how to reproduce the error.
    1. Create procedure in portal30 schema.
    Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES
    v_one IN NUMBER,
    v_two IN NUMBER,
    v_result OUT NUMBER)
    as
    begin
    v_result :=v_one+v_two;
    end;
    2. Create Dynamic Page with following code
    <ORACLE>DECLARE
    v_total NUMBER;
    BEGIN
    ADD_TWO_VALUES(:v_one,:v_two, v_total);
    htp.p('The total is => ');
    htp.p('<input type="TEXT" VALUE='||v_total||'>');
    htp.para;
    htp.anchor('http://<machine.domain:port#>/pls/portal30/PORTAL30.DYN_
    ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure');
    END;</ORACLE>
    3. I clicked on Customize Link and entered 2 numbers as values for v_one and v_two.
    4. Got "The page cannot be found" error in I.E. or "The requested URL /pls/portal30/PORTAL30.DYN_SAMPLE_ADD.show was not found on this server." on Netscape
    However when I subsitute "ADD_TWO_VALUES(:v_one,:v_two, v_total);" in the dynamic page for "ADD_TWO_VALUES(3,2, v_total);", it runs just fine.
    What's wrong here? Can I not use a parameter from a dynamic page and call a procedure with it? Help is needed urgently and will be greatly appreciated.
    -Ahsun

    Hi,
    I tried with your code with few changes ,please try with them.
    Create or Replace PROCEDURE <myschema>.ADD_TWO_VALUES
    v_one IN NUMBER,
    v_two IN NUMBER,
    v_result OUT NUMBER)
    as
    begin
    v_result :=v_one+v_two;
    end;
    I created the procedure in <mySchema> and granted that to <application_schema> and made some changes
    <ORACLE>
    DECLARE
    v_total NUMBER;
    BEGIN
    <procedure_schema>.ADD_TWO_VALUES(:v_one,:v_two, v_total);
    htp.p('The total is => ');
    htp.p('<input type="TEXT" VALUE='||v_total||'>');
    htp.para;
    htp.anchor('http://<your_host>/pls/<portal_schema>/<application_schema>.DYN_FOR_OTN.SHOW_PARMS', 'Re-Execute Procedure');
    END;
    </ORACLE>
    Hope this helps.
    rahul

  • Can I call stored procedure with PL/SQL?

    Oracle newbie question, it is.
    Assume a very simple stored procedure like this:
    Create or replace procedure aa (
    inPar IN number, outPar OUT number)
    IS
    rrr Number;
    Begin
    Blah, blah, blah...
    rrr := inPar + 100;
    Blah, blah, blah...
    outPar := rrr;
    End;
    So the questions are
    1) How do I call the above stored proc and pass input parameter values dynamically?
    2) How can I retreieve the results of outPar?
    I did some research and I learn I can use a programming interface such as Visual Basic or Java. Is that the only way available? I know a small bit about SQL*Plus. f I've tried to enter some PL/SQL commands under SQL*PLUS but I'm stuck. I must have missed something..please.
    In MS SQL Server environment I know what I can do. If I want to do the same thing, I just:
    Create proc aa ( @inParam int, @outParam int OUTPUT )
    as
    blah, blah, blah
    Set @outParam = @inParam + 1000
    return 1
    GO
    Enter the following statements (via query analyzer) to call the SQL Server Stored procedure and get the result:
    Declare @outX int
    Declare @returnX int
    exec @returnX = aa 100, @outX OUTPUT
    print str(@outX)
    print str(@returnX)
    Go

    maybe this example might be of some help:
    SQL> set linesize 120
    SQL> set pagesize 40
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> create or replace procedure proc_get_emp_name(pEmpno in number,
      2                                                pEmpName out varchar2) as
      3  begin
      4    select ename
      5      into pEmpName
      6      from emp
      7     where empno = pEmpno;
      8  end;
      9  /
    Procedure created.
    SQL> declare
      2    vEname     emp.ename%type;
      3  begin
      4    for i in (select empno from emp) loop
      5      proc_get_emp_name(i.empno,vEname);
      6      dbms_output.put_line(vEname);
      7    end loop;
      8  end;
      9  /
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • Can import 1080i from Sony HDR-HC7, but not export it

    I am helping a friend with a Sony HDR-HC7 camcorder that is capable of DV and HDV formats. They have used it without a hitch with DV shot footage on import and export to the camera. They are using iMovie HD 6.0.3. They shot footage in 1080i format an

  • No longer capable of opening TIFF or JPEG in Camera Raw

    Hi, I was able, initially, to open TIFF, JPEG and even PSD files in Camera Raw , but today I installed an HP image application that came with my iPAQ and have found that I no longer can open these files with Camera Raw from Bridge (or from anywhere e

  • Open Purchase Orders Conversion Document

    Hi All, Does any one has Conversion Document for Open POs. if so could you please share. Thanks in Advance Tenali Prasad [email protected]

  • Error message in Contribute on file checkout from Subversion

    I have Contribute CS5 and Subversion talking to each other perfectly (I also have my Dreamweaver CS5.5 connected to this Subversion server). I can create a new file in Contribute and save it which checks the file into Subversion, but everytime I try

  • FTP Receive port not pulling files

    I configured FTP receive location to pull files from FTP server. It is not pulling files and not even giving any error in event log and also provided log file location in properties. It is not doing any thing in Production server (Biztalk 2013 (Stand