jupyter notebook with dropdown box and sql
I am using a dropdown box that receives the values from %sql select... 🆗
I display drop.value and it indicates 'SYSCAT' = ok
now I need to use this drop.value as an input to another %sql
sql select .. from table where col=$drop.value
in this case the value is supplied but I need the quotes
sql select ..from table where col1='SYSCAT'
how can this be done ? any idea
thanks for all update, Best regards, Guy
Related
The only thing I don't have an automated tool for when working with Oracle is a program that can create INSERT INTO scripts.
I don't desperately need it so I'm not going to spend money on it. I'm just wondering if there is anything out there that can be used to generate INSERT INTO scripts given an existing database without spending lots of money.
I've searched through Oracle with no luck in finding such a feature.
It exists in PL/SQL Developer, but errors for BLOB fields.
Oracle's free SQL Developer will do this:
http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html
You just find your table, right-click on it and choose Export Data->Insert
This will give you a file with your insert statements. You can also export the data in SQL Loader format as well.
You can do that in PL/SQL Developer v10.
1. Click on Table that you want to generate script for.
2. Click Export data.
3. Check if table is selected that you want to export data for.
4. Click on SQL inserts tab.
5. Add where clause if you don't need the whole table.
6. Select file where you will find your SQL script.
7. Click export.
Use a SQL function (I'm the author):
https://github.com/teopost/oracle-scripts/blob/master/fn_gen_inserts.sql
Usage:
select fn_gen_inserts('select * from tablename', 'p_new_owner_name', 'p_new_table_name')
from dual;
where:
p_sql – dynamic query which will be used to export metadata rows
p_new_owner_name – owner name which will be used for generated INSERT
p_new_table_name – table name which will be used for generated INSERT
p_sql in this sample is 'select * from tablename'
You can find original source code here:
http://dbaora.com/oracle-generate-rows-as-insert-statements-from-table-view-using-plsql/
Ashish Kumar's script generates individually usable insert statements instead of a SQL block, but supports fewer datatypes.
I have been searching for a solution for this and found it today. Here is how you can do it.
Open Oracle SQL Developer Query Builder
Run the query
Right click on result set and export
http://i.stack.imgur.com/lJp9P.png
You might execute something like this in the database:
select "insert into targettable(field1, field2, ...) values(" || field1 || ", " || field2 || ... || ");"
from targettable;
Something more sophisticated is here.
If you have an empty table the Export method won't work. As a workaround. I used the Table View of Oracle SQL Developer. and clicked on Columns. Sorted by Nullable so NO was on top. And then selected these non nullable values using shift + select for the range.
This allowed me to do one base insert. So that Export could prepare a proper all columns insert.
If you have to load a lot of data into tables on a regular basis, check out SQL Loader or external tables. Should be much faster than individual Inserts.
You can also use MyGeneration (free tool) to write your own sql generated scripts. There is a "insert into" script for SQL Server included in MyGeneration, which can be easily changed to run under Oracle.
I have created a report file in my ASP application, Statistics.rdlc
I have created a Data Source which connects to my local database.
I now wish to add a Dataset using a specific query I have written, however when I right click Datasets in the Report Data panel and select my Data source I am presented with a list of the tables on the database under 'Available datasets'.
What I am expecting to see here is the Dataset1.xsd I created which contains the following:
That Query contains the SQL I wish to apply to my report table, can any point out what im doing wrong here?
I needed to create a table adapter not a query.
This post helped me out:
http://www.c-sharpcorner.com/UploadFile/a72401/rdlc-report-generation-using-dataset/
Sometimes report view doens't allow when you use "SELECT * FROM". Put all columns instead of *.
Ex: SELECT column1, column2, column3 FROM table
In Oracle I create a view using a 'union all' as below
create view TESTVIEW as
select column1 from TABLE1
union all
select column1 from TABLE2;
If I want to insert into this view I get
SQL Error: ORA-01732: data manipulation operation not legal on this view
Is there any way around this if I know I want to insert in TABLE1?
Yes, you should be able to create an INSTEAD OF INSERT trigger on the view.
You'll need to write the trigger to insert the row in the base table, and it will run "instead of" the original insert.
Please refer http://docs.oracle.com/cd/E17952_01/refman-5.1-en/view-updatability.html to understand which views are directly updatable. For views which are not directly updatable use "Instead of" trigger as suggested in the above post.
I am trying to view data in grid view in asp.net page.I am using oracle databse.I Placed a grid view controller in page and I am trying to bind it with oracle database using datasource wizard. In wizard I chose SQL source, gave connection string. Now i choose a table then it gave query like:
Select * from [table_name]
When I test the query It is giving error like:
There was an error in executing query. Please check the syntax of the command and if present,the type and the values of the parameters and ensure they are correct. ORA-00903: Invalid table name.
The table name is enclosing in square braces. How to get rid of this.
You cann't use [table_name] you need to use table_name only.
It is ok in sql Server [table_name] but not in oracle.
So you need to use like this
Select * from table_name
I'm unable to retrieve the latest inserted id from my SQL Server 2000 db using a typed dataset in asp.NET
I have created a tableadapter and I ticked the "Refresh datatable" and "Generate Insert, Update and Delete statements". This auto-generates the Fill and GetData methods, and the Insert, Update, Select and Delete statements.
I have tried every possible solution in this thread
http://forums.asp.net/t/990365.aspx
but I'm still unsuccesfull, it always returns 1(=number of affected rows).
I do not want to create a seperate insert method as the auto-generated insertCommand perfectly suits my needs.
As suggested in the thread above, I have tried to update the InsertCommand SQL syntax to add SELECT SCOPY_IDENTITY() or something similar, I have tried to add a parameter of type ReturnValue, but all I get is the number of affected rows.
Does anyone has a different take on this?
Thanks in advance!
Stijn
I decided to give up, I can't afford to waste any more time on this.
I use the Insert statement after which I do a select MAX(id) query to hget the insert ID
If anyone should have a solution, I'll be glad to read it here
Thanks
Stijn
I successfully found a way to get the incremental id after insert using my table adapter.
My approach is a little different, I'm using a Store procedure to make the insert, so my insert command has all the values but the ID, I made the sp return the ID just calling:
SET #ID=SCOPE_IDENTITY()
and then
COMMIT TRAN
and last line will be
RETURN #ID
Then I searched my table adapter parameters for InsertCommand and set the #RETURNVALUE to the column of the incremental ID of the table, so when it's executed automatically put the return value on the id field.
Hope this help
You need to tell your table's table-adapter to refresh the
data-table after update/insert operation.
This is how you can do that.
Open the properties of TableAdapter -> Default Select Query -> Advnaced options. and Check the option of Refresh the data table. Save the adapter now. Now when you call update on table-adapter, the data-table will be updated [refreshed] after the update/insert operation and will reflect the latest values from database table. if the primary-key or any coloumn is set to auto-increment, the data-table will have those latest value post recent update.
Now you can Call the update as TableAdapterObj.Update(ds.dataTable);
Read latest values from the DataTable(ds.dataTable) coloumns and assign respective values into the child table before update/insert. This will work exactly the way you want.
alt text http://ruchitsurati.net/files/tds1.png