I created a param list and add some parameter, but when I want to check if the parameter and its value has been added, it cannot get the value I just added. What's wrong with the code :
IF NOT ID_NULL(GET_PARAMETER_LIST('RPT')) THEN
DESTROY_PARAMETER_LIST('RPT');
END IF;
v_param_list := CREATE_PARAMETER_LIST('RPT');
ADD_PARAMETER(v_param_list,'PAR_WHERE',TEXT_PARAMETER,'WHERE ID = 1010');
BEGIN
GET_PARAMETER_ATTR(v_param_list,'PAR_WHERE',v_param_type,v_temp);
message('PAR_WHERE:'||v_temp);
EXCEPTION WHEN OTHERS THEN
message('Couldn''t get the value for : PAR_WHERE');
END;
How could I retrieve all the parameters and values in a param list ?
As GriffeyDog said, there is no way to retrieve parameter list items. I had the same problem and solved it by using the database. The only way is to use workarounds.
My solution is to pass an ID in a parameter list. This ID represents a pl/sql collection. Once the ID is retrieved is easy to get all collection keys or values.
If you need more details let me know as the code is years old.....
I don't see where you've defined v_param_type and v_temp. v_param_type needs to be a number and v_temp a varchar2, and they are both out parameters.
Unfortunately, there is no way to retrieve all of the parameters from the ParamList without knowing the names of the parameters contained in it beforehand.
Related
I have a function that it receives in input a %ROWTYPE and a variable which contains the name of field in ROWTYPE
For example, my ROWTYPE contains 3 fields
data_row as data%ROWTYPE
data_row.Code
data_row.Description
data_row.Value
And the fieldName variable contains 'Description'
Where is the most simple way in order to extract a value from data_row.Description?
Regrards,
Marco
You can't refer to the record fields dynamically, at least without jumping through a lot of hoops using dynamic SQL and either requerying the underlying table or creating extra objects.
A simple way to do this is just with a case statement:
case upper(fieldName)
when 'CODE' then
-- do something with data_row.code
when 'DESCRIPTION' then
-- do something with data_row.description
when 'VALUE' then
-- do something with data_row.value
else
-- possibly indicate an error
end case;
The record field references are now static, it's just the decision of which to look at that is decided at runtime.
db<>fiddle demo
You may need to do some extra work to handle the data types being different; in that demo I'm relying on implicit conversion of everything to strings, which is kind of OK for numbers (or integers anyway) but still not ideal, and certainly not a good idea for dates. But how you handle that will depend on what your function will do with the data.
So I am having a dbgrid that is used as a data entry.
Assume I got 4 fields that needed to be filled by user and another field that I need to assign a value into. Look at the picture.
I connected that dbgrid to query1 through datasource1.
my question is, how did I assign a certain value (ex:abc) to idpay field so that it will be read without user inputing it?
As dbgrid is automatically posted, I need to assign that value on event beforepost. any idea how to do that?
any help is much appreciated! Thank you!
Does the Query component you use has the AfterInsert event ?
If so than simply do something like this
procedure TForm1.ClientDataSet1AfterInsert(DataSet: TDataSet);
begin
DataSet.FieldByName('IDPAY').AsString := 'ABC';
end;
I have an Action that opens another report and it passes a multivalue parameter. Is there a way to exclude for example, the first value of the multivalue parameter?
Assuming that you are using SQL Server for your queries.. when you pass the list of parameters into your subreport, I would take the parameter pass it to a splitstring function and then exclude the first row and then use the result in your where clause for your subreport parameter.
This way you have flexibility to exclude what ever row you want by passing the row number as a parameter as well.. just saying.. and you cal also check that you have more than one parameter selected before excluding it.. else you won't get a result back
I have two select lists
1. The first one P4_country_id_B contains countries names
select country_name as d, country_id as r
from countries
2. The second one P4_CITY_ID_B contains cities of a country based on selected value in P4_CITY_ID_B.
select city_name as d, city_id as r
from cities
where country_id = :P4_country_id_B
Everything goes OK without any problem.
BUT
I use Execute PL/SQL Code Dynamic Action to change selected values of those lists like this (for example):
:P4_country_id_B:=country_returned_value;
:P4_CITY_ID_B:=city_returned_value;
Where
country_returned_value : is a one value of countries list values for example (USA)
city_returned_value : is a one value of cities list values for example (NewYourk).
The first selected list value changes but the second list never changes.
Notes:
I used P4_country_id_B,P4_CITY_ID_B as Page Items to Submit for the dynamic action.
I don't whan to submit the page instead of dynamic action
How can I change list values in this case please?.
Thanks in advance.
Cascading select lists are refreshed through ajax.
Change select list 1, select list 2 will be refreshed.
You execute plsql, which in turn will set the value of the items involved. Both are select lists, and one is dependent on the other.
So while both will be set, the change of the first one will cause the second to be refreshed.
In other words, you're doing it too fast. And while there is a solution, the proper way is a bit complex and I wouldn't build it in DA's personally.
You haven't specified how or when you call the code which sets the values for the items. So here I'll just assume a DA with an action of type "Execute JavaScript" (for example)
// perform a call to the ajax callback process to get the country and city id
// there are several ways to provide values to the process if necessary.
// for example through x01, which can be used in the proces like
// apex_application.g_x01
apex.server.process('GET_COUNTRY_DEFAULTS', {x01:""}).done(function(data){
// process returns JSON which contains 2 properties: country_id and city_id
// data.country_id
// data.city_id
// bind a ONE-TIME handler to the after refresh event of the city
// cascading LOVs fire the before and after refresh events like any other
// refreshable element in apex
// a one time handler since the values are different each time this code will
// execute
apex.jQuery("#Px_CITY_ID").one("apexafterrefresh",function(){
// after refresh of the list, attempt to set the value of the list to the
// value retrieved earlier
apex.item(this).setValue(data.city_id);
});
// finally, set the value of the country. Doing this will also trigger the
// refresh of dependent elements
apex.item('Px_CITY_ID').setValue(data.country_id);
// since a handler has been bound, the refresh will occur, the after refresh
// triggers, and the value will be set properly
});
Finally, create a new process on the page under "AJAX Callback", and name it GET_COUNTRY_DEFAULTS
DECLARE
l_country_id NUMBER;
l_city_id NUMBER;
BEGIN
l_country_id := 8;
l_city_id := 789;
htp.p('{"country_id":'||l_country_id||',"city_id":'||l_city_id||'}');
EXCEPTION WHEN OTHERS THEN
-- returning an error while using apex.server.process will prompt the user
-- with the error and halt further processing
htp.p('{"error":"'||sqlerrm||'"}');
END;
That should tie everything together.
I think there is some confusion here. My answer below, assumes, according to your question, the first list name is P4_country_id_B, and the second list name is Cities_LOV. If that is not the case, please clarify.
Your first list called P4_country_id_B, and you assign it to itself through the following statement:
:P4_country_id_B:=country_returned_value;
So basically, nothing has changed, the value of P4_country_id_B is the returned value of your list P4_country_id_B without any need for this assignment. Note, it is not clear to me, what is country_returned_value, because P4_country_id_B holds the returned value.
Secondly, you have a list called Cities_LOV, and you assign the returned value to P4_CITY_ID_B page item, through the following statement:
:P4_CITY_ID_B:=returned_city_value;
Again, I am not sure what is returned_city_value, because Cities_LOV holds the returned value of that list.
I am not sure what you are trying to achieve here. But I assume, you want to allow the user to select the Country first, and then based on that, you want to refresh the Cities list to display the cities in that particular country. If that is the case, then use a dynamic action on P4_country_id_B value change, to refresh the value of Cities_LOV. You only need to pass P4_country_id_B to that dynamic action.
UPDATE
After you corrected the wording of the question, the answer would be like this:
In your child list P4_CITY_ID_B make sure you set the option Cascading LOV parent item(s) to the parent list P4_country_id_B. You do not need the dynamic action. The child list, should refresh upon the change of the parent list. The answer here, goes in details about how to implement cascading list
I have to create a birt report with user input parameters. It is something like when the para
meter is left blank it should fetch all values from a table otherwise when the user inputs the students roll no.,the corresponding data should be fetched. Can this be done through Birt report? If yes, then please suggest a way.
Thanks!
Yes, you can do that. If the parameter is optional you can't use the Dataset Parameter (with a ? in your query), because it will be null. Instead you have to modify your query using JavaScript.
Create a Report Parameter like usual, in this case 'stud_no'. Then add a comment in your SQL that you are reasonably sure is unique, I use something like --$stud_no$, wherever you want your clause inserted.
Then add a script like this to your Data Set, in beforeOpen:
if (params["stud_no"].value){
this.queryText = this.queryText.replace("--$stud_no$", "and stud_no = " + params["stud_no"]);
}
This replaces the comment with the clause when the parameter has a value. You can use regex in the search string, and then you can also insert it multiple places if you want.
Create your paremater using a like statement
where students_roll_no like ?
Create your report paramater using as a text box, with a defualt value of %
Because the percent '%' is the SQL wildcard, it returns all values. If the user enters a Student Roll number, it returns only that record. Additionally the user can enter 0500% and get all the records that begin 0500.