Forum > Databases

[solved] DBNavigator with user defined SQL

(1/2) > >>

Nicole:
How can I user-define the SQL on click?

These I have:
DBNavigator_Kupons
DataSource_Kupons
IBQuery_Kupons
IBUpdate_Kupons
DBGrid_Kupons

This IS in the navigator

--- Code: MySQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    Select ID_KUPON,BETRAG, DATUM, FK_EINKOMMEN    From TBKUPONS    where id_Kupon = :id_Kupon
This SHALL be in the navigator

--- Code: MySQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    Select ID_KUPON,BETRAG, DATUM, FK_EINKOMMEN    From TBKUPONS    where id_Kupon = :id_Kupon    and FK_einkommen = :myChosenValue
"myChosenValue" shall be taken from an edit-field, which the uses may change.

rvk:

--- Quote from: Nicole on May 30, 2024, 07:47:01 pm ---This IS in the navigator

--- Code: MySQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    Select ID_KUPON,BETRAG, DATUM, FK_EINKOMMEN...
--- End quote ---
Does your (tdb)navigator have a SQL property ????
I think you mean that your IBQuery_Kupons has that SQL statement.

What's wrong with changing it when the user changed the TEdit with myChosenValue? (OnChange or when pressed a Search button)

Then you only have to do IBQuery_Kupons.ParamByName('myChosenValue').AsString := myEdit.Text;

Nicole:
Thank you for your reply.

The dbnavigator has no SQL property, - this is exactly my problem.

This IBQuery_Kupons-select statement I can change, but it does not work under the line.
My suspect, this is due to "and FK_einkommen = :myChosenValue"

Let me explain the details:
The user (this is me) choses a certain fk_einkommen by keying in the number, fine.
Then I hit the button to list the values = the select statement-result is filled into the DBGrid, fine.
This is fine and can be edited by the DB navigator and within the DGGrid, fine
It can be edited as well, fine.

THEN I want the value to be changed into the DB.
and: No edit is brought to the database.
This means: Pushing the button again does not show the edited values, but the old ones.

This is not too surprising, because the and "FK_einkommen = :myChosenValue" no where finds its way in any update-statement.

It woud not be too hard, to find such a valid update-statement including the "and FK_einkommen = :myChosenValue".

My problem is:
Where to pass this statement into my code for using it in the query or navigator?
It has no SQL-property and the IBQuery only has a select-property.

In other words: I would need something like
myThing.SQL.Text:"'update value1 from tbtable where..."

WHERE can I find a "myThing" to pass such a statement?

rvk:

--- Quote from: Nicole on May 31, 2024, 12:03:45 pm ---In other words: I would need something like
myThing.SQL.Text:"'update value1 from tbtable where..."
--- End quote ---
I'm a bit surprised you are asking this question.
We've discussed the UpdateSQL property of TSQLQuery many times in the past.

And if you are still using TIBQuery (which you don't mention) then there is a UpdateObject property (which was also discussed).
Then you need to create a TIBUpdateSQL component which contains the Update/Delete/Insert statements, and attach that to the TIBQuery.UpdateObject.

BTW. TDBNavigator doesn't do anything other than just jumping through the databaset (TDataSource which is connected to TSQLQuery or TIBQuery) and putting it into edit or insert mode.
So you don't do anything with input there. Everything goes through the TDataset (which is that TSQLQuery or TIBQuery).

Nicole:
pls look in my first posting, there I listed all used items, I used including an "IBUpdate_Kupons".

I remember having seen context-menus with properties modifySQL, UpdateSQL or similar. I used them in an old unit long ago, but cannot find anymore how and where.

Unfortunately those properties are not part any more of any of the components listed in my first posting.

Probably the solutions of my question is that easy, that we both will call out "ah, this it was".

Navigation

[0] Message Index

[#] Next page

Go to full version