How to execute sets of DDL Statements in 1 command?

Hi All,
I've been trying to look for a way to run a set of DDL statements. I normally have text files with DDL Statements on it. So what I do is load the contents of this text file into a Textbox and then set the Textbox.Text as the CommandText of my command object. Unfortunately I get errors.
Here's my code...
    Private Sub btnLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OpenDiag As New OpenFileDialog
        Dim txtReader As StreamReader
        OpenDiag.ShowDialog()
        If OpenDiag.FileName <> "" Then
            txtReader = File.OpenText(OpenDiag.FileName)
            CommandTextBox.Text = txtReader.ReadToEnd
        End If
    End Sub
    Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim myConn As New OracleConnection(My.Settings.ConnectionString)
        Dim myComm As New OracleCommand(CommandTextBox.Text, myConn)
        Try
            myConn.Open()
            myComm.ExecuteNonQuery()
            myConn.Close()
        Catch ex As OracleException
            MessageBox.Show(ex.Code & ": " & ex.Message)
        End Try
    End SubThe errors that I get are
"ORA-00900: Invalid SQL Statement"
- Not sure how I get this but I noticed that if i had remarks/comments in my text file, this is the error that i get. Although i don't get this error if i execute in SQL Plus.
"ORA-00911: Invalid Character"
- after removing the remarks/comments, i get this error. i tried removing the semi-colon ";" then it works okay if i'm running 1 DDL statement in my file.. but if i my file contains to DDL statements for example, then i get the this error "ORA-00922: Missing or Invalid Options".
can anyone help me with this?
thanks.

yes. i have BEGIN and END in their corresponding places.
i found out that removing linefeeds and semi-colons somehow fixes the problem for DDL statements. also, if i use a RichTextBox and uses its RichTextBox.LoadFile(filename, RichTextBoxStreamType.PlainText) instead of the File.OpenText(filename), it works fine as well. although its not something i would want. so what i did was to create a PL/SQL Anonymous Block instead. this too works if i use a RichTextBox.LoadFile instead of a textbox. but i'm using these controls to see the contents. eventually i will need to use a variable to store the contents of the file and i'm worried that it won't work with it.
unfortunately it doesn't work when i use a string. i'm guessing because of the linefeeds and semi-colons are still there.

