ADF triggered ADL jobs failing with syntax error - azure-data-lake

I am trying to run a job that runs successfully from within Visual Studio. I'd like to run this in my ADF pipeline but the job fails with a syntax error.
ERRORID: E_CSC_USER_SYNTAXERROR
SEVERITY: Error
COMPONENT: CSC
SOURCE: USER
MESSAGE:
syntax error. Expected one of: '[' end-of-file ALTER COMBINE CREATE DEPLOY DROP EXTRACT IF INSERT OUTPUT PROCESS REDUCE REFERENCE RESOURCE SELECT TABLE TRUNCATE UPDATE USE USING VIEW identifier quoted-identifier variable ';' '('
DETAILS:
at token [], line 2
near the ###:
**************
DECLARE #outSlice string = "somepath.csv";
### USE DATABASE myDB;
//LOCAL
//DECLARE #root string = #"some local path";
//CLOUD
//DECLARE #root string = "adl://storeuri";
DECLARE #root string = "wasb://container#account/";
//RUN MODE 0
//DECLARE #var2 int = 1;
//DECLARE #var1 int = 1;
DECLARE #path1 string = #root + #"path1/xyz.csv";
EDIT:I tried it both with USE DATABASE statement and I commented it out like shown above;### appears in the exact same location in either cases.
EDIT2: Added consecutive lines of code per request from #michael-rys
Later in the script the parameter #outSlice is used in an output statement like
OUTPUT #dataset
TO #outSlice
USING Outputters.Csv();
The parameter is determined within a pipeline activity. Snippet below:
"type": "DataLakeAnalyticsU-SQL",
"typeProperties": {
"scriptPath": "script.usql",
"scriptLinkedService": "storageXYX",
"degreeOfParallelism": 2,
"priority": 0,
"parameters": {
"outSlice": "$$Text.Format('/Output/{0:yyyy}/{0:MM}/{0:dd}/{0:HH}/somefile.csv',SliceStart)"
}

Per off-line conversation with Michael, I removed the BOM from the script file and the ADF job ran successfully. If you are using Visual Studio, go to File->Advanced Save Options. In my case, I had to choose UTF-8 without the signature to remove BOM. Thanks again #michael-rys!

Related

SSIS package precedence Constraint not working for multiple expressions

I have a SSIS package in which we want to see if the DataLoadStatusID == 2 then go to the path that copies the file and deletes from the initial import folder. This part works as expected.
And if we load the same file again, due to duplicate values the DataLoadStatusID !=2, then go to the path where the file does not get copied or deleted. The file should remain in the initial import folder.** This is not working when I re-load the same file the DataLoadStatusID !=2 does not work.**
AND
I tired changing the Result Set to Single Row
Set the Result Set to DataLoadStatusID
Set the Parameter. One thing to note is that the DataLoadId is the only parameter setup in the stored procedure. But the DataLoadStatusId is setup as a variable in the SSIS package only. DataLoadStatusID is not setup as a parameter in the Stored Porcedure. But we have a update statement in the stored procedure.
-- If there were validation errors (not just warnings, mark the data load as failed and exit procedure
DECLARE #ErrorCount INT = 0
SELECT #ErrorCount = COUNT(*) from dbo.ClaimLoadValidation where DataLoadId = #DataLoadId and ValidationStatusId = 2
IF (#ErrorCount > 0)
BEGIN
UPDATE dbo.DataLoad set DataLoadStatusId = 3 where DataLoadId = #DataLoadId
RETURN
END
-- If everything worked, mark record as successful
UPDATE dbo.DataLoad set DataLoadStatusId = 2 where DataLoadId = #DataLoadId
Once I run the package it gives me below error:
"[Execute SQL Task] Error: Executing the query "execute uspLoadClaimHartford ?" failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly."
Are you sure the DataLoadStatus variable is != 2. Maybe put a breakpoint and watch on it to check it

Unable to pass a variable value to a stored procedure in ssis

When executing an SSIS package, the following error appears:
[OLE DB Source [83]] Error: The SQL command requires a parameter named
"#Sales_person", which is not found in the parameter mapping.
[SSIS.Pipeline] Error: OLE DB Source failed the pre-execute phase and
returned error code 0xC0207014.
Below is the screenshot of my OLE DB Source editor
I do see Param direction tab in Set Query parameters, how is that used? In my case will I be using Input or Output or InputOutput
After searching i didn't find a solution for this issue that worked for me. Ther are many suggestions like adding SET NOCOUNT ON before the execute command. Below some related links:
http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx
http://www.sqlservercentral.com/articles/Data+Flow+Task+(SSIS)/117370/
http://www.ssistalk.com/2007/10/10/ssis-stored-procedures-and-the-ole-db-source/
You can do a workaround
Declare a SSIS variable (assuming #[User::Query])
Set #[User::Query] property EvaluateAsExpression = True and use the following expression
"EXEC [dbo].[GetDales_Person_data] " + #[User::Sales]
if #[User::Sales] is a string use the following
"EXEC [dbo].[GetDales_Person_data] '" + #[User::Sales] + "'"
Then In OLEDB Source use SQL Command from variable and select #[User::Query]
The problem is with the mapping. See image and source below to make corrections, you should set it to:
Exec [dbo].[GetSales_Person_Data] #Sales_person = ?
Source - geek with blogs
There seems to be a problem with mapping parameters directly into the EXEC statement.
One way you can get around this is to use:
DECLARE #SalesPerson int = ? -- or whatever datatype
EXEC [dbo].[GetSales_Person_Data] #SalesPerson

Runtime error with no apparent cause

I'm working with files in free pascal and I'm trying to open a file, but if it doesn't exists then I create it.
This is my code:
program messages;
const PATH_ = 'data/messages/';
type messageFields =
record
date : String
; viewed : Boolean
; text : String
; sender : String [ 8 ]
end
; messagesFile = file of messageFields
;
procedure openMessagesFile ( var _file: messagesFile; _fileName: String; var error: Boolean );
begin
error := false;
assign ( _file, PATH_+_fileName );
{$I-}
reset ( _file );
{$I+}
if ( ioResult <> 0 ) then
error := true;
end;
var _file: messagesFile
; fileName: String
; error: boolean;
begin
readln(filename);
openMessageFile(_file, filename, error);
if ( error ) then
rewrite(_file);
end.
The first time that I execute the program, since the file doesn't exists, throw me an exception.
The second time, works fine!
This is the exception:
An unhandled exception occurred at $00401759 :
EInOutError : Access denied
Have you reproduced this error with the exact code you've posted and I really can't see it causing the error you're getting. I cannot reproduce it and since you haven't included uses SysUtils you should get Runtime error 5 instead of EInOutError.
One thing that's terribly wrong with your code is that you're not closing the file after opening/creating it (although OS usually cleans it up after program finishes). Given this and the fact that you're getting EInOutError instead of Runtime error 5 I believe that your (real, bigger) program keeps the file open after creating it and trying to open it later, but fails since the file is already opened. The second time you run the program the file is already created so it's only opened once (for reading).
The code is a bit atypical, but Windows is known to keep fleeting locks on files for a few seconds even after they are closed and Dos originating code like this might suffer from that.
Maybe using FPC's FileExist() directly works better (IIRC on windows it is findfirst based, and not createfile based)

Yii CDbException.. invalid input syntax for integer: "1,075"

I started receiving this error from a production site since this morning and I'm wondering why I don't get the same in UAT or the developer environment..
Is any one familiar with an error like this ?
CDbException
Description
CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "1,076"
Source File
C:\inetpub\wwwroot\framework1.0\db\CDbCommand.php(372)
00360: }
00361:
00362: if($this->_connection->enableProfiling)
00363: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00364:
00365: return $result;
00366: }
00367: catch(Exception $e)
00368: {
00369: if($this->_connection->enableProfiling)
00370: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00371: Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00372: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00373: array('{error}'=>$e->getMessage())));
00374: }
00375: }
00376: }
Attached a screenshot too.. the application is based on yii framework and postgress database.
Quick reply is highly appreciated.
The issue was actually because used number_format() function to a primary key and later in a code section it inputs the formatted number to search query.. i.e select * from user where id = 1,075 (instead of id = 1075)
Changing the number_format() function to apply only on selected areas worked.

