How to call dbms_metadata.get_ddl of ODP?

This package function returns a CLOB.

Whenever I call it, I get the error ORA-22275.

I looked at the examples and I can't figure out what I need to do. From what I can find by looking at examples of Microsoft, I need create sort of a temporary CLOB in the database, and then somehow a back reference in my call to the package.

Does anyone have an example on how to do this?

Here is the code I have, but it keeps returning ORA-22275

using (OracleConnection oraConn = OracleConnection (targetConnString)) new
{
OracleParameter parmObjectType = new OracleParameter();
parmObjectType.OracleDbType = OracleDbType.Varchar2;
parmObjectType.ParameterName = 'OBJECT_TYPE ';
parmObjectType.Value = objectType;

OracleParameter parmObjectName = new OracleParameter();
parmObjectName.OracleDbType = OracleDbType.Varchar2;
parmObjectName.ParameterName = "NAME";
parmObjectName.Value = objectName;

OracleParameter parmObjectOwner = new OracleParameter();
parmObjectOwner.OracleDbType = OracleDbType.Varchar2;
parmObjectOwner.ParameterName = 'SCHEMA ';
parmObjectOwner.Value = objectOwner;

oraConn.Open ();

OracleCommand cmd = new OracleCommand();
cmd connection group oraConn;.

cmd.CommandText = "declare clob xx; begin dbms_lob.createtemporary (xx, false, 0); : tempclob: = xx; end; « ;
cmd. Parameters.Add (new OracleParameter ("tempclob", OracleDbType.Clob)). Direction = ParameterDirection.Output;

cmd ExecuteNonQuery());

OracleClob tempclob is cmd (OracleClob). Parameters [0]. Value;
cmd Parameters.Clear ();

OracleParameter parmScript = new OracleParameter();
parmScript.OracleDbType = OracleDbType.Clob;
parmScript.Direction = ParameterDirection.ReturnValue;
parmScript.Value = tempclob;


cmd.CommandText = "dbms_metadata.get_ddl";
cmd.CommandType = CommandType.StoredProcedure;
cmd. Parameters.Add (parmObjectType);
cmd. Parameters.Add (parmObjectName);
cmd. Parameters.Add (parmObjectOwner);
cmd. Parameters.Add (parmScript);

cmd ExecuteNonQuery()); <-this is where the code does not work!


oraConn.Close ();

}

Published by: [email protected] on March 23, 2009 14:43

Hi Enzo,

Have you run my code CORRECT, exactly as planned?

It's just that I look back on your original post that looks like you can add parameters in the right order. ODP is BindByPosition, so you must ensure that the Clob gets first instruction executed ultimately added to the collection will be something like start: 1: = dbms_metadata.get_ddl (: 2:3.. etc).

If I intentionally add parameters to the collection in the wrong order, 22275 results. If happens?

Greg

Tags: Database

