How to create refresh statements for TableAdapter objects in Visual Studio? - visual-studio

I am working on developing an ADO.NET data provider and an associated DDEX provider. I am unable to convince the Visual Studio TableAdapater Configuration Wizard to generate SQL statements to refresh the data table after inserts and updates. It generates the insert and delete statements but will not produce the select statements to do the refresh.
The functionality referred to can be accessed by dropping a table from the Server Explorer (inside Visual Studio) onto a DataSet (e.g., DataSet1.xsd). It creates a TableAdapter object and configures SELECT, UPDATE, DELETE, and INSERT statements. If you right click on the TableAdapter object, the context menu has a “Configure” option that starts the “TableAdapter Configuration Wizard”. The first dialog of that wizard has an Advanced Options button, which leads to an option titled “Refresh the data table”. When used with SQL Server tables, that option causes a statement of the form “select field1, field2, …” to be added on to the end of the commands for the TableAdapter’s InsertCommand and UpdateCommand.
Do you have any idea what type property or interface might need to be exposed from the DDEX provider (or maybe the ADO.NET data provider) in order to make Visual Studio add those refresh statements to the update/insert commands?
The MSDN documentation for the Advanced SQL Generation Options Dialog Box has a note stating, “Refreshing the data table is only supported on databases that support batching of SQL statements.” This seems to imply that a .NET data provider might need to expose some property indicating such behavior is supported. But I cannot find it. Any ideas?

The refresh functionality in TableAdapter means that the associated datatable for the tableadapter operation will have updated data after the operation is completed.
If you call insert method of the tableadapter and pass the datarow or the datatable for the insert operation, the tableadapter will refresh the datatable/datarow to reflect the latest values from the database after the insert operation. If your table in database has generate a unique-id or auto-number for the insert command for the given row to insert, the original datarow's p.key coloumn will reflect the auto-generate id value from the database. This refreshing will be taken care by the tableadapter provided you have set the refresh option to true in the wizard configuration.
Now to this 'refresh' tableadapter will execute 2 queries in single batch, first will be the Insert, then the select with the scope_identity.
EDIT
My default Insert command would fire this single SQL if Refresh is turned OFF on the TableAdapter
INSERT INTO Table (coloumns) VALUES (values);
But My default Insert command would fire these SQL statement batch if Refresh is turned ON on the TableAdapter. Datarow that is passed as argument to Insert() will also be updated after successful execution.
INSERT INTO Table (coloumns) VALUES (values);
SELECT coloumns FROM Table WHERE (PKeyID = SCOPE_IDENTITY())

Related

Can't create new columns, constraints, indexes using DBeaver 7 in MySQL 8

I'm attempting to create new tables and add new columns to an existing MySQL 8 database. I'd like to use DBeaver GUI for this task. Creating the new connection with the MySQL 8+ driver, I'm able to connect to my localhost using root user.
I'm able to load the database tables and explore their columns, constraints, properties, etc. But I'm not able to create new columns... I can't see any option similar to New column, New Table, etc. In MySQL Workbench, for example, one just has to right-click over the grid to be able to add new columns.
I've right-clicked everywhere and I've read all menus and I'm not able to find a way to insert something new using the GUI. It seems as if I was in a read-only connection. However, I didn't check Security: Read-only connection when creating the connection (double checked).
Under table properties, if I right-click and I select Generate SQL > INSERT I'm not able to type anything in the resulting window...
Testing my connection I got the following:
Connected (30 ms)
Server:
MySQL 8.0.21
Driver:
MySQL Connector/J mysql-connector-java-8.0.17 (Revision: 16a712ddb3f826a1933ab42b0039f7fb9eebc6ec)
Finally, in table properties, if I change the table description, click de Save button and then the Persist button, I'm able to update the description. What am I doing wrong then?
I'm missing something obvious for sure.
Thanks in advance.
You can make changes to your tables with SQL. Click on the 'New SQL Editor' button here:
Then type up your SQL:
ALTER TABLE db_name.my_table,
ADD COLUMN column_1 NULL,
ADD COLUMN column_2 TEXT,
ADD COLUMN first_name VARCHAR(255);
Make sure you check the syntax for your specific version of MySql, and when you've got what you want there, click the 'Execute SQL Script' button:
That should do the trick.
Checked on windows machine on DBeaver 21.3.2, right the respective table on which you want to add column, click on "create column" and then enter the name and default values of the column like Auto increment and not null etc.
Finally click save and persist those changes in the database if you are sure of the changes you did otherwise edit the column and then persist them.
Running on Linux but seeing the same issue. I was able to start adding columns in the left pane, in the Database Navigator. Open a table, then right mouse on a table and you will see the option to add a column. Thereafter you can add columns in the properties tab.

How to resolve error ORA-20987: APEX - ORA-02015?

