Insert into Oracle from Excel VBA - excel

I'm using ADO object to connect oracle database. When I execute an INSERT statemnet from VBA it is getting inserted properly. If I check the same record with the current connection, I am able to retrieve the inserted data. But when I check the same directly in Oracle it is not reflecting that inserted Data.
For cross verification, I have created one more button to check whether the Data inserted into the ORACLE table. But there I'm getting only zero recrods.
(I have tried with connection method .BeginTrans and cn.CommitTrans before execute statement)
Can any one of you please let me know the reason.
Regards,
Ram

This sounds like you are missing a COMMIT after your INSERT statement.
This article does a
objADO.CommitTrans
after executing the insert.

Related

how to use a stored log analytics query as a datasource in excel?

In our project we created several useful queries on log analytics that we deploy as a "savedSearch" (Microsoft.OperationalInsights/workspaces/savedSearches#2020-08-01).
Now when we load the query in the editor we can export it to excel, which can be nicely refreshed to view current data.
However this link is created to the query that is in the editor and not the stored/deployed query. The alternative is to export to Power Bi (M query) which generates a script that you can then use in excel.
In both cases the query itself seems to be in the connection, so it does not get updated when we deploy a new version. Does anyone know of a way to make this connection to a stored/deployed query?
I feel like this should be as straightforward as a connection to resource so that not only the data, but also the query itself gets updated.... I must be missing something
One way I can think of is to leverage Functions in log queries.
You can first save your query as a function, then export it to excel that would create a connection but execute the function, instead of the raw query.
You can tweak your query later if needed and save/overwrite to the same function, and the refresh should still be able to pull in the latest results since the changes are now neatly abstracted away via the function. :)

How to update, insert and delete Redshift database using Python?

I am able to create table using psycopg2 library however I am unable to update and delete records in Redshift database. Please suggest some methods to do this.
You can find a lot of good information in their documentation: here
Here's a small snippet for your reference.
with conn.cursor() as sql_cursor:
sql_cursor.execute('delete from table_1 where col1=123')
Also, make sure the db user you are using to update or delete has permission to do so.

How Can I see the Sql query of the excel file I uploaded Oracle DB

I am learning pl/sql. I want to ask a question for importing excel files.
I create a table after that import data from excel nearly 100 rows.
I wonder how can i see this query basic like;
insert into table_name (column1,colum2,...,columnn )
values (value1, value2, ... , value n); and other 100 rows..
Sincerely
I'm not sure whether there is a feature within Oracle engine itself, but I can think of two ways to get those queries:
1. Use Oracle SQL Developer (Or another GUI with the same features) :
Oracle SQL Developer (Download link here) is a free tool developed by Oracle to interact with the database. Add the connection for your database and connect to it, then follow these guidelines carefully to generate your insert script.
2. Use v$sql (Experimental) :
Right now I have no access to an Oracle database to check this, but theoretically, if the database is a development/training one, there should not be a lot of activities and queries inside, so you can query the v$sql table to find the last 100 (or whatsoever) queries:
SELECT SQL_FULLTEXT FROM V$SQL WHERE ROWNUM < 1000 ORDER BY FIRST_LOAD_TIME desc;
Check for the ones starting with INSERT INTO {THE_TABLE_WHICH_HAS_IMPORTED_DATA} to find your insert lines.
As I mentioned, this method is quite experimental and might confuse you, so I strongly suggest using Oracle SQL Developer.

"show dbs" command only showing local database but not newly created ones

I started working with mongodb yesterday and can't seem to generate a database on the console. Every time I do the
use exampledb
switched to db exampledb
but for some reason I still generate only my locals..?
show dbs
local 0.078GB
I created a folder called /data/db in my root directory (following the tutorial) so I'm not sure what I am missing... help appreciated!
You are not missing anything. exampledb will be shown (using show dbs) only when you insert atleast one document in it. You can add collections manually if you want using db.createCollection().
Your database need to have atleast one document inside. First we need to add atleast one document into the selected database.
Example:
db.mycollection.insert({"name":"Max"})
where db is the general term not the name of the database and mycollection is the name of your collection, inside the insert give as key value pairs)
After that you can see your database.
Insert one Document and the "show dbs" command will display your database

Create fulltext index within Entity Framework Coded Migrations

TLDR; How do you add a full text index using Entity framework 5 coded migrations
I'm having issues adding a full text index to a database using Entity framework migrations. It needs to be there from the start so I'm attempting modifying the InitialCreate migration that was automatically generated to add it.
As there isn't a way to do it via the DbMigrations API I've resorted to running inline sql at the end of the 'Up' code.
Sql("create fulltext catalog AppNameCatalog;");
Sql("create fulltext index on Document (Data type column Extension) key index [PK_dbo.Document] on AppNameCatalog;");
When this runs everything gets created fine until it reaches this sql, then it throws the the sql error 'CREATE FULLTEXT CATALOG statement cannot be used inside a user transaction.'. Which is expected and working as designed.
Thankfully Sql() has an overload that allows you to run the sql outside the migration transaction. Awesome! I thought.
Sql("create fulltext catalog AppNameCatalog;", true);
Sql("create fulltext index on Document (Data type column Extension) key index [PK_dbo.Document] on AppNameCatalog;", true);
But low and behold modifying the code to do this (see above) results in a new timeout error 'Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.'
I've tried spitting out the sql and running it manually and it works fine. I've also diff'd the generated sql with and without running it outside a transaction and they are identical so it must be something in the way sql is executed.
Thanks in advance for any help!
I had a similar problem. My InitialCreate migration was creating a table and then attempting to add a full text index to that table, using the overloaded Sql() to indicate that it needs to execute outside the transaction. I was also getting a timeout error and I suspect it's due to a thread deadlock.
I could get it to work in some scenarios by using Sql() calls instead of CreateTable() and by merging the CREATE FULL TEXT CATALOG and CREATE FULL TEXT INDEX statements into a single Sql() call. However, this wasn't very reliable. Sometimes it would work and sometimes it would fail with the same timeout error.
The only reliable solution I found was to move the creation of the catalog and full text index into a separate migration.

Resources