delete from database after deleting from the table ADF - oracle-adf

I made a small app using ADF which is deleting row from a table after daraging it to a small picture (recycle bin) on the page
but now i want this delete to be commited on database
how can I do that?

Which JDeveloper version are you using?
You should just be able to drag and drop a commit button from the 'Data Controls' tab > your Data Control > 'Operations' > Commit onto your page.
Or you could do it via a bean (make sure the Commit binding is on your page/fragment). Here is an good example: http://adfsonal.blogspot.be/2013/02/perform-delete-and-commit-by-single.html

Key k =EntityImpl.createPrimaryKey(attribute);
EntityImpl rw =
(EntityImpl)EntityImpl.getDefinitionObject().findByPrimaryKey(getDBTransaction(), k);
rw.remove();
this.getDBTransaction().commit();

Related

How to copy a record from Excel and paste into SSMS V 17 to update existing record

Folks,
I am a novice, really a business user (not techie), in SSMS v 17. I used to update a MS Sql Server database in Azure using Excel add-in (Devart), but then Active Directory Multifactor Authentication was introduced at the organization and I cannot use Devart any longer. I am forced to use SSMS v 17.5 to make updates to the database through that grid.
I found a few old (circa 2008) solutions for creating new records using Copy Paste from Excel. Similarly, is there a way to "update" an existing record in the database by copying a row from Excel and pasting into that "grid"? I have some 60+ and 70+ year olds in the team, and would really like a simple solution that could cater to all ages. Right now, we scroll right and left, furiously, inside the grid trying to ensure that we are updating the correct row of record.
I sincerely appreciate your guidance in this regard.
One way you can do this, though I do not recommend is:
1) Right click the table you want to edit, select edit top 200 rows.
2) Right click the screen that pops up, go to Pane -> SQL
3) Change this to show the records you want to edit and column in the order you want and it should work.
Big problem here and why I wouldn't suggest this, is if anything is wrong you could really mess stuff up, also it will lock the rows you are looking at which could affect other things. A better "work around" would be to create an excel function and use a template. Example : ="Update "&B1&" Set "&C1&" = '"&D1&"' where ID = "&A1 ... Essecially letting Excel write the dynamic sql. In this case B1 would be the table to update, Cell C1 would be the column to update, D1 would be the new value and A1 would be the unique identifier. I do this often when someone sends me a list of 1000 items and I need to put them in a temp table or something.

pgadmin 4, cannot find "edit data"

I read the Q/A "How to insert a row in postgreSQL pgAdmin?" from enter link description here
, but it's for pgAdmin 3.
I just installed postgreSQL 9.6.2 with pgAdmin 4, but could not find the option shown in pgAdmin 3, which you can click to have an excel-like window where you can add and update data in a table without using SQL language (as per #KarelG). Does anyone know whether it stills exist in postgreSQL 9.6.2 with pgAdmin 4? Thanks.
After editing the data, simple click on Save Data Changes (F6) icon.
You can select the table, use the right mouse button to select “View Data” and any of the subselections you choose.
You can add new rows in the resulting grid.
To save them in the database, use the “Save” icon with the image of a floppy disk:
The table needs to have a primary key to become editable in pgadmin so that the column names have a pencil icon next to them instead of a padlock.
You can right-click the table, then select View-Edit Data, and select Filtered Rows, Edit the rows and simply close on the X in the upper right. It will ask you if you want to SAVE.
I had some trouble finding this too, but found it eventually: Right-click the table, then select "View/Edit Data", and select "Filtered Rows", then enter the condition (format: field name = ). Now it will only be showing the row you want to find and edit, and you can double-click the value, change it, then click the save-icon button to save it.
I had the same trouble. Trying to find out some short keys, I found using F6 key pretty useful.
Query tool -> F5
It will run the current query in the query editor.
Query tool -> Edit some cells -> F6
It will save the current changes to the database.
Check the query history to confirm what happend exactly.

Qt: How to add/delete rows to a TableView populated with SQL records?

I am using Qt5 and MS-SQL Server 2014 on Windows7.
In my app I need to be able to perform some changes in a database table.
The DB table looks like this:
Code:
DepotTable::DepotTable(QWidget * parent) :
QDialog(parent),
ui(new Ui::DepotTable)
{
ui->setupUi(this);
model = new QSqlTableModel(this);
model->setTable("DEPOTS");
model->select();
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
ui->tableView->setModel(model);
ui->tableView->setEditTriggers(QAbstractItemView::SelectedClicked);
}
I created the table(view) using QTableView and QSqlTableModel, just to be able to fetch all rows from the database table. I can also change/modify the values of any cell/column.
And, when changes are done, I can commit/submit all changes back to database table, when pressing Ok button: model->submitAll();.
Yet, I still have one problem: I don't know how to insert a new row and edit its related values. Also, how to delete a certain/selected row? (Ok, it seems in fact there are two problems: 1) insert&edit and 2) delete row)

IntelliJ IDEA: How to quickly open a DB table editor?

Scenario: I'm in IntelliJ IDEA DB console and looking at
SELECT * FROM TableXY;
I want to see the definition of the TableXY. One way of doing it is:
ctrl+click on the table name: Looks up the table in the Database window.
F4: Opens the table editor.
select the Text tab
The problem is that I'm on a DB with a lot of tables and the first step takes forever because IDEA loads the full list of tables.
Is there a way to jump to the table editor directly?
I am not sure if this is what you are looking for, but to quickly view the table definition you can use the Quick Documentation pop-up:
Place your cursor within the table name and hit CTRL+Q (or F1 on Mac). This will show you some information about the table, the first rows, and the table definition (output from SHOW CREATE TABLE).
You can also configure the Quick Documentation under Settings > Tools > Database (see Intellij IDEA on-line help).

Need to change sql server database name in MS Access with Linked Tables

I used the SSMA to migrate data from an access database to sql server, while still using the user interface in the access database.
Now, I need to rename that sql server database, but I'm not sure how to update the Access file to use the renamed database.
You can use the Linked Table Manager.
View or refresh links
Use this procedure to view or to refresh links when the structure or
location of a linked table has changed. The Linked Table Manager lists
the paths to all currently linked tables.
Open the database that contains links to tables.
On the Tools menu,
point to Database Utilities, and then click Linked Table Manager.
Select the check box for the tables whose links you want to refresh.
Click OK to refresh the links.
Microsoft Access confirms a successful
refresh or, if the table wasn't found, displays the Select New
Location of dialog box in which you can specify the
table's new location. If several selected tables have moved to the new
location that you specify, the Linked Table Manager searches that
location for all selected tables, and updates all links in one step.
To change the path for a set of linked tables
Open the database that contains links to tables.
On the Tools menu,
point to Database Utilities, and then click Linked Table Manager.
Select the Always prompt for new location check box.
Select the check
box for the tables whose links you want to change, and then click OK.
In the Select New Location of dialog box, specify the new
location, click Open, and then click OK.
You can do this in VBA. This code looks for linked tables that begin with "dbo_" and it removes that part of the name. You'll need to modify it to suit your needs. I recommend your call this from your autoexec macro or an unbound form that starts up with your database.
If you're linking to multiple SQL Server databases then this solution might now work.
Public Sub subChangeLinkedTableNames()
Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If Len(tdfCurr.Connect) > 0 Then
If Left(tdfCurr.Name, 4) = "dbo_" Then
tdfCurr.Name = Replace(tdfCurr.Name, "dbo_", "")
End If
End If
Next
Set tdfCurr = Nothing
Set dbCurr = Nothing
End Sub

Resources