So here is the error...
An error occurred while saving the
Panel.
System.ArgumentOutOfRangeException:
Index was out of range. Must be
non-negative and less than the size of
the collection. Parameter name: index
at
System.ThrowHelper.ThrowArgumentOutOfRangeException()
at
System.Collections.Generic.List`1.get_Item(Int32
index) at PanelController.Save(Int32
ID, FormCollection FormValues)
During debugging, I checked the parameter it was adding to the save stored proc, and the ID it was adding was 0. Then, when it used this
oDal.Execute("Lending.uspPanelSave")
Item.PanelId = oDal.Parameters("#PanelId").Value
To retrieve the ID to return it, it set it as 1000? Anyone know what the problem is?
Use SqlServer Profiler (in performance tools) to see what is realy send to SQL Server.
Sounds like it's not finding an output parameter called #PanelId in your command object. Was the parameter added and declared with the correct direction? Is the parameter declared properly in the stored procedure?
Related
I have a Stored Procedure activity in my Azure Data Factory pipeline that recalls the following stored procedure on Azure Synapse:
CREATE PROCEDURE schema.procedure_name #portafoglio INT [...]
The activity in configured in order to use a variable (portafoglioElab), previously set in the pipeline:
My problem is how to pass a Null value as input parameter to the procedure via the Azure Data Factory Pipeline in the Store Procedure activity.
I've tried by setting the variable portafoglioElab with null, "null", None, #coalesce(null) but I'm not finding the right value corresponding to sql NULL.
This is the step of the pipeline where I set the variable:
It is a step inside the IF condition of the whole pipeline:
Indeed I'm getting this error:
Cannot create Sql Source. Please double check the connection string, stored procedure are set with correct format. Error: The value of the property 'Value' is invalid for the stored procedure parameter 'portafoglio'.
Can please someone help me?
Thanks in advance
I've found a solutions with the dynamic content.
It is not only possible to put dynamic content in the value of the parameter, but even the parameter itself cam be dynamic.
I solved after many tests with this value:
#json(concat('{"portafoglio": {"value": ', variables('portafoglioElab'), '}}'))
In this way I can handle null and not null values.
Pay attention that the documentation is wrong, the content has to be a dictionary, not a string.
Pass -1 or some other sentinel and handle it in the proc
I have an Execute SQL Task which tries to execute a stored procedure, like this:
EXEC usp_stored_proc ?, ?, ? OUTPUT, ? OUTPUT;
I have 4 variables mapped to parameters. Ignoring the output parameters, these are both strings mapped to NVARCHAR params (as expected by the stored procedure).
When I run the package, an error tells me that execution failed with the message input string is not in the correct format. However, when I use a breakpoint to find the runtime values of the input parameters (or at least the variables mapped to them) and execute the same line of SQL in SSMS using the runtime values, it works fine.
Can anyone help? I'm at the end of my tether with this. I can't even find out the exact parameter causing the issue although it's probably both as the values follow the same format.
More details:
Connection type: OLE DB
Input Variable: String = schema.table
Mapped Param: NVARCHAR, ParamName = 0, ParamSize = -1
UPDATE
Solved the issue by making a new execute sql component that calls a stripped down procedure. I then slowly added lines of code to the procedure and additional parameters until arriving at the same component I started with and now it works. Comparing the original and rebuilt tasks, I see absolutely no differences (same with the procedure), so I don't know why this issue was occuring.
Try changing the parameter size (ParamSize) to match the parameter size within the stored procedure; if nvarchar(50) then set it to 50.
Solved the issue by making a new execute sql component that calls a stripped down procedure. I then slowly added lines of code to the procedure and additional parameters until arriving at the same component I started with and now it works. Comparing the original and rebuilt tasks, I see absolutely no differences (same with the procedure), so I don't know why this issue was occurring.
In a .CFC file, within a CFfunction and with CFargument tags.
<cfscript>
var sp=new storedproc();
sp.setDatasource(variables.datasource);
sp.setProcedure("storedProcedure_INSERT");
sp.addParam(cfsqltype="cf_sql_integer",type="in",value=arguments.one);
sp.addParam(cfsqltype="cf_sql_integer",type="in",value=arguments.two);
sp.addParam(cfsqltype="cf_sql_integer",type="in",value=arguments.three);
sp.addParam(cfsqltype="cf_sql_integer",type="in",value=arguments.four);
sp.addProcResult(name="results",resultset=1);
//writeDump(sp);break; //This dump is reached
var spObj=sp.execute(); //blows up here; this is never reached
writeDump(spObj);break; //This is never reached, either.
var spResults=spObj.getProcResultSets().results;
A shiny nickle to anyone who can tell me why the sp.execute() is blowing up with message
"Cannot find results key in structure.
The specified key, results, does not exist in the structure."
I've used this psuedo-code many, may times in the past, and never had it do this. I'm connected to a MSSQL Server 2012 DB, everything's cricket in CF Admin, and other SPs are working properly. The stack trace doesn't even include any of MY code at all o_O
The error occurred in C:/ColdFusion10/cfusion/CustomTags/com/adobe/coldfusion/base.cfc: line 491
Called from C:/ColdFusion10/cfusion/CustomTags/com/adobe/coldfusion/storedproc.cfc: line 142
Called from //hq-devfs/development$/websites/myProject/cfc/mySOAPWSDLs.cfc: line 123
And SO is blowing up if I try and paste anymore of that. Google has...not been helpful ._.
Short answer: The error means you are trying to retrieve a resultset from the stored procedure, when it does not actually return one. A simple solution is to add a SELECT to the end of your procedure, so it returns a resultset containing the data you need. Then your original code will work:
SELECT ##ROWCOUNT AS NumOfRowsAffected;
Longer answer:
The method you are using, addProcResult(), is the equivalent of <cfprocresult>. It is intended to capture a resultset returned from a stored procedure. (Due to CF's poor choice of attribute names, a lot of people think "resultset" means the storedproc "result" structure, but they are two totally different things). A "resultset" is a query object", in CF parlance.
While all four (4) of the primary sql statements return some result, not all of them return a "query object"
Only SELECT statements generate a "query object"
INSERT/UPDATE/DELETE statements simply return the number of rows affected. They do not generate a "query object".
Since your stored procedure performs an INSERT, it does not generate a "query object". Hence the error when you try and grab the non-existent query here:
sp.addProcResult(name="results",resultset=1);
The simple solution is to add a SELECT statement to the end of your stored procedure, so that it does return a query object. Then your code will work as expected.
As an aside, I suspect you were actually trying to grab the "result" structure, but used the wrong method. The equivalent of <cfstoredproc result=".."> is getPrefix(). Though that would not work here anyway. According to the docs, it does not contain the number of rows affected. Probably because stored procedures can execute multiple statements, each one potentially returning a row count, so there is not just a single value to return.
I am migrating BIRT reports from version 2.6 to 4.4 and facing a very strange issue which is as under
BIRT parameter passed as part of the query gets rounded off i.e if I pass 1 as parameter, query gets executed for 0 and if I pass parameter as 99 or 101, the query gets executed for 100
Query - select data from table1 where actualID = ?;
The datatype for parameter is Decimal (28,0)
DB used is SQL Server 2012
I have logged the value of parameter in BIRT Functions (beforeOpen, beforeClose and others) and it always show the parameter value consistent with what I have passed.
Please help me understand or point me to a direction where I can take this investigation further
Any help will be much appreciated
Note
If I convert datatype from Decimal to String, it works fine
If I pass parameter as part of Query it works fine but it doesn't work when parameter value dynamically replaces '?' in the query
You should also log the parameter values in the afterOpen event.
Maybe they are modified somehow in the beforeOpen event.
In my BIRT framework, I have defined a function like this:
afterOpen: function(ds) {
log.debug("afterOpen DS " + ds.getName() + " inputParams=" + ds.getInputParameters().toString());
}
This function can be called as trace.afterOpen.
Then I can use it in the data set's afterOpen event like this:
trace.afterOpen(this);
You could also set BIRT's internal logging to FINEST; that will generate loads of debug messages and should include the bind variables for each SQL statement executed AFAIK.
I have an Execute SQL task which gives returns only one row with one column - a number. I set my result set to single row. Despite that, the task fails. Why ? How do I fix it ?
[Execute SQL Task] Error: There is an invalid number of result bindings returned for the
ResultSetType: "ResultSetType_Rowset".
Probably, you haven't configured your resultset parametrs correctly. To configure it, click on ResultSet in the Execute SQL Task, click Add. In the 'ResultSetName' column, enter the exact name of the columnname that you are retrieving or simply give it 0. In the 'variablename', select the variable you created to map the data returned.
In my case the ResultSet configured to "Full result set" when there were no results being returned. The Stored Procedure I was calling was simply deleting data. So I sat this to "None" and it worked..
Old question (but Google still finds it :-))
If you want to use a rowset as result (usually to combine it with an ForEach-Loop)
you have to create a variable with the type "Object" (e.g. MyResultSet)
in the Execute SQL task the ResultSet property must be Full Rowset (is already, when you are receiving the error message above)
on the ResultSet pane (left list entry) you have to add a single entry, set it name to 0 and its variable to the Object type variable (MyResultSet)
in the ForEachLoop-Container you have to switch to the Collation pane (left list entry)
there set the Enumerator property to Foreach-ADO-Enumerator
the (now visible) ADO-ObjectSourceVariable has to be set to your Object variable (User:MyResultSet)
Click onto the Variable assignment entry in the left pane
create an entry for every column in the result set (and hope you did not use a select * for a 100 column table :-))