We have a Oracle table which consists of following columns: user,code,date,number,origin.eg:
|user, code, date, number, origin|
|--------------------------------|
|stah, LK, 10-1, 20091, WEST |
|hats, LJ, 12-2, 30001, ESTA |
This table already has 1000 users. Now we want to add another 500 new users to this table and also grant all those 500 users same code->{'LD','LM','MK',CK'}.i.e each user should have same code (And date,number,origin can be null).
I have 500 users in excel. Can someone help me to figure out how to insert these into a table?
Build your script manually in excel by using formulars:
user code date number origin skript
stah LK 10-1 20091 West =CONCAT("INSERT INTO mytable values(""";A2;"""";""";B2;"""";""";C2;"""";""";D2;"""";""";E2;"""";");")
hats LJ 12-2 30001 ESTA INSERT INTO mytable values("hats"";B2;"";"12-2"";D2;"";"ESTA");
First row shows formular - second shows the result..
You could use SQL Developer to import data from spreadsheet into table. Look here: http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev/r30/SQLdev3.0_Import_Export/sqldev3.0_import_export.htm#t3
You can use free data migration tool PDI which is very helpful and
manageable
You can schedule it by using windows or linux scheduler
here is a tutorial link how it migrate excel to oracle
https://www.youtube.com/watch?v=RDxdy_8mOa0
Related
I have a table that looks like this:
Sku_Code Channel Rank Category Website Date
123 US 28 Toys www.foo.com 2021-06-07
123 US 13 Games www.lolo.com 2021-06-07
328 CA 12 Toys www.lo.com 2021-05-12
123 US 2 Games www.foo.com 2021-06-05
I would like to pivot this table so all ID information falls in one row...like this:
Sku_Code Channel Category Category_1 Website Website_1 Date
123 US Toys Games www.foo.com www.lolo.com 2021-06-07
328 CA Toys www.lo.com 2021-05-12
123 US Games www.foo.com 2021-06-05
It's a fairly large table so wondering whats the best/fastest way to do this? I know there is a pivot function I could use but do not now how to apply it in this situation.
I'm fairly new to SQL so any help would be appreciated.
It's not clear whether an ID can have an arbitrary number of categories. If so, this is not possible in normal SQL alone. The SQL language has a strict requirement for the number and types of columns to be known at query compile time, before looking at any data.
That doesn't mean what you want to do can't happen at all... just that the solution will be more involved. For example, you may need to do the pivot in your reporting tool or client code. The other alternative is dynamic sql over three steps: First, run a query to determine how many categories you will need. Second, use the information from step one to build a new SQL statement on the fly, probably involving an additional join back to the same table for each category, using the PIVOT keyword, or both. Finally, execute the SQL statement built in step two.
This question already has an answer here:
Why is my query not updateable?
(1 answer)
Closed 5 years ago.
I have a master table tblBudget which contains entries like
ProjID Type Budget Active
101 ROM 100 No
101 PLE 110 No
101 DLE 120 Yes
102 ROM 200 No
102 PLE 210 Yes
Every month I get an excel which i import and store into a temp table tblMonthlyBudget that contains entries like
ProjID Type Budget Active
101 EAC 100 Yes
102 DLE 110 Yes
I wrote an update query that tries to update all the Active entries in tblBudget to No so that new records which are the most active could then be inserted. My query is
UPDATE tblBudget
INNER JOIN tblMonthlyBudget
ON tblBudget.ProjectId = tblMonthlyBudget.ProjectID
SET tblBudget.Active = false
However I get the error
operation must use an updateable query
even though the query seems to show correctly in the datasheet and design view. I get it only while executing the query . I tried searching for the error and have tried all sorts of combinations without success. Any alternative approach is welcome.
I suspect this is because the temporary table contains more than one records.
I have tried to replicate your problem using the data and table structures, you provided. But the UPDATE works as I would expect. It will still work if there are repeated entries in tblMonthlyBudget - it just updates an excessive number of times. Please read mcve and alter your question with data and table structure that actually produces your error. Otherwise we have almost zero hope of helping you.
I have two datasets, one in SSMS and one in Oracle I'm trying to combine through SSRS. Technically I have two questions regarding the results I'm getting.
Dataset 1:
DataSet1 - Sales - MS
Part Location Transaction_date QTY_SOLD
1234 New York 06/01/2017 1
1235 New York 06/01/2017 4
Dataset 2 - Returns - Oracle
Part Location Purchase_Date QTY_RTN Reason
1235 New york 06/01/2017 2 Broken`
What I'm wanting to get:
Part Location Date QTY_SOLD QTY_RTN Reason
1234 New York 06/01/2017 1 NULL NULL
1235 New York 06/01/2017 4 2 Broken
I have lookup expressions set to join on part, location, date for qty_rtn and reason columns.
Part one, 1234 with no returns does not show up. The first dataset should return ~1400 items. The second dataset should return the same theoretically, but since that info is manually entered the purchase_date does not always match the transaction_date (this is fine. half the purpose of this is to find those mistakes and get someone to go back and correct the data). When I run the query, I get ~400 items.
Part two, when I do a preview from within Studio, the MS and Oracle data shows up. When I pull from the web interface, only the MS data shows up. I've checked that the credentials on both sides are correct and have the correct connection strings as well.
Any thoughts are appreciated.
Not sure what was broken, but I wound up deleting and re-creating the report from scratch and it works with all the data as it's supposed to. Web interface is also not missing data.
I'm using an MRP system for stocking inventory where I work. The interface it self isn't the best, so I have decided to open up the database file and do everything manually. I'm having some issues though. I'm trying to sort my database by using ORDER BY. I'm not getting the results I thought I would. It is showing them in this format:
1
10
100
101
101
11
110
111
etc
Instead of
1
2
3
4
5
etc
This is my query
SELECT *
FROM tblStockItems
Order By (`MasterPNo`)
I'm currently working in access, and then database is in the JET format. If you're wondering why I am using access instead of the MRP Interface, it is because later down the line I will be needing to re-organise the whole stock system, so a lot of fields will have their product numbers changed.
Thanks for reading
if possible, change the column type to number
if not, a cast should do it:
ORDER BY Val(MasterPNo)
Short background: I have an SQLite database, a couple of gb in size and growing. It contains a bunch of very simple tables. Each table consists of a 64-bit integer primary index field (TStamp) and a value field (Val). The field TStamp is actually an long-int representation of a date-time. The tables have widely varying row-counts and somewhat variable content types, but that shouldn't matter. A master table (tbIndDate) holds a full range of dates, has the same primary index (TStamp) as the other tables, and holds human-readable date-time in its Val field. For instance,
The master index table, named tbIndDate:
TStamp Val
634082688000000000 5/1/2010 0:00:00
634082691000000000 5/1/2010 0:05:00
634082694000000000 5/1/2010 0:10:00
634082697000000000 5/1/2010 0:15:00
etc etc
A sample table for automation tag 6FI1.PV, named tb6FI1%PV:
TStamp Val
634085793000000000 41.7
634085796000000000 42.83
634085799000000000 41.44
634085802000000000 40.43
634085805000000000 39.78
etc etc
Getting data into the tables is handled by a little vb.net program, and when a new automation tag is added to the capture list then the program creates a new table using the automation tag name, and begins populating it. That all works real slick.
OK. I've started building a tool for getting data out of the database. It works great for inner joins:
SELECT [tbIndDate].[Val] AS 'Timestamp',[tb6FI1%PV].[Val] AS '6FI1.PV',
[tb6FI34%PV].[Val] AS '6FI34.PV',[tb6AI32%PV].[Val] AS '6AI32.PV'
FROM [tbIndDate],[tb6FI1%PV],[tb6FI34%PV],[tb6AI32%PV]
WHERE [tbIndDate].[TStamp]=[tb6FI1%PV].[TStamp]
AND [tbIndDate].[TStamp]=[tb6FI34%PV].[TStamp]
AND [tbIndDate].[TStamp]=[tb6AI32%PV].[TStamp];
This returns:
Timestamp 6FI1.PV 6FI34.PV 6AI32.PV
1/1/2013 0:00:00 42.4679 1.499 0.8439
1/1/2013 0:05:00 40.3628 1.5048 0.8435
1/1/2013 0:10:00 38.2652 1.5028 0.8436
1/1/2013 0:15:00 37.8582 1.5029 0.8436
Yay! :)
I've also gotten some averaging and time-interval queries working.
However, because tag data is not all available for all dates, I'd like to create the option to list all dates in the master index even if some of the tag tables do not have matching data.
A SELECT query with a left outer join, in other words. Everyone knows that. The data might look like:
Timestamp 6FI1.PV 6FI34.PV 6AI32.PV
1/1/2013 0:00:00 42.4679 1.499 NULL
1/1/2013 0:05:00 40.3628 1.5048 NULL
1/1/2013 0:10:00 38.2652 NULL NULL
1/1/2013 0:15:00 37.8582 NULL 0.8436
Trouble is, none of the SQL I've tried has worked. Here's one that didn't go:
SELECT [tbIndDate].[Val] AS 'Timestamp',[tb6FI1%PV].[Val] AS '6FI1.PV',
[tb6FI34%PV].[Val] AS '6FI34.PV'
FROM [tbIndDate],[tb6FI1%PV],[tb6FI34%PV]
LEFT JOIN [tbIndDate] ON [tbIndDate].[TStamp]=[tb6FI1%PV].[TStamp]
LEFT JOIN [tbIndDate] ON [tbIndDate].[TStamp]=[tb6FI34%PV].[TStamp];
The error was "SQL error or missing database, ambiguous column name: tbIndDate.Val"
I've tried copying the syntax from several examples, but none are exactly the same and my attempts fail.
Am I doing the aliases wrong? The square brackets to accommodate special characters in table names? I'm a complete SQL beginner, so don't hold back with the advice.
It looks like the problem is that you're trying to join [tbIndDate] several times. Try this:
SELECT [tbIndDate].[Val] AS 'Timestamp',[tb6FI1%PV].[Val] AS '6FI1.PV',
[tb6FI34%PV].[Val] AS '6FI34.PV'
FROM [tbIndDate]
LEFT JOIN [tb6FI1%PV] ON [tbIndDate].[TStamp]=[tb6FI1%PV].[TStamp]
LEFT JOIN [tb6FI34%PV] ON [tbIndDate].[TStamp]=[tb6FI34%PV].[TStamp];