0

Good morning.

I am making a function that connects to Oracle from JDBC and executes a query.

The number of query statements to be executed is about 50.

I looked for several examples, but most of them are examples that execute only one, and even this is only executed by putting the query in a variable.

I think it is impossible to put all 50 queries in a variable.

Among these, there is an option called allowMultiQueries=true in mysql, but it does not appear to be in oracle.

';', which means the end of the query syntax. Is there any other way to perform a multi-line query other than parsing based on?

  • Are these "query statements" queries as in `select` statements? Or are they other types of DML? Are they the same query with different sets of bind variables? Or 50 completely different `select` statements? – Justin Cave May 26 '21 at 03:01
  • @JustinCave This is a query composed of Create and Alter statements. –  May 26 '21 at 03:05
  • 1
    OK. So if it's DDL, presumably it's only ever executed once, right? And no data is coming back. It seems odd to be concerned about 50 extra network round-trips in a process that is run once at install time-- it would almost certainly make more sense to just run the DDL statements one at a time. You could make an anonymous PL/SQL block that used `execute immediate` statements to execute all 50 statements with a single round-trip but that's a whole lot of effort to save a few milliseconds of installation time. – Justin Cave May 26 '21 at 03:08
  • @JustinCave Umm... So, can you tell what to do? I think PL/SQL is difficult (I don't know about this). simply ; Should I parse based on ?? –  May 26 '21 at 03:13
  • I'm not sure what you are trying to parse. If you have a single script file that you can't manually separate into the 50 separate DDL statements you want to run at install time, can you just invoke `SQL*Plus` and have it connect to the database and run the script? I can't think of a reason that I'd want a .Net application trying to parse a script with many different statements that aren't known at compile time in order to install the tables the application would need. – Justin Cave May 26 '21 at 03:36
  • @JustinCave Oh, there was a lot of lack of explanation. When the user inputs jdbc access information in CLI, it tries to execute the CREATE and ALTER statements already defined at the corresponding address. Until now, the connection operation has been normal, and now you can run the defined query. The query is written in plain text such as .txt. So, I read all the contents with the InputStream, and then the; I tried to split the query based on and put the query to be executed in a list, and execute it in the order of the list. –  May 26 '21 at 03:40
  • I'm still a little lost. Presumably, the JDBC access information isn't the "corresponding address" you're referring to. Unless you're somehow storing a bunch of DDL statements in a CLOB in a database? So where is the .txt file? – Justin Cave May 26 '21 at 04:15

0 Answers0