Using Pentaho and Spoon. i have a combination of transforms that
Creates a new table name variable (TABLENAME)
In a separate transformation I'm attempting to use this table name
first step creates a list of column names (generate rows step)
second step uses these table rows and the table name from the previous transformation (Table output step)
When i click the SQL button on the Table Output Step, it returns the correct create table statement. (although it doesn't replace the placeholder, it does return a CREATE TABLE....)
when i attempt to run these two transformations in-line, it complains that the table with my generated name does not exist. It appears that instead it must be trying to INSERT into this generated table, when the sql button returns a CREATE.
how do i make pentaho create a table with a generated name stored in a variable?
The Table Output step doesn't create the table, the SQL button is like a help button, it only allows you to copy the DML to create the table and paste it to wherever you want to run it, but that step doesn't run the create table order.
You'll need a separate transformation or job to create the table before inserting into it. For jobs there's an action to run SQL statements, one similar step for transformations.
Related
I am trying to run SQL on Oracle live and I give only one input but the output is printed multiple times, I don't know why this is happening.
You have executed it two times. First time table has been created and a row has been inserted.
Second time table creation failed but a row has been inserted again.
And your select query is correctly showing both rows.
Drop the table and execute the query again.
The SQL state is maintained between runs.
The first time you execute the script, it creates the table and inserts a row into the table and then you select the single row.
The second time you execute the script, it tries to create the table but finds that it already exists and raises an ORA-00955: name is already used by an existing object exception and then will insert the row into the table (so you now will have two rows in the table) and then you select both rows.
If you were to run it again, it will fail to create the table again, insert another row and show you three rows... and so on.
Instead of re-running the entire script (or adding DROP TABLE statements in), what you can do is delete the CREATE TABLE and INSERT statements after they have been run the first time and just edit the SELECT statement to give the output you want.
If you want to see the entire history for the session then click on the "Actions" button and then "View Session".
If you want to drop all the changes and re-run the script from the beginning then use "Actions" then "Reset Session".
In SQL Server Database Engine I have a table named Table A.
I deleted the table using graphical interface, but when I wanted to create a table with same name, the error shows
The object already exists
What is the remedy of this situation?
The following steps should help you track down what is going on and help you create your table:
Right-click on your database and select refresh
Verify that your table does not exist under this database.
If you table is
not shown here, then very likely your table is displayed under the
master database.
To create a table in your selected database,
first select the database and then run your query.
A better
option for number 4, just to be sure you are specifying the correct
database is to run the command use dbname; (where dbname is
the name of your database). Do this on the line above your create table code.
HI I am generating schema script for a database, but when i finish creating it and and look at the script it gives create table statement for a table but not including all column in it also it generates alter table add column statement for the same tables but for missing columns which are left in create table statement.
see the attached screenshot.
Assuming the question is "why does it not create all of the columns in the CREATE TABLE statement" ...
You'll notice that between the CREATE TABLE and the ALTER statements, the value for SET ANSI_PADDING is altered. As the documentation notes, the setting's value is taken into account at the point in time when a column is created.
There's no way to override this setting in-line with the declaration of a column.
Since your table apparently contains a mixture of columns, some of which are defined with the setting ON and others with it defined OFF, there's no way to write a single CREATE TABLE statement that creates all of the columns in one go.
I have an SSIS project that does the following:
Executes a sql task (in the control flow) that creates (and populates with data) 4 tables. After that executes I have a Data Flow task that references those 4 tables, joins them, then uses the destination assistant to create a new table called "Step". Then, those 4 tables are deleted leaving only the "Step" table.
However, when I try to run it it throws an error because technically I am referencing 4 tables that do not yet exist. How do I work around this?
I would do this the same way you have to handle temp tables in a data flow source.
Use a stored procedure for your datasource, and start it with something like:
IF 1=0
SELECT
{dummy-valued column list that matches the column names and datatypes of your expected output}
ELSE
{your real stored procedure code}
i have created tables and views, and insrted some test data, but i want to know where i can get the sql code that i used to create and insert the data, i tried to look in the sql history, but its no thier, thanks :))
You can get the SQL required to create and populate the table:
1) For the create table DDL, go to the Tables node and select the table, then click on the SQL tab and copy the DDL it displays.
2) For the insert DML, right-click on the table name in the Tables node and select Export Data then Insert... and fill in the wizard. You can also get the create table DDL this way rather than as I said in step 1.
history F8 should show you everything that has happened in that tab within SQL Developer (for instance file xyz.sql).
if you cannot find the history or the ddl that you wish, you ought to be able to get the ddl 'simply' enough
by
select *
from addmas
where colA = 'my criteria'
;
then clicking F9, then right clicking onto the grid and export data to 'insert'
and that will create the insert statments for you (keep in mind to put in a table name)
to get the CREATE TABLE/VIEW (or object, not the alter tables) you may right click on the table name,
select 'edit' then go down to DDL (create). If you use that tool for your edits it'll also show you the ddl for the alters