how to use parameterized Query in after sql in datastage? - datastage

I have to create a table in DB2 and read the query from file in Before/After Sql tab in Datastage.
I am using DB2 connector for this.
I have also parameterized the query but getting below error-
an unexpected token was found '/'.
create table Temp as(#Query#) with data
can u help in suggesting how can i achieve this successfully. Thanks in advance

Try loading the entire query into the parameter, rather than just the table name.

Related

How to properly use plain SQL code in Postgresql?

I'm using pgadmin right now and this is the table I created. I'm trying to convert this wkb_geometry column into lat,lon geometry point.
When I tried to select this column and declare it as a variable so I can perform some conversion on it, I failed to do so by using plain SQL code such as "DECLARE #xxx VarChar". I looked it up and did see that plain SQL code doesn't always work in Postgres but haven't found a solution yet. Could someone point me a way to do it? Thank you so much!!

View query used in Data Factory Copy Data operation

In Azure Data Factory, I'm doing a pretty vanilla 'Copy Data' operation. One dataset to another.
Can I view the query being used to perform the copy operation? Apparently, it's a syntax error, but I've only used drag-and-drop menus. Here's the error:
ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A
database operation failed. Please search error to get more
details.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=Incorrect
syntax near the keyword 'from'.,Source=.Net SqlClient Data
Provider,SqlErrorNumber=156,Class=15,ErrorCode=-2146232060,State=1,Errors=[{Class=15,Number=156,State=1,Message=Incorrect
syntax near the keyword 'from'.,},],'
Extra context
1.Clear Schema and import Schema again.
2. This mostly happens when there are some changes to table schema after creating pipeline and datasets. verify once.
3.The schema and datasets should be refreshed when there are some changes in the SQL table schema.
4. For table name or view name used in the query, use []. ex: [dbo].[persons]
5. In datasets select table name
6. try to publish before testing.
I followed the same scenario and reproduced the same thing. I didn’t get any error as you can see, the above error mainly happens because of schema.
Source dataset:
In source dataset, I manually added and connected to SQL database with Sample SQL table.
Sink dataset:
In sink dataset, I added another SQL database with auto create table, write behavior: Upset, key column: PersonID.
Before execution there is no table on SQL database, then after the execution was successful, I got this sample output in azure SQL database.

, Drop column Error ora-00933 sql command not properly ended

I need to drop an column in my existing table. Not sure why below syntax is not working for me and getting 'ora-00933 sql command not properly ended'
DB Query:
ALTER TABLE employee DROP COLUMN TITLE;
Please suggest. Using oracle 12c version.
Thanks #learningloop for suggestions.
I tried after removing the semi-colon in the SQL and it worked out. I was using toad editor for the query execution.

postgres db trigger to log query type into another table

This problem scenario may sounds strange but I am trying to write a trigger to log the query type into another table and so far i havent been able to find anything on google
the database i am using is postgres
i.e.
if i have two tables; table1 and querylog(has a string field called querytype)
and a select query is executed on table1, i want to insert a row into the query log table with the querytype field populated with "select"
anyone have any idea how to reference the query type in a function that will be called by a trigger?
Triggers do not get called for SELECT queries, so that won't work.
If you want to audit queries, you can use the PostgreSQL log file or tools like pgaudit that hook into PostgreSQL to retrieve and log the information.

REORG command in db2

So I have been altering a table in QMF. After 3 alters I believe the table has gone into a pending reorg state so that I cannot alter it additionally. Am I correct in this assumption? If so what implications does this have and to get around it can I simply reorganize the table and continue altering it? If so, what does the syntax look like for reorganizing a table? I tried
REORG TABLE PIDJBIP.TABLE_NAME_T
and receive the error:
an unexpected token "PIDJBIP" was found following "REORG TABLE".
Expected tokens may include: "JOIN". SQL state = 42601.
I haven't gotten much help out of the IBM pages regarding this subject.
REORG is not an SQL statement, so it cannot be issued using a SQL interface (such as QMF). You will need to run it using the DB2 Command Line Processor.
Alternatively, you might use the administrative stored procedure, which you could call via QMF:
call sysproc.admin_cmd('reorg table PIDJBIP.TABLE_NAME_T')