Questions tagged [executequery]

Using Java's Statement executeQuery method for getting SQL select results

133 questions
3
votes
1 answer

SQL Server execute procedure as user

I have a stored procedure which loads data into a target table and works fine when run in a session with my AD credentials. When I try to run it in a job (again with my AD details in the Run As option) suddenly the login does not have access to one…
3
votes
1 answer

After an Exception, closing the Connection appears to commit the transaction even though AutoCommit is false

setAutoCommit is false and exception is thrown before closing the connection, but still its committing the transaction. Isn't this is strange behavior? public static void insertEmployee(){ String query1 = "INSERT INTO EMPLOYEE VALUES(80,…
eatSleepCode
  • 4,427
  • 7
  • 44
  • 93
3
votes
1 answer

Calling stored proc with LINQ .ExecuteQuery to return non-mapped fields

I have a stored procedure which returns all the fields of a table plus one, ie: tablename.*,count(suchandsuch) Of course, when executing this via LINQs ExecuteQuery I can get back instances of the table's class in an IEnumerable<>, but I also want…
Matt W
  • 11,753
  • 25
  • 118
  • 215
3
votes
1 answer

MySQL - how to store execute result

I wrote a procedure in mysql, which return a random value from a table. But I have a lot of tables, and I want to use this procedure many times, so I add as procedure parameter name table, from which I want to rand value, which name i will pass to…
Ziva
  • 3,181
  • 15
  • 48
  • 80
3
votes
1 answer

LINQ to SQL(.dbml): how do ExecuteQuery method return DataTable?

var products = db.ExecuteQuery( "SELECT ProductID, ProductName " + "FROM Products " + "WHERE Discontinued = 0 " + "ORDER BY ProductName;" ); above query works fine but is there any way db.ExecuteQuery returns DataTable…
Pritesh
  • 3,208
  • 9
  • 51
  • 70
2
votes
2 answers

Unexpected SQL results: string vs. direct SQL

Working SQL The following code works as expected, returning two columns of data (a row number and a valid value): sql_amounts := ' SELECT row_number() OVER (ORDER BY taken)::integer, avg( amount )::double precision FROM x_function(…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
2
votes
0 answers

Can JDBC statement run execution plan / explain plan?

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()…
ITpeople
  • 29
  • 1
  • 5
2
votes
1 answer

Javascript Waiting for result before continuing

I am new to Javascript and trying to run before I can walk but I have to produce a result so here I am. I thought I had found the answer to this in another question but it did not work for me as expected, below is my script the function of which is…
Derek
  • 41
  • 1
  • 8
2
votes
2 answers

How to cast INT32 to INT during a SQL select through a LINQ data context?

I have the following statement: someList = dc.ExecuteQuery(@"Select Id As ProductId, Name From ivProduct").ToList(); Id in the database is stored as int32, when my Id property of MyCustomType is INT. Is there a way to cast that int32…
user338195
2
votes
1 answer

In maven, how can I execute a SQL if I detect the table structure is missing?

I'm modifying an existing maven2 project and I would like to create the database structure if I notice it is missing. I sort-of know how to do this in ant, I could query the database and if the table is missing I could execute the query. But,…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
2
votes
2 answers

Invalid query: You have an error in your SQL syntax; syntax to use near

I have this problem error and I don't know how to solve it. I know what so many have issues like my issue but I can not orient. Problem: Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server…
Dimas
  • 47
  • 1
  • 9
2
votes
0 answers

PreparedStatement.executeQuery fetches wrong value for some columns

When I execute a query using PreparedStatement.executeQuery() from a Java application I get a resultSet object with wrong values for some of the fields. When I use PLSQL developer then the value looks ok. The field value is 10101010 but in the…
saumil
  • 21
  • 1
2
votes
1 answer

How to manipulate Database.ExecuteSqlCommand() return value?

private int GetId(int userId, int companyId){ string query = String.Format("SELECT Id FROM MyTable WHERE UserId = {0} AND CompanyId = {1}", userId, companyId); return _db.ExecuteSqlCommand(query); } I can run the query via Microsoft's SQL…
James Madison
  • 337
  • 1
  • 4
  • 17
2
votes
1 answer

Postgres run SQL statement from string

I would like to execute a SQL statement based on a string. I have created the SQL statement through a function which returns a string. Can anybody explain how I can execute the statement that is returned? I know that you can't do it in plain SQL, so…
2
votes
2 answers

C# ExecuteQuery null value

I have some code: using (OAZISDBDataContext ctx = new OAZISDBDataContext()) { IEnumerable details = ctx.ExecuteQuery("exec [dbo].[zna_contact] {0}, {1}", …
WtFudgE
  • 5,080
  • 7
  • 47
  • 59
1
2
3
8 9