executequery

execute result of select statement

淺唱寂寞╮ 提交于 2021-02-18 10:20:10
问题 How can I execute the results of my select query. The query below gives me some SQL statements back as result. I want to execute does statements, how to do this? All this is executed in SQL Sever Management Studio. Query: SELECT 'UPDATE Rolecopy SET PartofFT = ''' + R2.PlayedbyOT + ''', OriginalOT = ''' + R.PlayedbyOT + ''' WHERE RoleNo = ' + CAST(R.RoleNo AS VARCHAR) + CHAR(13) FROM Role R INNER JOIN Role R2 ON R.PartofFT = R2.PartofFT AND R.RoleNo <> R2.RoleNo WHERE EXISTS ( SELECT PG

JDBC - SQLITE Select to variable

吃可爱长大的小学妹 提交于 2021-02-05 11:13:45
问题 I am trying to run a query / select statement and save it in a variable. I know how to get something specific from a specific column but not from counting rows. This is working as I getting MYID specifically. ResultSet MYIDrs = stmtCFG.executeQuery( "SELECT rowid, MYID from MYINDEX order by rowid desc limit 1;" ); MYID = MYIDrs.getString("MYID"); Now I am trying to count the rows that works in SQLite client but not in the jdbc as I can't figure out what to request. this is what I have but is

SQL Server execute procedure as user

十年热恋 提交于 2020-01-24 09:42:09
问题 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 of the DB's. I used EXEC SP1 Which worked fine. I used (to emulate running the stored procedure in a job) EXECUTE AS user = 'Domain\JDoe' EXECUTE SP1 REVERT Which failed. Why does the stored procedure fail when running with the same credentials

SQL Server execute procedure as user

一曲冷凌霜 提交于 2020-01-24 09:42:09
问题 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 of the DB's. I used EXEC SP1 Which worked fine. I used (to emulate running the stored procedure in a job) EXECUTE AS user = 'Domain\JDoe' EXECUTE SP1 REVERT Which failed. Why does the stored procedure fail when running with the same credentials

Is COMMIT required after every EXECUTE IMMEDIATE?

风格不统一 提交于 2020-01-13 09:12:11
问题 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? 回答1: The only times that you're really forced to commit, other thasn at the end of a business

Is COMMIT required after every EXECUTE IMMEDIATE?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 09:11:05
问题 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? 回答1: The only times that you're really forced to commit, other thasn at the end of a business

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

纵然是瞬间 提交于 2020-01-10 02:06:11
问题 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,

Avoid Parameter Binding When Executing Query with SQLAlchemy

时光怂恿深爱的人放手 提交于 2020-01-03 16:23:15
问题 I am using SQLALchemy to execute queries on Teradata. One of the queries I execute is a DDL statement to replace a stored procedure: REPLACE PROCEDURE DEV_MIGRATION_TOOL.UNIT_TEST_NEW_STORED_PROCEDURE() UNIT_TEST_NEW_STORED_PROCEDURE: BEGIN DECLARE V_VAR VARCHAR(50); SELECT 'Hello World!' INTO :V_VAR; END; This SQL statement is assigned to a variable query and is executed by SQLALchemy with the session execute method: def execute_sql_statement(self, query): """Generic method to execute a SQL

Getting TDS driver - java.lang.NullPointerException. this exception is not consistent

核能气质少年 提交于 2020-01-03 06:46:14
问题 I am getting exception when a method is called from 3 or 4 threads. This method get a DataBase connection inside method and populate some values from DB and then connection (connection, resultset and prepareStatement) getting closed properly inside method only. Still getting exception. Thread_1 - abc() method called. connection opened and closed inside method. Thread_2 - abc() method called. connection opened and closed inside method. Thread_3 - abc() method called. connection opened and

JDBC executeQuery() returning both ResultSet and output params

家住魔仙堡 提交于 2020-01-03 03:15:59
问题 I am calling one sp with few out params and as per my requirement,I need to use ResultSet on some condition and out params on other conditions. But using executeQuery(), I am getting, JZ0R0: ResultSet has already been closed error.(I am using Sybase 15) Here is the example: Connection conn = ~~; CallableStatement cstmt = conn.prepareCall("{call my_sp(?)"); cstmt.registerOutParameter(1,java.sql.Types.INTEGER); ResultSet rs = cstmt.executeQuery(); If i try to do, below code now, int res = cstmt