Paramaterising SQL in SSIS

I'm trying to paramaterize some queries in SSIS. After some reading, it sounds like my best option is to create one variable that contains my base sql, another that contains my criteria and a final variable that is evaluated as an expression that includes both of these. I want to end up with an SQL query that is effectively
UPDATE mytable set something='bar' where something_else='foo'
So my first two variables have the scope of my package and are as follows:
Name: BaseSQL
Data Type: String
Value: UPDATE mytable set something = 'bar' where something_else =
Name: MyVariable
Data Type: String
Value: foo
My third variable has a scope of the data flow task where I want to use this SQL and is as follows:
Name: SQLQuery
Data Type: String
Value: #[User::BaseSQL] + "'" + #[User::MyVariable] + "'"
EvaluateAsExpression: True
In the OLE DB Source, I then choose my connection and 'SQL command from variable' and select User::SQLQuery from the dropdown box. The Variable Value window then displays the following:
#[User::BaseSQL] + "'" + #[User::MyVariable] + "'"
This is as desired, and would provide the output I want from my DB.
The variable name dropdown also contains User::BaseSQL and User::MyVariable so I believe that my namespaces are correct.
However, when I then click preview, I get the following error when configuring an OLE DB Source (using SQL command from variable):
TITLE: Microsoft Visual Studio
Error at Set runtime in DB [Set runtime in myDb DB [1]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80040E14 Description: "Must declare the scalar variable "#".".
(Microsoft Visual Studio)
Can anyone advise what I'm missing or how I can resolve this please ?
Thanks in advance!
I had a similar issue.
It seems to be that the designer wants something at design time.
I was getting the error when i tried to click OK on the oleDBSource task after choosing a variable name.
I had a similar situation where the where clause logic was a bit involved and required a script task to assign its value.
This is what things looked like at design time.
#basesql = "select from mytable where "
#where = empty string
#fullsql = #basesql + #where
i was getting the E14 error you mentioned above.
by changing the design time value of #where to something silly, the oleDBSource task got what it wanted and let me use the variable.
#where = " value1 is null and value2 = 'easteregg' "
Related issue, to even get the thing to work, i had to start out by putting a basic select stmt into the sql command so it could go get source columns.
It makes sense, but that step took me and google a while to figure out.
You should set the Expression property of SQLQuery, instead of the Value property. If you do it correctly, the Variable Value window should show you the result of the expression:
UPDATE mytable set something = 'bar' where something_else = 'foo'
I would create a script task and concatenate the strings into one variable and use that as your source:
Dts.Variables["SQLQuery"].Value = Dts.Variables["BaseSQL"].Value.ToString() +
Dts.Variables["MyVariable"].Value.ToString();
Then, in the advanced properties under the component properties tab, you need to change the ValidateExternalMetadad property to False so SSIS will not try to prevalidate your sql query in your variable which would give you a run time error. Just created a simple package and that seemed to work. Hope this helps.
-Ryan