sending multiple selected values comma-separated to a stored procedure - birt

I am currently using this:
params["RPBla"].join(",")
as default parameter of a (stored procedure) dataset. This works fine and sends one or more selected values from the report parameter RPBla to a stored procedure, e.g.:
1,2,3
Unfortunately, this does not work if the user does not select any value. Any ideas what to do. Actuate BIRT should send NULL instead of for example 1,2,3.

What about testing the content in this default value expression, something like:
if (params["RPBla"].value==null){
null;
}else{
var list=params["RPBla"].join(",");
list.length>0 ? list : null;
}
Of course you could return anything you need instead of "null" here, for example returning a specific value warning the stored procedure that the filter should be disabled.

Related

Cannot clear one of the page items via dynamic action

I have a couple of text fields that are filled from the database when the value of a select list changed.
I added another action to the list change dynamic action to execute PL/SQL code:
IF :P2_SELECT_LIST1 LIKE '%ABC%' AND :P2_NAME = 'WWW' THEN
:P2_NAME = NULL;
END IF;
Nothing happend on the page when I change the value of the select list, but the session value of P2_NAME gets cleared.
I also tried:
IF :P2_SELECT_LIST1 LIKE '%ABC%' AND :P2_NAME = 'WWW' THEN
:P2_NAME = '';
END IF;
But gotten the same result
In this dynamic action there are two fields next to your pl/sql code:
Items to submit: list the items here that you use in your pl/sql to get the values from session (if necessary, the values are usually already in session).
Items to return: list the items here that you need to refresh the value on the HTML page after some change in your pl/sql
I think this solves the problem.

Update picklist value to null with Sdk.Sync.Update does nothing

Is it possible to update a record's attribute of picklist type with null by using Sdk.Sync.Update? It's not working for me.
Here's what I do:
var detailsObj = updatedDetailsObj; // I get updatedDetailsObj from previous logic, not shown here
var operation = new Sdk.Entity("kcl_operation");
operation.setId(operationId, false); // I have operationId from previous logic, not shown here
operation.addAttribute(new Sdk.String("op_updatedAccount", detailsObj.UpdatedAccount)); // works, get updated
operation.addAttribute(new Sdk.OptionSet("op_updatedExplanation", null)); // doesn't get updated
Sdk.Sync.update(operation);
After the completion of Sdk.Sync.update, the string field get updated, but the picklist field is left with its previous value, instead of null.
I also took a look inside the XML being sent inside Sdk.Sync.update, and indeed, it lacks the pair of "op_updatedExplanation" and null.
How can make it work?
Added:
I'm not doing it inside a form but inside a grid page, so that the user checks several records and I need to make the update on all of them.
standard CRM SDK code (assuming entity name and field name):
Entity operation = new Entity("kcl_operation");
operation.Id = operationId;
operation["op_updatedexplanation"] = null;
service.Update(operation);
where service is an IOrganizationService instance
Please use this snippet to set value as null.
Xrm.Page.getAttribute("op_updatedexplanation").setValue(null);
This will just set the value in the form. You may have to save the form to see the value getting stored in database.
Xrm.Page.data.entity.save();
If the control is disabled - you have to set the submitmode attribute also.
Xrm.Page.getAttribute("op_updatedexplanation").setSubmitMode("always");

Spring jdbcTemplate executing query

I have a strange problem ,
My Query looks like below.
String tokenQuery = "select id from table
where current_timestamp between
creation_time and (creation_time + interval '10' minute)
and token = '"+Token+"'";
But when I run, jdbcTemplate.queryForLong(tokenQuery) , no matter what , it always throws EmptyDataAccessException.
I am executing this in Oracle
Can we not append dynamic values to string and then pass it as a query and execute ?
What could be the issue ?
I assume that what you get is in fact an EmptyResultDataAccessException. The javadoc of this exception says:
Data access exception thrown when a result was expected to have at least one row (or element) but zero rows (or elements) were actually returned.
That simply means that the query is executed fine, and is supposed to return one row, but doesn't return any. So no row satisfies the criteria of your query.
If that is expected, then catch the exception, or use a method that returns a list rather then returning a single value. That way, you can test if the returned list is empty.
That said, you should use a parameterized query instead of concatenating the token like you're doing. This would prevent SQL injection attacks. It would also work even if the token contains a quote, for example.

qt call oracle stored procedure

I am using QsqlQuery to call oracle stored procedure that uses input parameters and two output parameters
The procedure executed perfectly but output parameters contains no data
QSqlQuery movementQuery ;
movementQuery.prepare("call Qt.add_movement(:pDocumentType , :pDocumentId ,
to_date(sysdate,'dd-mm-yyyy') ,:pDocumentNumber"
",to_date(sysdate,'dd-mm-yyyy') , :pCustId ,:pMovementId ,:pReturn )");
movementQuery.bindValue(":pDocumentType",documentType);
movementQuery.bindValue(":pDocumentId",documentId);
movementQuery.bindValue(":pDocumentNumber",0);
movementQuery.bindValue(":pCustId",ui->custId->text());
movementQuery.bindValue(":pMovementId", 0, QSql::Out);
movementQuery.bindValue(":pReturn", "FALSE", QSql::Out);
movementQuery.exec();
//// The query executed the query is active and no errors are valid
//// message is method to display the value
message(query.boundValue(":pReturn").toString());
message(query.boundValue(5).toString());
message(query.boundValue(":pMovementId").toString());
message(query.boundValue(4).toString());
Any ideas
Thank you for your interest
You are executing movementQuery
movementQuery.exec();
but you are returning the bound values of query.
message(query.boundValue(":pReturn").toString());

SqlDateTime overflow thrown by Typed DataSet Insert

I'm using a Typed DataSet with an Insert statement; I have a table that has a smalldatetime field defined to accept null values. When I insert from a .NET 2.0 FormView, I get a "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."
Now, I've read this post, and the parameter as sent to the class constructor is defined as
global::System.Nullable<global::System.DateTime> DoB
So, it looks like it should accept a Nullable obj. Additionally, the generated code is testing the value sent.
if ((DoB.HasValue == true)) {
command.Parameters[6].Value = ((System.DateTime)(DoB.Value));
}
else {
command.Parameters[6].Value = global::System.DBNull.Value;
}
Specifically, the error is occurring when generated SqlClient.SqlCommand.ExecuteScalar() runs:
try {
returnValue = command.ExecuteScalar();
}
So, I guess my question is: how do I use a Typed DataSet to set a blank value (passed from a FormView on CommandName=Insert) to a null in a database?
Ok, so here's what worked for me. First, to reiterate, I've got a Typed DataSet with DataAdapters that's generating the ADO objects. So, on my page, I can create a ObjectDataSource with the type that points to my adapter, and then name the different access methods housed there-in.
No, I have an Insert to a table where basically all the columns are nullable; some varchar, some smalldatetime.
When I submit an empty form, I'd like nulls to be entered. They're not and lots of various errors are thrown. What I ended up doing is subclassing the ObjectDataSource to gain access to the Inserting event. (subclassed for reusability) In the Inserting event, I looped through the InputParameters, and if it was a string and == "", I set it to null. Also, you cannot set ConvertNullToDBNull to true; that causes the strings to fail. This successfully allowed the Nullable to remain null.

Resources