Hi I have one doubt in ssis
I want delete the data in the target server(postgres) tables data using ssis package.
database: postgres server
Table: emp
in execute sql task, script is: delete from emp and connection used odbc
When I run the executesql task in ssis package
if emp table have data then its working fine and I am getting the error when emp table does not have data.
[Execute SQL Task] Error: Executing the query "delete from emp
usin..." failed with the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
suppose if i run same query in pgadmin tool that time it is not getting any error even though emp table does not have data.
could you please tell me how to avoid this issue in ssis package
In Execute SQL Task component , you should type your delete script in transaction block like below ;
BEGIN;
DELETE FROM yourtable;
COMMIT;
Related
I'm trying to use boto3 redshift-data client to execute transactional SQL for external table (Redshift spectrum) with following statement,
ALTER TABLE schema.table ADD IF NOT EXISTS
PARTITION(key=value)
LOCATION 's3://bucket/prefix';
After submit using execute_statement, I received error "ALTER EXTERNAL TABLE cannot run inside a transaction block".
I tried use VACUUM and COMMIT commands before the statement, but it will just mention that VACUUM or COMMIT cannot run inside a transaction block.
How may I successfully execute such statement?
This has to do with the settings of your bench. You have an open transaction at the start of every statement you run. Just add “END;” before the statement that needs to run outside of a transaction and things should work. Just make sure you launch both commands at the same time from your bench.
Like this:
END; VACUUM;
It seems not quite easy to run transactional SQL through boto3. However, I found a workaround using the redshift_connector library.
import redshift_connector
connection = redshift_connector.connect(
host=host, port=port, database=database, user=user, password=password
)
connection.autocommit = True
connection.cursor.execute(transactional_sql)
connection.autocommit = False
Reference - https://docs.aws.amazon.com/redshift/latest/mgmt/python-connect-examples.html#python-connect-enable-autocommit
when running this query on db2 on DBeaver :
reorg table departments
i got this error (just on external channel):
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;reorg ;JOIN <joined_table>, DRIVER=4.19.49
what does this query mean?
how can I fix the error?
appricicate any help.
Try call sysproc.admin_cmd('reorg table db2inst1.departments')
as you are using DBeaver which is a jdbc application.
If you do not qualify the table name (for example, with db2inst1) then Db2 will assume that the qualifier (schema name) is the same as the userid name you used when connecting to the database.
DBeaver runs SQL statements, but it cannot directly run commands of Db2 - instead, any jdbc app can run Db2-commands indirectly via a stored-procedure that you CALL. The CALL is an SQL statement.
The reorg table is a command, it is not an SQL statement, so it needs to be run via the admin_cmd stored-procedure, or it can be run from the operating system command line (or db2 clp) after connecting.
So if you have db2cmd.exe on MS-Windows, or bash on linux/unix, you can connect to the database, and run commands via the db2 command.
I want delete the data in the target server(postgres) tables data using ssis package.
database : postgres server
Table : emp
in execute sql task :scriptis: delete from emp and connection used odbc
when i run the executesql task in ssis package
if emp table have data then its working fine and i am getting the error when emp table donot have data.
[Execute SQL Task] Error: Executing the query "delete from emp
usin..." failed with the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
suppose if i run same query in pgadmin tool that time it is not getting any error even though emp table donot have data.
how to avoid this issue in ssis package?
If I understand correctly, The DELETE statement contains the connection. I guess you have passed the ODBC connection manager to the Execute SQL Task properties - Connection Type and Connection. Then your SQL script could be just:
DELETE FROM emp;
SSIS - Execute SQL Task Editor
I have Successfully cataloged remote iseries OS/400 DB2 on db2 9.1 ESE.
I am able to connect to database successfully as well but when i run below query or any other query i get following error:-
Query:
select 1 from sysibm.tables
Error:
Encountering SQL30000N Execution failed because of a Distributed Protocol Error that will
not affect the successful execution of subsequent commands or SQL statements:
Reason Code "0x1254"("0200"). SQLSTATE=58008
Pls let me know where i am making mistake..?
I am using the SQL Editor in IBM Data Server Manager to execute queries against DB2. The query in question works fine. However, when I click "Explain" to generate the access plan I get
"Access Plan Graph Cannot Be Generated"
and the diagnostic text is
The SQL statement failed. Explanation: The SQL statement resulted in
an error with SQLCODE: -204 and SQLSTATE: 42704. User response: The
DB2 documentation contains more information about the SQLCODE and how
to resolve the error. "DB2ADMIN.TABLENAME" is an undefined name..
SQLCODE=-204, SQLSTATE=42704, DRIVER=3.66.46
The query is something like
select col1, col2 from tablename where pred=value
Why is it failing? What needs to be changed?
The error code -204 hints at the tablename not being know ("undefined name"). It seems that even though a query runs successfully without using a fully qualified name (schemaname.tablename), the explain functionality in IBM Data Server Manager needs the full name to work.
Changing the query to "select col1, col2 from schemaname.tablename where pred=value" caused the explain to succeed and it shows a nice graph of the access plan.