Similar Questions

  • Another question about dbms_metadata.get_ddl

    Hello

    Recorded in as 'sys as sysdba' I tried to get the DDL for the EMP table in the SCOTT schema. Here is the output I got:
      1* select scott.dbms_metadata.get_ddl('TABLE', 'EMP') from dual
    SQL> /
    select scott.dbms_metadata.get_ddl('TABLE', 'EMP') from dual
           *
    ERROR at line 1:
    ORA-00904: "SCOTT"."DBMS_METADATA"."GET_DDL": invalid identifier
    Remove the reference to SCOTT, we get another error (no surprise):
    ORA-31603: object "EMP" of type TABLE not found in schema "SYS"
    Question: How the ADMINISTRATOR bring the DDL for a table without having to sign in as a user that owns the schema?

    Thank you

    John.

    He must inform the owner of this object when running DBMS_METADATA of SYS.

    If we describe DBMS_METADATA

    FUNCTION GET_DDL RETURNS CLOB
     Argument Name                  Type                    In/Out Default?
     ------------------------------ ----------------------- ------ --------
     OBJECT_TYPE                    VARCHAR2                IN
     NAME                           VARCHAR2                IN
     SCHEMA                         VARCHAR2                IN     DEFAULT
     VERSION                        VARCHAR2                IN     DEFAULT
     MODEL                          VARCHAR2                IN     DEFAULT
     TRANSFORM                      VARCHAR2                IN     DEFAULT
    

    So there must be another SCHEMA parameter when running DBMS_METADATA of SYS.

  • grant dbms_metadata.get_ddl wanted

    Hi all! I need help. I want to get in clob a ddl of an object. What I am doing wrong?

    Select the owner, constraint_name from dba_constraints where constraint_name = "TOME_KYTE_IS_UNIQUE";


    OWNER CONSTRAINT_NAME
    TOMKYTE TOME_KYTE_IS_UNIQUE




    Create procedure tomkyte.testprint as

    CLOB text;

    Start
    Select DBMS_METADATA. GET_DDL ('CONSTRAINT', 'TOME_KYTE_IS_UNIQUE', 'TOMKYTE')
    in the text of the double;

    dbms_output.put_line('1');

    end;

    -----
    procedure created

    -----
    Start
    tomkyte.testprint; -I plugged as tomkyte
    end;



    ORA-31603: object "TOME_KYTE_IS_UNIQUE" of type CONSTRAINT was not found in the schema TOMKYTE

    This who should I agree with tom that he can get atleast its own objects ddl?

    Thanks in advance.

    Instead of DBA_constraints you can use USER_CONSTRAINTS and see how it works

    create or replace procedure tomkyte.buildConstraint(
    cons_name varchar2,
    cons_owner varchar2,
    cons_new_owner varchar2) AS
    
    stat clob;
    e varchar2(4000);
    var varchar2(300);
    begin
    select DBMS_METADATA.GET_DDL('*CONSTRAINT*',cons_name,cons_owner) into stat from dual;
    dbms_output.put_line(stat);
    end;
    

    Try to replace the CONSTRAINT by REF_CONSTRAINT

    Thnks to metalink

    Published by: Maran Viswarayar Sep 12, 2008 17:26

  • How to call and parse the SOAP WSDL service in Swift 2.0 to Xcode 7.1

    I'm new to the SOAP and I don't know how to call SOAP Web service and parse XML. I also tried to try to Google.And all of the resources that I had was outdated. Y at - it a tutorial or examples that I can learn? Any help?

    Hello ColayHills,

    It's because SOAP is exceeded. It is based on XML and XML really nasty at that. You have other options or should you use SOAP?

  • How to call a second instance of the same VI?

    Hello

    I have a useful VI dealing with IO operations. To save some time, of what I would call the VI as a second instance do work at the same time. I created a sequence sub with the run option 'Use the new thread' and I called the Vi (a step of the sequence only). Execution time of the VI is about 20 seconds run Durin I called the subsequence and I carried on running my main sequence (parent). Since then 10 seconds to launch the subsequence (in the thread of sepatate I called the same VI as in the thought of subsequence the second instance will be created. However, instead of parallel work of the two instances of the same VI had to wait when mt subsequence end known call the VI th.

    So my question is, as in the topic: how to call a second instance of the VI even at the "same time"?

    Could you please tell me about the best approach to solve the problem?

    Any VI that you want to run in parallel must be paid also re-entrant, including screws.

  • How to call same vi for 4 times in a single vi?

    Hello.. I ve a vi named table 1 d Mult. I need to call this vi four times in another program of vi. The problem I've known is all the four outputs of vi are the same.

    My question is: how to call the same vi number many times?

    Thanks in advance

    Recursive calls in LabVIEW using VI Server

  • How to call windows dialog boxes

    Hello

    I just want to know how to call a windows dialog box, I called below the dialog using VB script and the script is the following lol = msgbox ("Your Message here", 19, "Your title here") and save it as a .vbs file, by changing the number "19" in the script to generate the different dialog box. And I think it is called by the user32.dl of windows.

    So can you please help me to call the dialog even in labview.

    Thank you & best regards

    Samuel J

    System engineer

    CAPTRONIC systems Pvt Ltd

    Bangalore, India.

    See attached VI calling MessageBoxA from user32.dll. Sorry for french labels, comments and the description...

  • How to call the setting menu of the BIOS on HP DV4 1540us netbook?

    Hi all

    How to call the setting menu of the BIOS on HP DV4 1540us netbook?

    F2 does NOT an on-screen BIOS setting.

    Is there another trick?  Or, perhaps, defining the procedure step by step to start the BIOS?

    TIA

    Power on the laptop and all logo HP being displayed, press F10.

  • How to call adobe pdf reader to open the PDF files in your application BB10?

    Hi all

    Can anyone please write an example of cascades showing how to call adobe pdf reader to open PDFs inside my BB10 stunts application?

    Thanks,.

    Mohanad

    This is how to do it:

    https://developer.BlackBerry.com/Cascades/documentation/device_platform/invocation/AdobeReader.html

  • How to call the web service?

    Hello

    I want to know how to call the web service from my application HTML5 & javascript.

    Please help me find this detail as what I can access easily. and I want to access web services online (a method of it) I'm not concered with how background Web service takes place.

    I just want that when you call a web service method, I will return the result.

    Please try this out for a WebService call

    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("get","your url",true);
    xmlhttp.setRequestHeader("Accept","application/json");
    xmlhttp.setRequestHeader("Content-type", "application/json");
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
      if (xmlhttp.status == 200) {
        console.log(xmlhttp.responseText);
      }
     }
    }
    xmlhttp.send();
    

    This will display the result of the invocation of webservice. The url is the application that you deploy and the type can be get/post. If xmlhttp.send (post) takes argument for the display of the data. You can call it by clicking a button in HTML.

  • How to call a function in class library?

    Hi all

    Anyone know how to call a function in a library project?

    I have to call using a resource file in a library of a CLDC project project.

    So I write a simple test library and tried to access a function in my CLDC application.

    I tested with 2 following projects.

    1. a library project: TivitFirm

    Sorry I can't answer this from the point of view of the eclipse, I use JDE.  But I suspect that the approaches are similar, even if the detail is different, so maybe this will help you.

    In JDE, you have two options:

    (a) use a jar

    (b) create a dependent project

    (a) I usually use a jar.  So to do this I have a workspace is the library, I compile this, then in my project that uses it, I add the jar to build settings

    (b) in this case, you have two projects in the space of a job, and you say the main project that it is dependent on the library project.

    I hope this helps.

  • How to call the function cascade BlackBerry

    I begineer in blackberry c ++.

    I do two class is testobject and second in test .i call the onther text function average () and nexttext();

    so please how to call this function.

    // Default empty project template
    #include "TestObect.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    TestObect::TestObect(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        // set created root object as a scene
        app->setScene(root);
    }
    
    void TestObect::test(){
    
        qDebug()<< "****************Naveen";
    }
    

    I insert also declared in the header file.

    Q_INVOKABLE Sub test();

    then I create another test class.

    /*
     * test.cpp
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #include "test.h"
    
    test::test() {
        // TODO Auto-generated constructor stub
    
    }
    
    void test:: nexttest(){
        qDebug()<<"***********Next test*********"
    
    }
    test::~test() {
        // TODO Auto-generated destructor stub
    }
    

    error in the file namespace,

    here in file herder

    the namespace error

    /*
     * test.h
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #ifndef TEST_H_
    #define TEST_H_
    
    class test {
    public:
        test();
        virtual ~test();
         Q_INVOKABLE void nexttest();
    };
    
    #endif /* TEST_H_ */
    

    You have a space between the colon and the n in:

    void test:: nexttest()
    

    Another thiing, if you are using Q_INVOKABLE, you must declare Q_OBJECT in your front header file public:

     


    If you're still having problems, try to clean up the project with Project > clean...

  • How to call this method?

    I wrote this method earlier, but I do not remember how to call it. Can someone help me?

    public class PostReview extends Thread {
        String _url = new String();
    
        public void Submit(String _url) {
            ConnectionFactory connFact = new ConnectionFactory();
            ConnectionDescriptor connDesc;
            connDesc = connFact.getConnection(_url);
            if (connDesc != null) {
                HttpConnection httpConn;
                httpConn = (HttpConnection)connDesc.getConnection();
                try {
                    final int iResponseCode = httpConn.getResponseCode();
                    UiApplication.getUiApplication().invokeLater(new Runnable()
                    {
                    public void run() {
                        //Dialog.alert("Response code: " + Integer.toString(iResponseCode));
                    }
                    });
                } catch (IOException e) {
                    Dialog.alert("Caught IOException: " + e.getMessage());
                }
            }
        }
    }
    

    You can simply call News PostReview.Submit (url). But why the class extends Thread If you aren't actually create or who runs an instance of thread?

  • How to call a second screen?

    I don't know exactly how to call a second display (displays the results of a web service) with some parameters.  I'm starting simple and sending the GPS coordinates of the current location.  I would like to call the service, and then view the name of the first result in the text field.  However, I get the infamous with is not the mistake of blocking event every time that I try to do the setText.  Can someone tell me what I'm doing wrong here?

    class Results extends UiApplication {    public static void main(String[] args) {        Results gbResults = new Results(args[1], args[2]);
    
            gbResults.enterEventDispatcher();    }
    
       private Results(String Latitude, String Longitude) {        pushScreen(new ResultsScreen(Latitude, Longitude));    }}
    
    final class ResultsScreen extends MainScreen{
    
        ResultsScreen(final String Latitude, final String Longitude) {        final LabelField lblResult = new LabelField("Result:", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);        add(lblResult);
    
            UiApplication.getApplication().invokeLater(new Runnable() {            public void run() {                //Call the service and get back [wsresult]                synchronized(UiApplication.getEventLock()) {                    lblResult.setText("Result: " + [wsresult]);                }            }        });    }}
    

    Now, I don't think that I need this class first results statement as in my first screen I call you just this screen like this:

    getUiEngine().pushScreen(new ResultsScreen(String.valueOf(qc.getLatitude()),String.valueOf(qc.getLongitude())));
    

    I think I'm calling and declaring the second screen correctly that the code is certainly get there.  There is just something to do with this setText.  What I need to do kind of the enterEventDispatcher () inside the ResultsScreen class?

    Also, I tried to do just the invokeLater by itself and the synchronize (getEventLock) by itself and kept getting the error each time.  It seems that no matter what I do, it always says that I'm not holding the lock on the event.

    I realized what the problem was.  When I called the getUIengine (.pushScreen), I was outside the event thread and so I had to wrap this call in a getAppLock as well.  When I was debugging before she looked like she came all the way to the setText (I'm sure that was the case somehow) and then wrong so I don't think that the appeal was the cause of the problem.

  • How to call the REST Webservices via native J2ME app.

    Hi, can someone help me how to call REST Webservices via native J2ME app. I don't want to use the HTTP request. Is there a possible way to call via AJAX, if so how? I use only the RIM and the J2ME API. Thank you, joy

    JSON is just the format fo the data returned.  So all you do is make a standard HTTP call, get the data and analyze using JSON.  OS 6.0 includes JSON, but OS 5.0 doesn't work, then you will need to get a JSON library if you want to use in the 5.0 OS.

    You might find them useful:

    http://supportforums.BlackBerry.com/T5/Java-development/JSON-library/m-p/573687

    http://supportforums.BlackBerry.com/T5/Java-development/sample-code-implementing-JSON-in-your-applic...

Maybe you are looking for