I'm currently working on Pentaho and I need to create this "Insert into select" statement from table1 into table2. I simplified the script on the image attached to make it easier to understand (Just one column field), I have the script in a "Execute SQL Script", the script works fine from MYSQL Workbench, but on Pentaho, it doesn't work. I've been reading and I set the table names with its proper syntax (Maybe there's an error there?) anyway I would really appreciate your help.
Thanks in Advance
Diego
Related
I'm not a DB person but something weird is happening in Access:
I'm trying to run this SQL command: UPDATE tbl_DirectorySet SET TempRootDir='D';
on this table:
It doesn't do anything! I mean the field is empty as before.
If I manually set the field with some value like "aaaaa", then after I run the SQL command I can see that the command worked as expected.
If you don't have any record in a cell, the UPDATE command won't work. Use INSERT instead. That's why it works when you first introduce "aaaaa" and then you UPDATE.
EDIT: this link may make you understand better the principles behind the basic SQL commands: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
I have two database named Main and OutputTax using Firefox SQLite database.My aim is to update database in OutputTax while data in Main is input by selecting certain columns.
The columns in Main are "Date", "Particular", "InvNoSimp", "InvNoFull", "AmountTaxSimp", "GSTSimp", "AmountTaxFull"
While I just need "Date","Particular","InvNoSimp","AmountTaxSimp", "GSTSimp", in OutPutTax database.
String query="insert into OutputTax SELECT
Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp, from Main";
Whenever I call this query, It shows Query does not return results.
Can anybody tell me what is the problem? Thank you, your answer is much appreciated!
Have you tried this
insert into OutputTax( Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp) SELECT
Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp from Main;
I am a novice Oracle User.
I want to move a table records from QA to Test environment. The table already exists in Test. Would it be something like this ?
insert into wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove ;
Any help is greatly appreciated.
Both the tables in both environments have same number of columns with same data types.
You can use database links in Oracle to do this.Create a database link in your test database called myQADBLink which points to your QA DB.
The code would look something like this
CREATE DATABASE LINK myQADBLink CONNECT TO <username> identified by
<password> USING
'<QA DBconnect string>';
SELECT 1 FROM dual#myQADBLink; -- This is to test if your dblink is created properly.
Now you can copy from QA to test by saying
INSERT INTO wKTest01.MyTableIWantToMove select * from wkQA01.MyTableIWantToMove#myQADBLink;
Yes, it actually exists, right like you put it.
Here is the full syntax guide for this: http://docs.oracle.com/cd/E17952_01/refman-5.1-en/insert-select.html.
Later, when you might place your tables at the different Oracle instances, google 'Orace DBLink' for the good ;)
Ive tried to execute below delete through SQL script in Pentaho Job, I get the error as
Unknown table 'a' in MULTI DELETE. Can somebody throw light on this. Is there any other way
to go around this?
DELETE a.* FROM pm_report.PM_CONCERTS_GQV_REPORT_TEST a
WHERE EXISTS
(SELECT 1 FROM pm_report.PM_CONCERTS_GQV_REPORT_TEST_3 b WHERE b.TM_EVENT_ID=a.TM_EVENT_ID
GROUP BY b.TM_EVENT_ID)
This is mysql right?
See similar solutions here - recommends removing the table alias.
Worth noting this is nothing to do with Pentaho, if you did it in a SQL client you'd get the same error. If you don't then the difference is probably in the jdbc driver version - may be worth checking that.
i can suggest these options:
dont use aliases
try this directly on your mysql and check if it works for you.
dont use pentaho like this : make a transformation and break apart the query to steps
with table input and lookup then delete the rows by row_id
its a little bit longer but a lot more undersrandable and easy to maintain.
"dont over optimize"
I am discovering Pentaho DI and i am stuck with this problem :
I want to insert data from a csv file to a custom DB, which does not support the "insert table" step. So i would like to use the sql script step, with one request :
INSERT INTO myTable
SELECT * FROM myInput
And my transformation would like this :
I don't know how to get all my data from the csv to be injected in the "myInput" field.
Could someone help me ?
Thanks a lot :)
When you first edit the SQL Script step, click 'Get fields' button. This is going to load the parameters(fields from your csv) into box on the bottom left corner. Delete the parameters(fields) you don't want to insert.
In your sql script write your query something like this where the question marks are your parameters in order.
insert into my_table (field1,field2,field3...) values ('?','?','?'...);
Mark the checkboxes execute for each row and execute as a single statement. That's really about it. Let me know if you have any more questions and if you provide sample data I'll make you a sample ktr file to look at.
I think you get the wrong way. You should get a cvs file input step and a table output step.
As rwilliams said, In cvs file input step Get fields; the more important, in table output there is a Database Fields tab. Enter field mapping is right choise.The guess function is amazing.
And more, system can generate target table create sql statement when target table not exists in target connection Db server.
Use the following code
with cte as
(
SELECT * FROM myInput
)
select *
into myTable
from cte;