SAP PO JDBC SENDER CHANNEL ISSUE WITH QUERY WHICH CONTAINS VIEW - sap

I have requirement to extract data (daily end of the day) from portal which have oracle database 11g
they created one view given to me i.e Select * from "viewname";
i tried to execute this in query sql statement in jdbc sender channel but its not picking up showing an error a issue with select * from "viewname";
Please anybody let me know what is the cause to this and another question if the view will update the next day that will pick old and new data that will cause an issue how can i avoid these?
Please help me to do this.
Regards,
Abdul

Related

Identical SQL query works on some tables but errors out on other tables same in the same DB

I'm a finance person (little programming background) so I maybe asking something obvious for database programming experts but will appreciate any advice
Background:
I'm accessing Oracle NetSuite database via ODBC from Microsoft SQL Management Studio
Connection as a Linked Server is established successfully
I'm trying to execute the following SQL statements:
select * from [NETSUITE_SB2].[SB-B].[Administrator].[VARIANCE] -- success
select * from [NETSUITE_SB2].[SB-B].[Administrator].[WTAX_JOB] -- "Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "NETSUITE_SB2" does not contain the table ""SB-B"."Administrator"."WTAX_JOB"". The table either does not exist or the current user does not have permissions on that table."
Upon some testing, it appears that whether the query is successfully run depends on whether the table name contains "_" (underscore) - for all tables without underscore I've tried, it worked, for all tables with underscore that I've tried, it failed.
Can anyone help me figure out how to overcome this?
Thanks in advance!
Instead of using a 4-part name in SQL Server and having SQL Server generate a query for the linked server, try using the OPENQUERY function and passing a query in the target system's SQL dialect directly. Something like:
select *
from OPENQUERY([NETSUITE_SB2], 'select * from [SB-B].[Administrator].[WTAX_JOB]' )
I just encountered this myself in a new instance that I just set up. I had been using Suite Connect for 4+ years without running into this issue before.
I believe the issue with the situation here is the "[SB-B]" part of the name because it contains the "-" dash. I found that a "," comma or "." period were the issue with my name [Acme, Inc.]. Ether the period or comma threw the error.
The second part of the 4-part name is the NetSuite [Company Name] under General Settings Company Info. I changed the name in NetSuite and removed the comma and period and the problem went away. Maybe most special characters cause the issue?
Just remember you'll have to update your second part name in each query you created before.
While using OPENQUERY is a solution, I just don't like the extra quotes needed so I prefer normal SQL.

SQL select by field acting weird

I am writing this post because I have encountered something truly weird with an SQL statement I am trying to make.
Context:
I am developing an app which uses JPA in the backend to persist / retrieve objects to/from a postgres database.
Problem:
During some tests I have noticed that when a particular user adds entries in the database and later I try to fetch them by his facebook id, the result is an empty list, even though the entries are there in the database. Doing a select statement on the database returns no rows. This does not happen with other users.
I have noticed that the mentioned user's facebook id is slightly longer then others. I do not know if and how this affects this situation.
Interesting part:
When during debugging I created an entry not programmatically, but manually with a SQL INSERT statement directly on the database (marked red on the 1st screenshot), I could fetch the data by facebook id both in my app and with a select statement.
Do you have any ideas what is going on here?
Please check the screenshots:
result of select * from table:
result of select * from table where user_facebook_id = 10215905779020408 :
Please help,
Thanks

SQL Server Query in Access

I currently have a bunch of queries that have been input into macros, which are called by one parent macro in Access 2007.
At the end of the process I have to switch to the central DB from which we have several ODBC connections and run this query:
update A
set A.PCP_End_Date = B.PCP_End_Date
from dbo.PCP_History A
outer apply (SELECT (min(PCP_Start_Date) -1) PCP_End_Date from dbo.PCP_History x
WHERE x.PCP_Start_Date > A.PCP_Start_Date AND x.PartD_Rx_ID=A.PartD_Rx_ID)B
Is there any way to do this in Access?
What I'm trying to do is say I have two records:
First record is original PCP, PCP_Start_Date, PCP_End_Date (null), and PCP_Update_Date
Then I have a new record:
new PCP, PCP_Start_Date (04-01-2014), PCP_End_Date(Null),PCP_Update_Date(DATE())
I want to set the first records PCP_End_Date to the day before the new records PCP_Start_Date - so in this scenario it would be 03-31-2014 to the end date of the first record.
Hope this makes sense. Let me know. Thanks!
So I solved this myself.
It's called a Pass-through query.
Because I identify the ODBC connection, I put this same syntax into a query, but select Pass-through. A properties window comes up and asks you to select your ODBC connection str.
This worked very well. Awesome.

How to Query Database Name in Oracle SQL Developer?

How do I query the database name in Oracle SQL Developer? I have tried the following and they all fail:
SELECT DB_NAME();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? Even this one fails too:
show tables;
EDIT: I can connect to the database and run queries such as:
select * from table_name_here;
EDIT 2: The database type is Oracle, this is why MySQL queries are failing. I thought it was related to the database client not the database itself. I was wrong. I'll leave the question as is for other as lost as I was.
Once I realized I was running an Oracle database, not MySQL, I found the answer
select * from v$database;
or
select ora_database_name from dual;
Try both. Credit and source goes to: http://www.perlmonks.org/?node_id=520376.
try this:
select * from global_name;
You can use the following command to know just the name of the database without the extra columns shown.
select name from v$database;
If you need any other information about the db then first know which are the columns names available using
describe v$database;
and select the columns that you want to see;
I know this is an old thread but you can also get some useful info from the V$INSTANCE view as well. the V$DATABASE displays info from the control file, the V$INSTANCE view displays state of the current instance.
Edit: Whoops, didn't check your question tags before answering.
Check that you can actually connect to DB (have the driver placed? tested the conn when creating it?).
If so, try runnung those queries with F5
To see database name,
startup;
then type
show parameter db_name;
DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.

Eclipse SQL Code Assist

Is there some trick to getting SQL Code Assist working in Eclipse? I have opened an SQL scrapbook page, assigned it a type, connection name and database.. and tried to type some SQL.
If I enter a schema name..
select * from public.
It shows me a list of tables.. so I can select one and get:
select * from public.batch_job_instance
but that's it. Once I start on the WHERE clause there is no help. It doesn't matter whether I put public or public.batch_job_instance (or just hurl obscenities at my monitor for five minutes - I tried that a few times) there is no further "assistance".
How exactly do I get this code assist to assist me?