SSIS Execute SQL Task error - ssis

I'm having an SSIS package which gives the following error when executed :
Error: 0xC002F210 at Execute SQL Task 1, Execute SQL Task: Executing the query "Declare #POID as Varchar(50)
Set #POID = 636268
..." failed with the following error: "Unable to populate result columns for single row result type. The query returned an empty result set.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Execute SQL Task 1
The package has a single Execute SQL task with the properties listed below :
General Properties
Result Set : Single Row
ConnectionType : OLEDB
Connection : Connected to Server
SQLSourceType : Direct Input
SQL Statement :
Declare #POID as Varchar(50)
Set #POID = 0
SELECT DISTINCT BizTalk_POA_HEADER.PONUMBER, FAN_Suppliers.SupplierName, FAN_Company_Details.CompanyName, FAN_Company_Details.[PrimaryEmail], BizTalk_POA_HEADER.[DeliveryDate]
FROM BizTalk_POA_HEADER
INNER JOIN FAN_PO_Details ON BizTalk_POA_HEADER.PONUMBER = FAN_PO_Details.PoNumber
INNER JOIN FAN_PO ON FAN_PO_Details.PurchaseOrderID = FAN_PO.PurchaseOrderID
INNER JOIN FAN_SupplierDetails ON FAN_PO.SupplierDetailsID = FAN_SupplierDetails.SuppliersDetailsID
INNER JOIN FAN_Suppliers ON FAN_SupplierDetails.SupplierID = FAN_Suppliers.SupplierID
INNER JOIN FAN_Company_Details ON FAN_PO.CompanyID = FAN_Company_Details.CompanyDetailsID
WHERE (BizTalk_POA_HEADER.PONUMBER = #POID)**
IsQueryStorePro : False
BypassPrepare : False
Parameter Mapping Properties
None
ResultSet
ResultName Variable Name
0 User:PONUMBER
1 User:StoreName
2 User:StoreEmail
3 User:Supplier
4 User:DeliveryDate
I would appreciate if anybody can help me out of this issue by suggeting where the problem is.
I then changed my query to the following as the above was showing conversion error in SSMS, when I try to include the below in Execute SQL Task the query isn't saved , any reason?
SELECT DISTINCT BizTalk_POA_HEADER.PONUMBER,FAN_Suppliers.SupplierName, FAN_Company_Details.CompanyName,
FAN_Company_Details.[PrimaryEmail], BizTalk_POA_HEADER.[DeliveryDate]
FROM BizTalk_POA_HEADER INNER JOIN
FAN_PO_Details ON CAST(BizTalk_POA_HEADER.PONUMBER AS VARCHAR(128)) = CAST(FAN_PO_Details.PoNumber AS VARCHAR(128)) INNER JOIN
FAN_PO ON FAN_PO_Details.PurchaseOrderID = FAN_PO.PurchaseOrderID INNER JOIN
FAN_SupplierDetails ON FAN_PO.SupplierDetailsID = FAN_SupplierDetails.SuppliersDetailsID INNER JOIN
FAN_Suppliers ON FAN_SupplierDetails.SupplierID = FAN_Suppliers.SupplierID INNER JOIN
FAN_Company_Details ON FAN_PO.CompanyID = FAN_Company_Details.CompanyDetailsID
Thanks in Advance.

If 0 records are returned from your query and you are trying to populate a result set, that is the error you will get. Change your query so it always returns a single result and the error will go away.

Related

syntax error (missing operator) in query expression - Access16

I am getting the following error message when attempting to save or run a SQL query in MS Access 2016:
"Syntax error (missing operator) in query expression 'M.ScheduleKey FROM Actual_Data A'
The Query is:
UPDATE Actual_Data
SET A.ScheduleKey = M.ScheduleKey
FROM Actual_Data A, Match M
WHERE A.ActualKey = M.ActualKey
Both the ScheduleKey & ActualKey fields are text fields.
Any help on resolving this would be greatly appreciated.
You can use this instead:
UPDATE Actual_Data A
INNER JOIN Match M
ON A.ActualKey = M.ActualKey
SET A.ScheduleKey = M.ScheduleKey

How to resolve MS Access SQL UPDATE syntax error

I am trying to type a SQL query in MS Access to update the records in FilesTable.FilePath with the records in Files.FPath, when the FilesTable.FileName Matches a record in Files.FName, but I receive an error:
UPDATE FilesTable
SET FilesTable.[FilePath] = Files.[FPath]
FROM (FilesTable INNER JOIN Files ON (FilesTable.[FileName] = Files.[FName])
WHERE *;
syntax error (missing operator) in query expression 'Files.[FPath]
FROM (FilesTable INNER JOIN Files ON (FilesTable.[FileName] = Files.[FName])
WHERE *;'
I have also tried to add () after Set as well which results in an error as well:
UPDATE FilesTable
SET (FilesTable.[FilePath] = Files.[FPath])
FROM (FilesTable INNER JOIN Files ON (FilesTable.[FileName] = Files.[FName])
WHERE *;
Syntax Error in UPDATE Statement.
Here is how my tables looks like
This is the correct query:
UPDATE FilesTable
INNER JOIN Files ON (FilesTable.FileName = Files.FName)
SET FilesTable.FilePath = Files.FPath

Query that populates a datasheet in MS Access, and MsgBox if no values returned

I'm trying to create a query that can run from a button in MS Access. The SQL query I've created is below:
PARAMETERS CASNUMBER Text ( 255 );
SELECT DISTINCT Chemical.Chemical_Name, Hazard.Hazard_Code, Hazard.Hazard_Text
FROM Chemical, Chemical_Hazard, Hazard
WHERE Chemical.Chemical_Id = Chemical_Hazard.Chemical_Id
and Chemical_Hazard.Hazard_Id = Hazard.Hazard_Id
and [CASNUMBER] = Chemical.CAS
;
How do I make it so that a MsgBox appears when there are no values returned?
I'd recommend join tables using JOIN instead of WHERE. Also you can avoid using parameter, which in most cases requres VBA code for query execution. Just create query without parameter, add CAS to columns list:
SELECT DISTINCT Chemical.Chemical_Name
,Hazard.Hazard_Code
,Hazard.Hazard_Text
,Chemical.CAS
FROM (
Chemical_Hazard INNER JOIN Chemical ON Chemical.Chemical_Id = Chemical_Hazard.Chemical_Id
)
INNER JOIN Hazard ON Chemical_Hazard.Hazard_Id = Hazard.Hazard_Id
And then check for CAS in code:
If DCount("*", "MyQuery", "CAS=" & lngCASNumber) = 0 then
MsgBox "CAS not found"
End If

Execute a join query in Talend Open Studio for data integration

I am new to Talend open studio, I need to execute a MySql update query in a job. So I tried using tMysqlrow component and specified the query in Query field. When I run the job it shows "Lock wait timeout exceeded; try restarting transaction" error.
Here is my SQL query:
UPDATE library_export AS updater INNER JOIN
(SELECT id,(max_sequence_3 - coreTable.Level_3_sequence)+1 AS reverse_sequence_3,
(max_sequence_2 - coreTable.Level_2_sequence)+1 AS reverse_sequence_2,
(max_sequence_1 - coreTable.Level_1_sequence)+1 AS reverse_sequence_1
FROM library_export AS coreTable
LEFT JOIN
(SELECT MAX(Level_3_sequence) AS max_sequence_3,Level_2_id
FROM library_export
GROUP BY Level_2_id) AS level3 ON (coreTable.Level_2_id = level3.Level_2_id)
LEFT JOIN
(SELECT MAX(Level_2_sequence) AS max_sequence_2,Level_1_id
FROM library_export GROUP BY Level_1_id) AS level2 ON (coreTable.Level_1_id = level2.Level_1_id),
(SELECT MAX(Level_1_sequence) AS max_sequence_1
FROM library_export) AS level1) AS updataBy ON (updater.id = updataBy.id)
SET updater.Level_1_new_sequence = updataBy.reverse_sequence_1,
updater.Level_2_new_sequence = updataBy.reverse_sequence_2,
updater.Level_3_new_sequence = updataBy.reverse_sequence_3
Can anybody help me to execute the update query?

Update a single table based on multiple tables - appears to works MySql not ACCESS 2003

Mysql Version Works
UPDATE results SET rCARRIER = (
SELECT cellCarrierName
FROM tblImportedTempTable, user, cellCarrier
WHERE
userEmployeeNumber = tblImportedTempTable.EMPLOYEENUMBER
AND userId = results.rUserId
AND results.rPHONENUMBER = tblImportedTempTable.PHONENUMBER
AND CARRIER = cellCarrierId )
I have written this sql that works fine in MySql(above) and fails in access 2003(below) any suggestions? Is one or both of the 2 nonstandard sql? Does Access hav an admin problem?
Sorry the field and table names are diferent this is the ACCESS version.
Access version
UPDATE tblWorkerPhoneNumber SET tblWorkerPhoneNumber.PhoneCarrier = (
SELECT PhoneCarrierType.CarrierName
FROM tblImportedPhoneCarrier, tblWorkerMaster, PhoneCarrierType
WHERE
tblWorkerMaster.EmployeeNumber = tblImportedPhoneCarrier.Emp
AND tblWorkerMaster.WorkerID = tblWorkerPhoneNumber.WorkerID
AND tblWorkerPhoneNumber.PhoneNumber = tblImportedPhoneCarrier.Cell
AND tblImportedPhoneCarrier.CarrierCode = PhoneCarrierType.CarrierID )
Error Message
Operation must use and updateable query
Thanks
In MS Access, something like this:
UPDATE tblWorkerPhoneNumber
INNER JOIN tblWorkerMaster ON tblWorkerMaster.WorkerID = tblWorkerPhoneNumber.WorkerID
INNER JOIN tblImportedPhoneCarrier ON tblWorkerPhoneNumber.PhoneNumber = tblImportedPhoneCarrier.Cell
INNER JOIN PhoneCarrierType ON tblImportedPhoneCarrier.CarrierCode = PhoneCarrierType.CarrierID
SET tblWorkerPhoneNumber.PhoneCarrier = PhoneCarrierType.CarrierName
WHERE tblWorkerMaster.EmployeeNumber = tblImportedPhoneCarrier.Emp
(Might need to change the join conditions; I'm not familiar with your schema)