I have been running a report in Oracle for my customer where they provide a list of id numbers. I import the id numbers into a table and run a query which includes this table. However, the customer would like the ability to run this report. I can create the report in SSRS and take a few id numbers, but not the entire list. I would like to know if I can create a procedure that would check the table for data, delete if it exists, then import the data from the parameter in SSRS into the table which SSRS can then run the query which includes the newly populated table. How would such a procedure look, and can that be called in SSRS with the parameter to include the id numbers that will be imported. I had thought of creating a temp table and populating it, but was advised that Oracle does not use temp tables, and I already have the table created within the database.
Related
I'm currently trying to create txt files from all tables in the dbo schema
I have like 200s-300s tables there, so it would takes up too much times to create it manually..
I was thinking for creating a loop.
so as example (using AdventureWorks2019) :
select t.name as table_name
from sys.tables t
where schema_name(t.schema_id) = 'Person'
order by table_name;
This would get all the table name within the Person schema.
So I would loop :
Table input : select * from ${table_name}
But then i realized that for txt files, i need to declare all the field and their data types in pentaho, so it would become a problems.
Any ideas how to do this "backup" txt files?
Using Metadata Injection and more queries to the schema catalog tables in SQL Server. You not only need to retrieve the table name, you would need to afterwards retrieve the columns in that table and the data types, and inject that information (metadata) to the text output step.
You have in the samples directory of your spoon installation an example on how to use Metadata Injection, use it, along with the documentation, to build a simple example (the check to generate a transformation with the metadata you have injected is of great use to debug)
I have something similar to copy data from one database to another, both in Oracle, but with SQL Server you have similar catalog tables as in Oracle to retrieve the information you need. I created a simple, almost empty transformation to read one table and write to another. This transformation has almost no information, only the database origin in the Table Input step and the target database in the Table Output step:
And then I have a second transformation where I fill up all the information (metadata) to inject: The query to perform in the Table Input step, and all the data I need in the Table Output: Target table, if I need to truncate before inserting, the columns from (stream field) and to (Table field):
So, i am a begginer on ORACLE and realy would apreciate your help.
I have 3 tables, EMPLOEES, PERSONAL_DATA and RECORDS. I want to create an UPDATE TRIGGER that when fires takes the old values of EMPLOOES finds the personal data of that updating emplooe on the PERSONAL_DATA table with the OLD id and insert all of that data( the OLD of EMPLOOES and the one fetched from PERSONAL_DATA) into the RECORDS table. I been triying to use the SELECT sentence to fetch information from the table PERSONAL_DATA, but the compiler throws me an error.
I need to create a sequence whose value is going to be read by call to .NEXTVAL in PL/SQL code and saved in more then one record of a specific table column, so my design doesn't require to define a PK on the aforementioned column.
I cannot find out how to edit the sequence tab in Oracle Data Modeler (I'm on version 4.1.1) when the PK checkbox is not selected (all the sequence related fields are disabled).
Any idea?
In the relational model, choose your DB and within that you will find sequence as an item to create. You can also create other types of object here.
I want to create a table (lets say table_copy) which has same columns as other table (lets call it table_original) in Oracle database, so the query will be like this :
create table table_copy as (select * from table_original where 1=0);
This will create a table, but the constraints of table_original are not copied to table_copy, so what should be done in this case?
Only NOT NULL constraints are copied using Create Table As Syntax (CTAS). Others should be created manually.
You might however query data dictionary view to see the definitions of constraints and implement them on your new table using PL/SQL.
The other tool that might be helpful is Oracle Data Pump. You could import the table using REMAP_TABLE option specifying the name for the new table.
Use a database tool to extract the DDL needed for the constraints (SQL Developer does the job). Edit the resulting script to match the name of the new class.
Execute the script.
If you need to do this programmatically you can use a statement like this:
DBMS_METADATA.GET_DDL('TABLE','PERSON') from DUAL;
I am trying to import an excel spreadsheet into Oracle using Toad. The gotcha is that the table I am importing into has a primary key field that I use a "sequence".nextval to populate in a normal stored procedure insert.
Using the Toad import wizard, I tried putting in 'table_seq.nextval' as an expression but when I execute the wizard at the end I get the error: Could not convert variant of type (UnicodeString) into type (Double).
So is it possible to import Excel data using sequence.nextval with the Toad import wizard or is there a better way?
I also gave some thought to just letting Excel generate the key by starting the seed beyond what is currently in the table. But being new to Oracle, would this mess-up the sequence I have setup for the table? For example, if before the insert, the next available ID is say 500 and the inserts from Excel inserted rows from 500 to 5000, would the next execution of a stored procedure for that table's sequence try to use 500?
Thanks in advance!
Yes, the sequence will remain at 50, and you'll get primary key violated exception when using stored procedure.
That's because sequences are not linked to tables in any way. And cannot be linked. They are separated objects.
The best approach I see is to use a trigger on insert for each row which will set the id to nextval.
Code example:
CREATE OR REPLACE TRIGGER trg_table_name_set_id
BEFORE INSERT
ON table_name
FOR EACH ROW
BEGIN
SELECT table_seq.nextval INTO :new.id FROM DUAL; --id would be the id column in your table
--or, if you are on 11g, simply
--:new.id := table_seq.nextval;
END trg_table_name_set_id;