I have a page in apex with multiple interactive grid. In one of the interactive grid i am trying to update the data of a column of a table in the database. The column named defect kind is a dropdown in the grid and on click of save should be able to updated the column value in database with the selected value in the grid.
While clicking on save apex is showing an error as follows:
Ajax call returned server error ORA-20987: APEX - ORA-02015: cannot select FOR UPDATE from remote table for.
I have used the type interactive grid - automatic row processing(DML) for saving the grid. Only defect kind is selected by the user rest all column value are coming directly from the table.
Interactive grid image:
NOTE:For this workspace the tables are accessed through a database link. I am using APEX 5.1.
This error is raised specifically because you are working over a database link.
Error code: ORA-02015
Description: cannot select FOR UPDATE from remote table
Cause: An attempt was made to select FOR UPDATE on a remote table (directly, or via a view) that had abstract data type columns, and the
view or select list contained abstract data type columns or non-column
items.
Action: To attempt a select FOR UPDATE, use a view or select list that consists only of base columns from the remote table, none of
which may be abstract data type columns.
I can't tell from what you've posted if the issue is with the query you're using to populate the IG or with some underlying view or the table itself. Depending your ability to locate and remove the "abstract data type columns or non-column items" (if that's even possible with an IG) you may not be able to make this work with automatic row processing over a database link at all. It may require a custom PL/SQL API instead.
Have you tried to set the attribute Lock Row (group Settings) to No in your Interactive Grid - automatic row processing(DML) process?

Generating sql insert into for DataGrip

When you run a query (a SELECT statement) in the console, the data retrieved from the database are shown in table format in the Result pane of the Database Console tool window.
I've searched through datagrip Help and I'm just wondering if there is anyway out there that can be used to generate INSERT INTO scripts for a tables' content or rows in table format?
Choose SQL Insert extractor in the drop-down menu.
Them you'll be able to copy (Ctrl/Cmd+C) data as a bunch of INSERTS. Or use Export button next to the extractor.

Delphi XE7 TFDTable View RowID error

I'm converting a Delphi 5 / BDE application to Delphi XE7 / FireDAC. One of my forms has a TFDTable component that points to an Oracle view containing a group by clause in its create statement.
This used to work fine in the BDE application, but with FireDAC I'm getting this error.
ORA-01446: cannot select ROWID from, or sample, a view with DISTINCT,
GROUP BY, etc.
I understand the error I'm getting from Oracle, but I'm not selecting ROWID, FireDAC is! Is there a property in the TFDTable that I can set to prevent it from adding ROWID to the query? If not, how am I supposed to use this view?
FireDAC fetches ROWID because it tries to identify tuples in the resultset for possible updates. For stopping that just enable the ReadOnly option which will properly make the grouped view resultset read only (properly as one cannot just identify particular tuples if they are grouped in a resultset for updating).
The SQL command is generated in TFDPhysCommandGenerator.GenerateSelectTable method, if you wanted to know the source of this problem. There is appended generic unique tuple identifier to the select list according to the ReadOnly property setting (which is ROWID for Oracle DBMS).
Include fiMeta in FetchOptions.Items.
TFDQuery, TFDTable, TFDMemTable, and TFDCommand automatically retrieve
the unique identifying columns (mkPrimaryKeyFields) for the main
(first) table in the SELECT ... FROM ... statements, when fiMeta is
included in FetchOptions.Items. Note:
mkPrimaryKeyFields querying may be time consuming;
the application may need to explicitly specify unique identifying columns, when FireDAC fails to determine them correctly.
To explicitly specify columns, exclude fiMeta from FetchOptions.Items,
and use one of the following options:
set UpdateOptions.KeyFields to a ';' separated list of column names;
include pfInKey into the corresponding TField.ProviderFlags property.
When the application creates persistent fields, then initially
TField.ProviderFlags will be set correctly. After that, automatic
field setup will not happen, when the DB structure or query is
changed. You should manually update ProviderFlags to adjust the column
list. Also, if the primary key consists of several fields, then all of
them must be included into persistent fields. Row Identifying Columns
Alternatively, a row identifying column may be included into the
SELECT list. When FireDAC founds such columns, it will not retrieve
mkPrimaryKeyFields metadata and it will use this column. The supported
DBMSs are the following:
DBMS Row identifying column
Firebird DB_KEY
Informix ROWID
Interbase DB_KEY / RDB$DB_KEY
Oracle ROWID
PostgreSQL OID. The table must be created with OIDs.
SQLite ROWID
Source : http://docwiki.embarcadero.com/RADStudio/XE8/en/Unique_Identifying_Fields_%28FireDAC%29

oracle query talend etl

I am a beginner to use talend etl I would make a request to select a database oracle then make a change _ S and insert it into a mysql table I'm stuck. I have not found how to make select queries with talend not know how I started that can help me please
To make a select on Oracle schema you need a tOracleInput component instance. You need to specify a Oracle connection (either a builtin connection or a repository-registered connection) and the output schema (the columns you need).
Then, click on "Guess query" to build the select SQL code accordingly to your desired output schema. You can then modify the automatically generated SQL code to fit your needs (ie. add WHERE or SORT clauses). Don't forget that output schema and selected columns must be the same (ie if you add a SQL-generated column inside the select clause you must add in your output schema, too). Any valid SELECT syntax can be used here (including subselects, cursors, window over partition and even more weird oracle stuff).
After the input instance, add a tMap where you make all your data manipulations. Finally, close with a tMySqlOutput, specifing connection and output table details. The flow will trivially looks like:
tOracleInput ----> tMap ----> tMySqlOutput
Create the connection Mysql and Oracle in Metadata Objects (Db Connections).
Create the following objects (tMySqlConnection - TOracleConnection)
Configure the objects with the parameters connections (Property Type: Repository).
Extract data: You can select the table with the object tOracleInput.
Edit schema of the table in the submenu Component
Create object TMAP, (transform the data)
Create object tMysqlOutPut and configure the schema and columns to insert.
Create object tMysqlCommit and close the connection.
Listo! ¡¡Run to job!! :)

Resources