executequery

Java - Stop executequery() after some period

♀尐吖头ヾ 提交于 2019-12-24 02:13:35
问题 I have an SQL query executed by: ResultSet resultSet = preparedStatement.executeQuery(); while( resultSet.next() ){ // do some stuff } Is there a way to stop the execution and do some code after let's say 2 minutes of execution? Thanks 回答1: You can set a timeout on executing a query. SQLException will be thrown if the query doesn't complete in time and times out: preparedstatement.setQueryTimeout(seconds); ResultSet resultSet = preparedStatement.executeQuery(); while( resultSet.next() ){ //

what is the difference between these two exection commands in c#

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 02:58:17
问题 Do you know the difference between these two conditions? 1 if(reader.hasrows()) { while(reader.read()) { } } 2 while(reader.read()) { if(reader.hasrows()) { } } 回答1: Doing if/while or while/if is not necessary, since "while(reader.read())" will only return true when the reader has rows "hasrows()" and has a row to read "read()". The extra nesting has no value. 来源: https://stackoverflow.com/questions/3098572/what-is-the-difference-between-these-two-exection-commands-in-c-sharp

C# ExecuteQuery null value

拥有回忆 提交于 2019-12-08 01:32:18
问题 I have some code: using (OAZISDBDataContext ctx = new OAZISDBDataContext()) { IEnumerable<DBContactDetail> details = ctx.ExecuteQuery<DBContactDetail>("exec [dbo].[zna_contact] {0}, {1}", "test", "19601023", } However I also want to be able to pass empty values to the stored procedure so it just doesn't use them. Now with strings this is easy, I can just pass String.Empty and it will work. However if I want to pass empty dates this is a problem. I obviously tried: using (OAZISDBDataContext

C# ExecuteQuery null value

拥有回忆 提交于 2019-12-06 06:55:21
I have some code: using (OAZISDBDataContext ctx = new OAZISDBDataContext()) { IEnumerable<DBContactDetail> details = ctx.ExecuteQuery<DBContactDetail>("exec [dbo].[zna_contact] {0}, {1}", "test", "19601023", } However I also want to be able to pass empty values to the stored procedure so it just doesn't use them. Now with strings this is easy, I can just pass String.Empty and it will work. However if I want to pass empty dates this is a problem. I obviously tried: using (OAZISDBDataContext ctx = new OAZISDBDataContext()) { IEnumerable<DBContactDetail> details = ctx.ExecuteQuery<DBContactDetail

Is COMMIT required after every EXECUTE IMMEDIATE?

一世执手 提交于 2019-12-05 05:24:43
I have multiple EXECUTE IMMEDIATE commands within one oracle procedure. EXECUTE IMMEDIATE 'DELETE FROM tbl1'; EXECUTE IMMEDIATE 'INSERT INTO tbl1...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl3'; EXECUTE IMMEDIATE 'INSERT INTO tbl3 ...'; COMMIT; EXECUTE IMMEDIATE 'DELETE FROM tbl4'; EXECUTE IMMEDIATE 'INSERT INTO tbl4 ...'; COMMIT; Do I need all of these COMMIT, or just at the end of the procedure? The only times that you're really forced to commit, other thasn at the end of a business transaction, are: When executing DDL: the DDL execution is wrapped in a pair of implicit commits. After

Can JDBC statement run execution plan / explain plan?

拥有回忆 提交于 2019-12-01 14:32:00
Can JDBC statement run explain plan on query string? The code throws SQL exception Error message: Incorrect syntax near the keyword 'plan'. Stacktrace is null I just copy from internet of using stmt.execute. However, it seems that stmt.execute() only Returns true if the first result is a ResultSet object; false if it is an update count or there are no results conn = getEntityManager().unwrap(java.sql.Connection.class); stmt = conn.createStatement(); stmt.execute("explain plan for SELECT 1 from Dual"); // throws sql exception rs = stmt.executeQuery("select plan_table_output from table(dbms

Can JDBC statement run execution plan / explain plan?

戏子无情 提交于 2019-12-01 13:02:35
问题 Can JDBC statement run explain plan on query string? The code throws SQL exception Error message: Incorrect syntax near the keyword 'plan'. Stacktrace is null I just copy from internet of using stmt.execute. However, it seems that stmt.execute() only Returns true if the first result is a ResultSet object; false if it is an update count or there are no results conn = getEntityManager().unwrap(java.sql.Connection.class); stmt = conn.createStatement(); stmt.execute("explain plan for SELECT 1

How to work with objects of unknown type returned from DataContext.ExecuteQuery

喜夏-厌秋 提交于 2019-11-29 05:06:31
So, with the advent of the dynamic keyword in C# 4.0 I am hoping I can find a better solution to the problem of dealing with types returned by DataContext.ExecuteQuery when arbitrary columns are selected. In the past I have either created a new type to hold the result of such a query or used the method described in this SO post . So, now that I am able to work on a new project running under .NET 4.0, I looked into using a dynamic type to accomplish the same thing in a less painful manner. So, I gave this a shot: var result = _db.ExecuteQuery<dynamic>( "SELECT CustomerID,City FROM Customers",

Must declare the scalar variable

二次信任 提交于 2019-11-27 06:38:50
问题 I wrote this SQL in a stored procedure but not working, declare @tableName varchar(max) = 'TblTest' declare @col1Name varchar(max) = 'VALUE1' declare @col2Name varchar(max) = 'VALUE2' declare @value1 varchar(max) declare @value2 varchar(200) execute('Select TOP 1 @value1='+@col1Name+', @value2='+@col2Name+' From '+ @tableName +' Where ID = 61') select @value1 execute('Select TOP 1 @value1=VALUE1, @value2=VALUE2 From TblTest Where ID = 61') This SQL throws this error: Must declare the scalar