Similar Messages

  • How can I set the United States as my country when opening PSE 10?

    How can I set the United States as my country when opening PSE 10 so I don't have to scroll down every time?

    Why do you have to scroll down every time? You should only see the country window the very first time you launch PSE after installing it.

  • Execute set of ddl scripts in pl/sql

    Hello,
    If I use DBMS_METADATA.GET_DDL and DBMS_METADATA.GET_GRANTED_DDL for a particular user I can get something like this:
    CREATE USER "USERB" IDENTIFIED BY VALUES 'B6C9E444D14CDE5B' DEFAULT TABLESPACE "PROD_TBSP_03" TEMPORARY TABLESPACE "TEMP";
    GRANT "SELECT_CATALOG_ROLE" TO "USERB";
    GRANT "SCHEMA_ROLE" TO "USERB";
    Now, how do I go executing this in pl/sql? The following would fail as execute immediate wouldn't run all of these at the same time:
    DECLARE
    v_str VARCHAR2(4000 BYTE);
    BEGIN
    v_str := 'CREATE USER "USERB" IDENTIFIED BY VALUES ''B6C9E444D14CDE5B'' DEFAULT TABLESPACE "PROD_TBSP_03" TEMPORARY TABLESPACE "TEMP";'
    || chr(10) || 'GRANT "SELECT_CATALOG_ROLE" TO "USERB";'
    || chr(10) || 'GRANT "SCHEMA_ROLE" TO "USERB";';
    dbms_output.put_line(v_str);
    EXECUTE IMMEDIATE v_str;
    EXCEPTION
    WHEN OTHERS
    THEN
    dbms_output.put_line('Exception encountered: '||SQLCODE||' - Error message: '||substr(SQLERRM,1,200));
    END;
    Any ideas on how to run it?
    Thanks guys
    Leo
    v$version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Edited by: leocoppens on May 22, 2013 2:43 PM

    DECLARE
    v_str VARCHAR2(4000 BYTE);
    BEGIN
    v_str := 'CREATE USER "USERB" IDENTIFIED BY VALUES ''B6C9E444D14CDE5B'' DEFAULT TABLESPACE "PROD_TBSP_03" TEMPORARY TABLESPACE "TEMP";';
    dbms_output.put_line(v_str);
    EXECUTE IMMEDIATE v_str;
    v_str := 'GRANT "SELECT_CATALOG_ROLE" TO "USERB";'
    dbms_output.put_line(v_str);
    EXECUTE IMMEDIATE v_str;
    v_str := 'GRANT "SCHEMA_ROLE" TO "USERB";';
    dbms_output.put_line(v_str);
    EXECUTE IMMEDIATE v_str;
    END;
    /You should make sure you really want to do this, though. I don't think this style (ie dynamically running DBA tasks) is a generally accepted "good" practice :)
    It's prone to a lot of issues - security and otherwise. Caution is advised.

  • How can i set a adresse/state Kosovo on my contacts?

    Hallo,
    ich versuche bei "meine kontakte" die Adresse zu bearbeiten, ist aber nicht möglich weil Kosovo gar nicht auf der Liste steht. Ich hätte es gern die adresse gehabt das wenn ich Navigon oder auch andere apps benutze direkt über Kontakte die Adresse entziehen kann, so muss ich die Adresse manuell eintippen die ich dann merken oder per hand irgendwo schreiben müsste, was nicht der Sinn der Apple Entwicklung ist. Es mag sein das das eine Kleinichkeit für Apple ist aber ich würde mich freuen wenn ich auch die gleiche Vorteile wie andere User habe.
    MfG

    Hi Taffy078
    Hope these answers help with some of the issues you have raised.
    How do people save a link / bookmark to the new login process?
    For easy access to BT Yahoo mail through the BT login page, people can save or bookmark the BT.com homepage, They can then access this page and click the email link in the main navigation bar to access the new login page.  Instructions on how to set BT.com as your homepage if they wish can be found here: http://www.bt.com/static/includes/account/portal/
    Why is the experience different on different machines / laptops?
    We’re in the middle of a process of altering the login process for BT Yahoo email and during the next few weeks it’s possible you’ll see both the old and new experience if you use different laptops, computers or devices while this transition happens.  Very soon all access to the BT Yahoo web email clients will be through BT.com
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • How can I set the initial state of the PGCTR0 out pin?

    Hi,
    I have a 6115 board, and I am trying to generate a pulse train on PGCTR0 with an external clock. The external clock signal is connected to PFI1 and the PGCTR0 is gated through PFI0. The PGCTR is reset at the end of each run.
    The problem is that the initial state of the PGCTR out pin changes from run to run, but I'd like it to stay high after reset. Any help is appreciated. THanks.
    feng

    Hi Feng,
    The default output state of your counters should be high depending on your board. If you run a counter application, and the line ends in a low state it will stay low. One way to change the output state is to not only reset the counter but reset the board (see knowledge base linked below). The other way is to treat it like a digital line (see second link below). This is probably the best method. This method should allow you to read the value and change it using a couple software calls. Instead of disabling the counter, I would reset the counter since you just want to reset the state. This method is also a decent workaround because you are resetting the counter anyway. Hope that helps. Have a good day.
    Default State of Counter Output Lines
    on E Series Data Acquisition Devices
    http://digital.ni.com/public.nsf/websearch/008995633E33E47486256B5F00034436?OpenDocument
    Using the General Purpose Counter (GPCTR) on the Data Acquisition (DAQ) Device as a Digital Line http://digital.ni.com/public.nsf/websearch/B8A49A4E33F38AB686256B610061DC6D?OpenDocument
    Ron

  • How to join 2 separate SQL Statements into 1 command

    Hi Everyone,
    I'm pretty new to PL/SQL.. thanks for your help. I'm hoping the answer to this is pretty straight forward.
    I have a report (crystal) that has 1 subreport. The results from the report are exported to excel. I'd like to take this report and include it in another report, however since I've already went 1 sub report down, looks like I need to figure out a way to get this 1 report combined into a SQL Command.
    Is there an easy way to combine the main report and subreport here into 1 SQL Command?
    Main Report SQL Select
    SELECT DISTINCT "ST_WORKORDER_REF"."st_wo_number", "ST_WORKORDER_REF"."gs_guid", "ST_STATION"."st_workorder_ref_guid", "ST_STATION"."gs_guid", "ST_ATTACHED_ASSEMBLIES"."gs_network_feature_guid", "GS_ASSEMBLY_REF"."gs_guid", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid", "GS_ASSEMBLY_DEFAULTS"."gs_assembly_ref_guid", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_quantity", "GS_ASSEMBLY_REF"."gs_assembly_description", "GS_ASSEMBLY_REF"."gs_display_feature_name", "ST_ATTACHED_ASSEMBLIES"."gs_network_feature_name", "ST_ATTACHED_ASSEMBLIES"."st_assembly_action_code", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_date_created", "ST_ATTACHED_ASSEMBLIES"."gs_display_feature_name"
    FROM   ((("gs54025_master"."dbo"."ST_WORKORDER_REF" "ST_WORKORDER_REF" LEFT OUTER JOIN "gsXXXXX"."dbo"."ST_STATION" "ST_STATION" ON "ST_WORKORDER_REF"."gs_guid"="ST_STATION"."st_workorder_ref_guid") LEFT OUTER JOIN "gs54gsXXXXX"."dbo"."ST_ATTACHED_ASSEMBLIES" "ST_ATTACHED_ASSEMBLIES" ON "ST_STATION"."gs_guid"="ST_ATTACHED_ASSEMBLIES"."gs_network_feature_guid") LEFT OUTER JOIN "gsXXXXX"."dbo"."GS_ASSEMBLY_REF" "GS_ASSEMBLY_REF" ON "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid"="GS_ASSEMBLY_REF"."gs_guid") LEFT OUTER JOIN "gsXXXXX"."dbo"."GS_ASSEMBLY_DEFAULTS" "GS_ASSEMBLY_DEFAULTS" ON "GS_ASSEMBLY_REF"."gs_guid"="GS_ASSEMBLY_DEFAULTS"."gs_assembly_ref_guid"
    WHERE  "ST_WORKORDER_REF"."st_wo_number"=N'90295' AND "ST_ATTACHED_ASSEMBLIES"."st_assembly_action_code"=N'C'
    ORDER BY "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid"I want to append the results from the subreport:
    Sub Report SQL Select
    SELECT DISTINCT "ST_WORKORDER_REF"."st_wo_number", "ST_WORKORDER_REF"."gs_guid", "ST_ATTACHED_ASSEMBLIES"."gs_network_feature_guid", "GS_ASSEMBLY_REF"."gs_guid", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid", "GS_ASSEMBLY_DEFAULTS"."gs_assembly_ref_guid", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_quantity", "GS_ASSEMBLY_REF"."gs_assembly_description", "GS_ASSEMBLY_REF"."gs_display_feature_name", "ST_ATTACHED_ASSEMBLIES"."gs_network_feature_name", "ST_ATTACHED_ASSEMBLIES"."st_assembly_action_code", "ST_ATTACHED_ASSEMBLIES"."gs_assembly_date_created", "ST_ATTACHED_ASSEMBLIES"."gs_display_feature_name", "ST_SPAN"."st_workorder_ref_guid"
    FROM   ((("gsXXXXX"."dbo"."ST_WORKORDER_REF" "ST_WORKORDER_REF" INNER JOIN "gsXXXXX"."dbo"."ST_SPAN" "ST_SPAN" ON "ST_WORKORDER_REF"."gs_guid"="ST_SPAN"."st_workorder_ref_guid") INNER JOIN "gsXXXXX"."dbo"."ST_ATTACHED_ASSEMBLIES" "ST_ATTACHED_ASSEMBLIES" ON "ST_SPAN"."gs_guid"="ST_ATTACHED_ASSEMBLIES"."gs_network_feature_guid") LEFT OUTER JOIN "gs54025_master"."dbo"."GS_ASSEMBLY_REF" "GS_ASSEMBLY_REF" ON "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid"="GS_ASSEMBLY_REF"."gs_guid") LEFT OUTER JOIN "gsXXXXX"."dbo"."GS_ASSEMBLY_DEFAULTS" "GS_ASSEMBLY_DEFAULTS" ON "GS_ASSEMBLY_REF"."gs_guid"="GS_ASSEMBLY_DEFAULTS"."gs_assembly_ref_guid"
    WHERE  "ST_WORKORDER_REF"."st_wo_number"=N'90295' AND "ST_ATTACHED_ASSEMBLIES"."st_assembly_action_code"=N'C'
    ORDER BY "ST_ATTACHED_ASSEMBLIES"."gs_assembly_guid"Thanks,
    BTW, I realize the SQL in both are very similar. GS_station and GS_Span both starting points... why I needed the subreport.
    John

    Not being a Crystal Reports developer, it's not obvious to me what "subreport" means in this context.
    What would it mean to you to combine the main report and the subreport? Do you just want to add the rows that the subreport returns to the end of the results returned by the report? If so, is the structure of the two report sets identical (do they select the same number of columns with the same data types)? Or do you want to join the data from the report query to the data from the subreport query? If so, what key(s) relate the rows in one to the rows in the other? Or do you want to do something else?
    It would be exceptionally helpful if you could post the DDL to create your tables (simplified versions if possible), the DML to insert some reasonable sample data, and an explanation of the output you're trying to get from the combined query.
    Justin

  • How to set a third state in a JCheckBox

    Hello
    Does someone know how can I set a third state (for example if the value is null instead of true or false) on a JCheckBox.
    The goal is that I can set this state myself with a click on the checkbox, so the method setEnabled(false) doesn't work.
    Thanks

    How about tinkering with the "enabled" property?
    That is, a 3-state check box is a check box that
    the user can disable/enable by clicking on it.
    I changed the code, assuming that the UI asks the
    model if the control is enabled. It apparently works
    (I'm using 1.3)
    Any comments?
    import java.awt.*;
    import javax.swing.*;
    // A Three State JCheckBox which takes an int via getSelected/setSelected methods
    // The null state is drawn as "disabled"
    // after http://forum.java.sun.com/thread.jsp?forum=57&thread=124056
    public class ThreeCheckBox extends JCheckBox
         ThreeToggleButtonModel theModel = new ThreeToggleButtonModel();
         public ThreeCheckBox(String aString)
              this(aString, 2);
         public ThreeCheckBox(String aString, int v)
              super(aString);
              theModel.setSelected(v);
              setModel(theModel);
         public void paintComponent(Graphics g)
              theModel.beforePaint();          
              super.paintComponent(g);
              theModel.afterPaint();          
         public int getSelected() { return theModel.getSelected(); }
         public void setSelected(int v)
              theModel.setSelected(v);
         class ThreeToggleButtonModel extends JToggleButton.ToggleButtonModel
              private boolean isPaint = false;
              private int theValue = 2;
              public int getSelected() { return theValue; }
              public boolean isEnabled()
                   return isPaint && theValue > 1 ? false : super.isEnabled();
              public void beforePaint() { isPaint = true; }
              public void afterPaint() { isPaint = false; }
              public void setSelected(int v)
                   theValue = v < 0 ? 2 : v;
                   super.setSelected(v == 1);
              public void setSelected(boolean b)
                   theValue = (theValue + 1) % 3;
                   super.setSelected(theValue == 1);

  • How to execute entire result set of multiple sql statements via sp_executesql?

    I have a query that generates multiple insert statements (dynamic sql).  So when I execute this my result set is a table of sql insert statements (one insert statment per row in my source data table).  Like so:
                 Select 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData + ')' from SourceDataTbl
    How can I completely automate this and execute all these sql statements via sp_executesql?
    My plan is to completely automate and execute all this via an SSIS package.
    As always any help is greatly appreciated!
    fyi-  This is a very simple version of what I am trying to do.  My query probably plugs in 20+ values from the SourceDataTbl into each of the sql insert statements.

    Ah, a small error in Visakh's post, which I failed to observe, and then I added one on my own.
    DECLARE @SQL Varchar(max)
    SELECT @SQL =
       (SELECT 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData +
                ')' + char(10) + char(13)
        from SourceDataTbl
        FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
    EXEC sp_executesql @SQL
    Without ", TYPE" FOR XML returns a string when assigned to a variable. The TYPE thing produces a value of the XML data type, so that we can apply the value method and get string out of the XML.
    And why this? Because:
    DECLARE @str nvarchar(MAX)
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''))
    SELECT @str
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
    SELECT @str
    Although the data type is string when , TYPE is not there, it is still XML and characters special to XML are enticised.
    Confused? Don't worry, for what you are doing, this is mumbo-jumbo.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to know which user has executed which ddl statement

    Hi All,
    Last week i faced some problem, like some one has truncated the table , so luckily i have the schema backup so i restored it till the last backup taken.
    but i want to know who has executed this ddl statement.
    i know there are some utilities are avaible with oracle, so please describe me the easiest and quickest way to get this.
    Regards
    Asif

    In order of descending simplicity
    - Use the principle of least privilege to restrict the privileges users have in the database to ensure that they cannot do things like truncating a table
    - Enable auditing of potentially problematic statements. This has to be done before the damage is done, though
    - Create a DDL trigger that logs when users issue DDL. This also must be done before the damage is done.
    - Use LogMiner to go through the archived log files that were generated at the time the table was truncated. This assumes that the database is in ARCHIVELOG mode and that you have the archived logs from last week. Using LogMiner to track down the culprit is also likely to be relatively time-intensive
    Justin

  • How to automate DDL statements in batch or stored procedure?

    I'd like to write a start file or stored procedure to create synonyms for all tables owned by the current user as well as any to which the user has been granted access. However, no DDL statement like create synonyms is allowed in stored procedures. How can I solve this problem?
    I am very new to Oracle, can anyone recommend a site that publishes lots of PL/SQL scripts?

    Phyllis,
    It looks like a problem with permissions, as Narayan Archarya said.
    In order to test your code, I connected as user scott, copied your code, put two hyphens in front of the line that begins with execute immediate, compiled it, set serveroutput on, and executed it as:
    SQL> EXECUTE create_synonyms ('scott')
    It worked properly, displaying:
    cursor is opened.
    stmt_str = CREATE SYNONYM ADDRESSES FOR SCOTT.ADDRESSES
    rowcount = 1
    and continued in this manner, incrementing the row counts and displaying a stmt_str for each table. This confirms that there is no problem with the code. It has got to be a problem with privileges.
    To test the theory that it is a problem with privileges, I connected as system manager and created user abc, granting connect, resource, and create table to abc. I then connected as abc and created a table named abc. I then recompiled the create_synonyms, set serverouput on, and I executed it as:
    SQL> EXECUTE CREATE SYNONYMS ('ABC')
    Once again it worked properly, displaying:
    cursor is opened.
    rowcount = 1
    stmt_str = CREATE SYNONYM ABC FOR ABC.ABC
    rowcount = 1
    end
    PL/SQL procedure succesfully completed.
    I then tried executing it as (while still connected as user abc):
    SQL> EXECUTE create_synonyms ('scott')
    and I got:
    cursor is opened.
    rowcount = 0
    end
    PL/SQL procedure succesfuly completed.
    I tried the reverse, by connecting as user scott and executing as:
    SQL> EXECUTE create_synonyms ('abc')
    and got the same:
    cursor is opened.
    rowcount = 0
    end
    PL/SQL procedure succesfuly completed.
    I then connected as user abc and entered:
    SQL> GRANT SELECT ON ABC TO SCOTT;
    Then I connected as scott, set serveroutput on, and executed again as:
    SQL> EXECUTE create_synonyms ('ABC')
    and it worked:
    cursor is opened.
    rowcount = 1
    stmt_str = CREATE SYNONYM ABC FOR ABC.ABC
    rowcount = 1
    end
    PL/SQL procedure successfully completed.
    So, the conclusion is that there is a problem with privileges, probably related to the user executing the procedure and/or the user creating the procedure not having privileges to the tables created by the user that corresponds to the table_owner parameter passed to the procedure.
    This may not be the whole problem as far as permissions, but it is probably part of it.
    null

  • How to set Query SQL Statement parameter dynamically in Sender JDBCAdpter

    Hi All,
    I have one scenario in which we are using JDBC Sender Adapter.
    Now in this case,we need to set Query SQL Statement with a SELECT statement based on some fields.
    This SQL statement is not constant, it would need to be changed.
    Means sometimes receiver will want to execute SQL statement with these fields and sometimes they will want to execute it with different fields.
    We can create separate channels for each SQL statement but again that is not an optimum solution.
    So ,I am looking out for a way to set these parameters dynamically or set SQL statement at Runtime.
    Can you all please help me to get this?

    Shweta ,
    <i>Sometimes receiver will want to execute SQL statement dynamically</i>....
    How you will get the query dynamically? Ok Let me assume, consider they are sending the query through file, then its definitely possible. But u need BPM and also not sender JDBC receiver adapter instead, receiver JDBC adapter.
    SQL Query File ->BPM>Synchronous send [Fetch data from DB]--->Response -
    >...............
    Do u think the above design will suit's ur case!!!!
    Best regards,
    raj.

  • Executing multiple DDL statements with OracleCommand

    hi..
    im having trouble executing multiple ddl statements with the the oracle command object. i have tried to enclose them within Begin.. End; block but with no use.
    this problem seems to occur only with DDL statements,.. as my DML like update, delete and Inserts seem to work fine when enclosed within the PL /SQL block.
    single DDL statements also seem to work fine. so im guessing this has nothing to do with priviledges. any ideas?
    my code as follows
    OracleCommand command = new OracleCommand();
    command.CommandType = CommandType.Text;
    command.CommandText = string.Format(@"{0}",script);
    conn.Open();
    command.Connection = conn;
    command.ExecuteNonQuery();
    the script is read from a file, and looks like this. (note : i have removed any line breaks or any other characters)
    BEGIN ALTER TABLE SYSTEMUSER DISABLE CONSTRAINT FK_USER_CLIENT; ALTER TRIGGER SET_SUBSCRIPTION_SUB_I DISABLE; END;
    this is the error i get.
    Oracle.DataAccess.Client.OracleException: ORA-06550: line 1, column 7:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe.

    If I'm not mistaken, we're not allowed to issue DDL inside anonymoue block (or stored procedure) since DDL has implicit commit in it. But you still can execute DDL using EXECUTE IMMEDIATE or using DBMS_SQL package. Try changing your CommandText like this,
    BEGIN
       EXECUTE IMMEDIATE 'ALTER TABLE SYSTEMUSER DISABLE CONSTRAINT FK_USER_CLIENT';
       EXECUTE IMMEDIATE 'ALTER TRIGGER SET_SUBSCRIPTION_SUB_I DISABLE';
    END;Hope this helps,
    [Nur Hidayat|http://nur-hidayat.net/]

  • Executing a DDL statement from java code

    Hi all,
    this is code from jdev11.1.1.3 version. I am trying to execute a DDL statement in oracle db from java code, but "ORA-00900: invalid SQL statement" error is coming.
    I am trying to create a table in same schema in same db by using 'Copy' command.
    Same DDL command is executing from sql command prompt & table is being created. Plz help me , as how to do from java?
            public String cmb_action() {
            // Add event code here...
            try {
                //getting source db connection
                InitialContext initialContext = new InitialContext();
                DataSource ds = (DataSource) initialContext.lookup("java:comp/env/jdbc/SourceConnDS");
                Connection sourceconn = ds.getConnection();
                sourceconn.setAutoCommit(false);
                String sql = "Copy from myschema/mypass@DB insert t_dept using select * from dept;"                       
                Statement stat = sourceconn.createStatement();
                stat.executeUpdate(sql);
                sourceconn.commit();
                System.out.println("done");
              catch (Exception ne) {
                // TODO: Add catch code
                ne.printStackTrace();
            return null;
        }

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

  • How to execute multiple sql statements in parallel ?

    Hi There,
    I have 10 stored procedures, each one will take approximately 5 seconds to run individually.
    Now I need to combine the results of these 10 stored procedures into single result set.
    So I have created one more stored procedure "proc_AllSPs" to get the single result set.
    The procedure "proc_AllSPs" is taking one minute to run because all the procedures inside the "proc_AllSPs" are running
    one after the other and taking 5 seconds each.
    If there is any other way that all the procedures run parallelly, then the procedure "proc_AllSPs" can run in 5 seconds time.
    Sorry if I am not being elaborated.
    PLease get back to me if any piece of information is needed.
    Any kind of help is truly thankful.
    Thanks,
    SequelBug

    Could you tell me how to execute two stored procedures or two sql statements in parallel
    For eg:
    First procedure name is proc_sp1 which takes 1 minute to run
    Second procedure name is proc_sp2 which takes 1 minute to run
    I want to accomplish the below query in 1 minute by executing statement1 and statement2 parallelly.
    go
    select * from openrowswt('sqloledb','server','exec proc_sp1')    --statement1
    union
    select * from openrowset('sqloledb','server','exec proc_sp2')     --statement2
    go
    OR
    go
    Select * into #Temp1  from openrowswt('sqloledb','server','exec proc_sp1') --statement1
    select * into #Temp2 from openrowset('sqloledb','server','exec proc_sp2') --statement2
    Select * from #Temp1
    UNION ALL
    Select * from #Temp2
    go
    Thanks,
    SequelBug

  • How to set Background Activity state as error

    HI Experts,
                    In case of foregruond activities,i know we can make the status as ' in progress' by exit_cancelled.What I want to do is,in case of background activity, if some error comes,i should be able to generate some sort of message, seeing which administrator can come to know that there is some problem.If I use exit_cancelled ,that doesnt solve the purpose.I think something should be there but I'm totally unaware.Please help me know how is that done .

    Hello Vivek,
    position your cursor in the object builder on the method declaration; then push the button "Exception".
    Declare an exception 9001 or greater, which is marked as "Application" or "System" error (both of these types will result in a error state of the work item, later on). Choose some useful message id.
    In the implementation of the object's method, use the macro
    exit_return 9001 <var1> <var2> <var3> <var4>.
    If you're not using any variables, use SPACE.
    Instead of setting the error state for a work item immediatly, you could also set the exception type to "temporary". If you do so, the workflow runtime system will re-execute the work item 3 times after every 20 minutes (if you're using the SAP standard settings). Only after the third exception the work item will be set to error state.
    Best wishes,
    Florin

Maybe you are looking for

  • Count Of each char in a String(Column)

    Hi, I have on column which stores any string. I need count of each alphabet, repeated how many times. For Ex: If a column has value "ORACLE TECHNOLOGY", O is repeated 2 times, R occurs 1 time, E is repeated 2 time etc., Please send the SQL Query for

  • Light framework difference in source code

    Hello Portal gurus -- We have many users accessing our Portal from home (and using a dial-up connection) so we are experimenting with the Light Framework to reduce the load time.  However, when we test with a dial-up connection, it's difficult for us

  • NEED help connecting

    I have a g4 powerbook and i cant connect to the internet everytime i put in my ethernet cable there is no light on the jack on the power book and i am wondering a hoping can i get online with the wireless card that is in the power book please help!!!

  • Can't open itunes, PLEASE HELP!

    When I try to open my iTunes this is the message that I get. I have been having horrible times with this program. I haven't been able to get it to work at all and have tried everything. I also haven't been getting responses for help. Please help me.

  • Bookmarking in Captivate 7

    I know, to some extent, boomarking depends on the LMS and/or browser, but I'm trying to determine how to best set this course up for my customer. They want it so that the user can leave at any time and come back to that exact page. In previous versio