assign string to dbgrid cell delphi7 - delphi-7

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;

Related

Catching user input from popup with validation?

I am trying to put in a variable a value that the user has to introduce from a popup.
I have seen the function POPUP_GET_VALUES can be the adiente, but in the parameters that the function requires I see that there is a table to put the value into a field. As it is a unique value, I would like to put it within a single variable previously defined, in order to also be able to establish limits for the user to enter the value, since it has to be a percentage.
Any ideas?
Thanks!
You can use FM POPUP_TO_GET_ONE_VALUE and specify texts you want. But you should then check the format of input. For POPUP_GET_VALUES you need a table and field to reference, it will check the format for you.

How to check Parameter List value in Oracle PL/SQL?

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.

Filter Records from buttonclick event

I have searched everywhere for an answer, but because I am so new to programming I don't have a real grasp of the tech language used to describe the procedure. I have probably seen the answer, but didn't recognize it as an answer.
Basically I have a database displayed in a grid. I have a name field (teacher name) and I want to find all the records that have that name, in the teacher name field in their records. In other words I would like to find all the people who were taught by Teacher X.
I am using a TDBEdit to display the teacher name field. What I would like to do is to use a button click to filter all the records based on the text displayed in the DBEdit.
I can search all the fields using a filter dialog now. I would like not to execute a dialog in this search and I don't know where to start.
Any ideas?
Okay, this is what I came up with:
procedure TForm1.btnSearchClick(Sender: TObject);
begin
tblTest.Filter:='Teacher='+QuotedSTR(Edit1.Text);
tblTest.Filtered:=True;
end;
Then to refresh the table I used another button click event:
procedure TForm1.btnRestoreClick(Sender: TObject);
begin
tblTest.Filtered:=False;
end;
Is there a better way to accomplish this?

Generate reports in birt using user input. When input is null, everything should be fetched otherwise corresponding data should be shown

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.

how I can read a SEQUENCE and write it in text item?

Please help me!I dont know why i cant solve this simple problem.
I wanna read my sequence that I made it in my database and add it to my text Item.
any idea?(with code plz)
right know I write a cursor and call my sequence by a select from it but i dont know what should I do after it :(
In Forms if you want to enter the value of a sequence into an item (named :BLOCK.ITEM) this would work:
SELECT your_sequence.nextval INTO :BLOCK.ITEM FROM DUAL;

Resources