Data Model - SQL Query
Hi everyone,
Hopefully someone can point me in the right direction.
I have the following SQL in the Data Model type SQL Query.
select * from ap_invoices
This select statement is not return any rows from the view but does so from sqlplus.
I am using BIP 10.1.3.4.1 and have setup the EBS Security model.
What am i doing wrong, is there some setup i am missing?
Do i need to use a different security model for BIP?
please help
thankyou.
Hi
AP_INVOICES is a view as you know, its based on the ORG_ID being set when you select from it. Im thinking that when you just use select * from AP_INVOICES in BIP. Its unaware of your org id and its not setting it for you when you run a query, so its not returning data. Two options:
1. Use a data template and in the pre-fetch trigger set the org context. Just like you might have in an Oracle Report. Data templates are very powerful and provide everything OReports does in EBS incl triggers and flex extensions
2. Use the AP_INVOICES_ALL table and set the org id in the query where clause.
Both approaches need for you to know the org id you want to set. The security integration you have will not have this ie it does not pass it when the user logs on. I guess as you have a report folder for every responsibility you could hard code the org id into the reports in a given folder. Or you could add it as a parameter to the report for the user to fill out.
The level integration just does not quite go far enough at the moment to handle the org and therefore the org views.
hope this is clear
Regards
tim
Similar Messages
-
Can we use session variables in BI publisher's Data Model SQL Query?
Hi Experts,
We need to implement Data level security in BI Publisher 11g.
In OBIEE we do so by using session variables, so just wanted to ask if we can use the same session variables in BI Publisher as well
ie can we include the where clause in the Data Models SQL Query like
Where ORG_ID = @{biServer.variables['NQ_SESSION.INV_ORG']}
Let me know your views on this.
PS: We are implementing EBS r12 security in BI Publisher.
ThanksRead this -> OBIEE 11g: Error: "[nQSError: 23006] The session variable, NQ_SESSION.LAN_INT, has no value definition." when Creating a SQL Query using the session variable NQ_SESSION.LAN_INT in BI Publisher [ID 1511676.1]
Follow the ER - BUG:13607750 - NEED TO BE ABLE TO SET A SESSION VARIABLE IN OBIEE AND USE IT IN BI PUBLISHER
HTH,
SVS -
How to aggregate data in SQL Query
Hi,
I have Table1 field1 and field2. Combination of these fields form the key of this table.
Next I have Table2 with field3 and field4. field1 is the unique key for this table.
My query is:
select T2.field4||','||T1.field2 from T1 inner join T2 on T1.field1 = T2.field3;
In the result I want to aggregate the data by T2.field4
How do I that? Please help
Thanks in advance,
RajaHow to aggregate data in SQL Query By using aggregate functions and group by:
SQL> select object_type, count(*), sum(decode(status,'VALID',0,1)) inv_obs
2 from all_objects
3 group by object_type;
OBJECT_TYPE COUNT(*) INV_OBS
CONSUMER GROUP 2 0
INDEX PARTITION 970 0
TABLE SUBPARTITION 14 0
SEQUENCE 226 0
SCHEDULE 1 0
TABLE PARTITION 349 0
PROCEDURE 21 0
OPERATOR 57 0
WINDOW 2 0
PACKAGE 313 0
PACKAGE BODY 13 0
LIBRARY 12 0
PROGRAM 9 0
INDEX SUBPARTITION 406 0
LOB 1 0
JAVA RESOURCE 771 0
XML SCHEMA 24 0
JOB CLASS 1 0
TRIGGER 1 0
TABLE 2880 0
INDEX 4102 0
SYNONYM 20755 140
VIEW 3807 72
FUNCTION 226 0
WINDOW GROUP 1 0
JAVA CLASS 16393 0
INDEXTYPE 10 0
CLUSTER 10 0
TYPE 1246 0
EVALUATION CONTEXT 1 0 -
Please help creating data model where query has & in select
Below is the actual code of the part of select having a problem.
When I had '&' instead of chr(36), a window opens up saying 'Please enter values for lexical references in sql then has *&' and empty box and check box then flex field.
So I replaced '&' with chr(36) below
After I put the code in, it is asking me the question ====>
'Do you want to create a bind parameter? : //wwwapps.ups.com/WebTracking/processInputRequest?sort_by
,'=HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status'||CHR(36)||'tracknums_displayed=1'||CHR(36)||'TypeOfInquiryNumber=T'||CHR(36)||'loc=en_US'||CHR(36)||'InquiryNumber1='||mbl.tracking_number||CHR(36)
||
'track.x=0'||CHR(36)||'track.y=0","'||mbl.tracking_number||'")' "Tracking Link (Click to Track)",Hi,
Looks like no more problems creating data models after replacing the '&' and ':' with their chr(x) counterparts. But when they I run the report, it shows the hyperlink code below instead of the hyperlink tracking number they can just click on. Also when I try the query in toad, it works.
=HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=&track.x=0&track.y=0","") -
Failing to import data using SQL query
I am trying to import data from a sql query to analysis service in SSDT. i went to model > import from data source >Microsoft SQL Server and i chose from query. I typed my query which works fin in SSMS and when i press import if gives me a error. what
is going on please help here is the error
DirectQuery error: All tables used when querying in DirectQuery Mode must be from a single relational Data Source.
here is my query:
USE AdventureWorks2012;
SELECT SalesPersonID, [29484] Brian, [29485] Peter, [29486] Frank, [29518] Sarah, [29519] Janet, [29520] Alice, [29608] Martin, [29609] Patrick, [29610] Wasu, [29780] Samanyika, [29781] Vladmire
FROM
SELECT SalesOrderID, SalesPersonID, CustomerID
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
As P PIVOT
COUNT (SalesOrderID) FOR CustomerID IN ([29484], [29485], [29486], [29518], [29519], [29520], [29608], [29609], [29610], [29780], [29781])
AS PVT
ORDER BY SalesPersonID ASC;Hi,
When importing data from relational data source, the steps are:
In SQL Server Data Tools (SSDT), click the Model menu, and then click Import
from Data Source.
On the Connect to a Data Source page, select the type of database to connect to, and then click Next.
Follow the steps in the Table Import Wizard. On subsequent pages, you will be able to select specific tables and views or apply filters by using the Select
Tables and Views page or by creating a SQL query on Specify a SQL Query page.
As we can see on the steps, we need to select one database, so we needn't to write "USE AdventureWorks2012" on the query.
Reference:Import from a Relational Data Source
Regards,
Charlie Liao
TechNet Community Support -
Need help in UPDATE data in SQL Query
Hi all,
I am trying to update data in the sql table as per below screenshot but couldn't able to do it. Can anyone help to update the data as I mention in screenshot.Appreciate you help.Thanks.
Yellow highlighted columns are source
Green highlighted columns are target
Colored data should be update as per source data in sql table.Data is not static as it might have more rows to update and query should be bit dynamic.
Maruthi...You have already asked this question once. You did not get any good answers, because you the information you gave was insufficient. And I'm afraid that the information is still in sufficient.
Or more exactly, from the example you have given, the answer is: can't be done. And the reason it can't be done, is as I explained in response to you first thread: there is no information in the data to from which we can deduce that Clorox Company
should be under "Week 1-1,K.B,F". The fact that rows are listed in a certain order in the screenshoot is of no importance, because a table is an unordered object.
But you said in another post that you have a timestamp column. Maybe that column is usable - maybe it is not. But at least it is a key that you have more columns that the ones you show.
The best way to get help with this type of problems is to post:
1) CREATE TABLE statement for your table(s).
2) INSERT statements with sample data.
3) The desired result given the sample.
4) A short description of the actual buisness problem you are trying to solve.
5) Which version of SQL Server you are using.
This makes it easy to copy and paste into a query window to develop a tested solution. Screenshots with an insufficient amount of data is not going to help you very much.
Erland Sommarskog, SQL Server MVP, [email protected] -
Help needed in Exporting tables data through SQL query
Hi All,
I need to write a shell script(ksh) to take some of the tables data backup.
The tables list is not static, and those are selecting through dynamic sql
query.
Can any body tell help me how to write the export command to export tables
which are selected dynamically through SQL query.
I tried like this
exp ------ tables = query \" select empno from emp where ename\= \'SSS\' \"
but its throws the following error
EXP-00035: QUERY parameter valid only for table mode exports
Thanks in advance,Hi,
You can dynamically generate parameter file for export utility using shell script. This export parameter file can contain any table list you want every time. Then simply run the command
$ exp parfile=myfile.txt -
Hi,
I have a search form with 1 field (date picker) - the user chooses a date and a report based on a sql query is shown.
I want the report to be based on only the month and year, and not the particular day.
If there is a date picker (or something similar) for only month and/or year, then I can change my form, but I don't see this option.
So, I'm trying to write my query to ignore the Day portion in the search form and just do a search based on the month and year, but i'm having trouble with this.
This is my query...
select d.dept, count(e.emp_id) "No. of Employees"
from dept d, employees e
where e.date_created = trunc(:P13_DATE, 'MONTH YYYY')
and d.dept_id = e.dept_id
group by dept
order by dept
How do I write the where clause so that the search is done only on month and year?
Or otherwise, how can I change the search form to exclude the day from the date?
Thanks.Hi,
Oh, the invalid number is the result of :P13_DATE being a string value. all item values are actually strings (or varchar2 if you like) when you referencing them with ':Px_ITEM' format. With the pl/sql function there are 2 possible ways to reference item, namely the function: V('Px_ITEM') and NV('Px_ITEM'). Although in SQL varchar2 => number conversion can be dealed with by the SQL engine.
Unfortunally there is no pl/sql method for getting a DATE of an date-picker item (based on its format mask etc.). Patrick Wolf has added this function in his ApExLib framework, function DV. I find this a nice extension. -
Data Display -- SQL Query?
Hi
This might be simple but, I have no idea.. how to achieve this via a simple SQL Query..
Data in a column :
1
5
6
15
25
30
35
Should do a SELECT showing like this..
1 5
6 15
25 30
35 NULL
Thanks!create table t1
(numcol number);
insert into t1 values(1);
insert into t1 values(5);
insert into t1 values(6);
insert into t1 values(15);
insert into t1 values(25);
insert into t1 values(30);
insert into t1 values(35);
commit;
select odds.numcol, evens.numcol
from
select numcol
,row_number() over (order by numcol) rn
from
select numcol
,row_number() over (order by numcol) rn
from t1
where mod(rn,2) <> 0
) odds
select numcol
,row_number() over (order by numcol) rn
from
select numcol
,row_number() over (order by numcol) rn
from t1
where mod(rn,2) = 0
) evens
where odds.rn = evens.rn (+);
NUMCOL NUMCOL
1 5
6 15
25 30
35 -
How to create a Matrix table using this data in SQL Query Analyzer
Hello all,
I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
my table Format is
city1 city2 Distance--------------------------------------------------------
Mumbai Delhi 100
Delhi Banaras 50
Mumbai Rajasthan 70
Banaras haryana 40
Mumbai Mumbai 0
784 entries
there are 784 cities each having link to other
Now i want my output as
Mumbai Delhi Banaras haryana
Mumbai 0 100 -- --
Delhi 100 0 50 --
Banaras
haryana
respective distance from one city to other should be shown
final Matrix would be 784*784
I am using SQL Query Analyser for this
Please help me in this regardI'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."
-
How to display contineous 10 dates from today date using SQL query
Hi All
I need a requirement of displaying 10 dates and numbers contineously, I have written a query for getting 10 numbers like this
select rownum from dual where rownum < 10 connect by rownum = level;
But i am not able to get the dates, Can any one help me ?Hi Satyaki,
No issues on my 9.2.0.8 client.
SQL*Plus: Release 9.2.0.8.0 - Production on Sat May 3 09:49:17 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn test/test@db10g
Connected.
SQL> select rownum, trunc(sysdate) + rownum from dual where rownum <= 10 connect by rownum = level;
ROWNUM TRUNC(SYS
1 04-MAY-08
2 05-MAY-08
3 06-MAY-08
4 07-MAY-08
5 08-MAY-08
6 09-MAY-08
7 10-MAY-08
8 11-MAY-08
9 12-MAY-08
10 13-MAY-08
10 rows selected.
SQL> Regards -
I need to denormalize data in sql query, please help!
With the query
select ref, start_time, end_time, person
from appointments
I get, eg:
REF START_TIME END_TIME PERSON
1234 10:00 11:00 USER1
1234 10:00 11:00 USER2
The users want to see it like this:
REF START_TIME END_TIME PERSON
1234 10:00 11:00 USER1, USER2
How do I do this just in sql?
cheers
Tracey.Apologies, my mistake, I forgot to connect by the ref as well...
(Note: you can ignore the CAST to VARCHAR2(40) as that just helped me get the formatted output.)
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1234 as ref, '10:00' as start_time, '11:00' as end_time, 'USER1' as person from dual union all
2 select 1234, '10:00', '11:00', 'USER2' from dual union all
3 select 345, '11:00', '12:00', 'USER3' from dual)
4 -- END OF TEST DATA
5 select ref, start_time, end_time, CAST(MAX(LTRIM(SYS_CONNECT_BY_PATH(person,', '),', ')) AS VARCHAR2(40)) as users
6 from (select ref, start_time, end_time, person
7 ,row_number() over (partition by ref, start_time, end_time order by person) rn
8 from t) t
9 CONNECT BY rn = PRIOR rn+1 AND ref = PRIOR ref
10 START WITH rn = 1
11* GROUP BY ref, start_time, end_time
SQL> /
REF START END_T USERS
1234 10:00 11:00 USER1, USER2
345 11:00 12:00 USER3
SQL> -
Date Validation-SQL Query or Mapping
Dear Friends,
I'm using sender JDBC adapter and fetching data.
Let say the table structure is Name,ID,Datetime.
I want to select the query and the resultset must be in the following fomat
I want to check the validation that if Datetime value is 2 weeks greater than current date return YES, else return NO
Is the above condition possible while selecting from the database itself?
If we can't achieve it using query, then I've to go for Mapping. Can you guys tell me the logic to implement the same.
<Rows>
<Name>J</Name>
<ID>126376</ID>
<DateTime>YES</DateTime>
</Rows>
<Rows>
<Name>P</Name>
<ID>126372</ID>
<DateTime>YES</DateTime>
</Rows>
<Rows>
<Name>S</Name>
<ID>126334</ID>
<DateTime>NO</DateTime>
</Rows>
If the above requirement is not clear, please let me know.
Thanks for all of your valuable time!!!
Best regards,
raj.Satish & Matias,
Thanks a lot for ur valuable time and help.
@Matias I tried to query with the SQL , but I failed since its throwing exception always.
@Satish: I wrote UDF and achieved the same.
<b>Code:</b>
//Sample input date: 2005-06-16 14:33:21.0
int year=Integer.parseInt(time.substring(0,4));
int month=Integer.parseInt(time.substring(5,7))-1 ;
int date=Integer.parseInt(time.substring(8,10));
int hour=Integer.parseInt(time.substring(11,13));
int min=Integer.parseInt(time.substring(14,16));
int sec=Integer.parseInt(time.substring(17,19));
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.set(year,month,date,hour,min,sec);
c1.add(Calendar.DAY_OF_MONTH,14);
if(c2.before(c1))
return "NO";
else
return "YES";
Thanks friends!!!
Best regards,
raj. -
Filtering data using sql query
I am pulling data from a database which is a log of events type data. It consists of entries at a certain time, entry text, and even has an entry type. One of those types is known as "open item." This entry has the potential to be present on multiple days over and over. The problem is I only want the "open item" entries to appear that occur on the most recent day of a date range that is input by the user, but also not excluding all other entries from all of the other days that are not "open item." The "is_open=0" is what is excluding the "open items" from all of the entries, but now there needs to be a way to include (ie. "is_open=1") the "open items" on the current day. My query is as follows:
SELECT b.log_title, a.log_id, MIN(a.shift_date) AS shift_date,a.shift_id,a.operator_position_descr,a.is_open,a.user_id, MAX(a.annotation_number) AS annotation_number,
a.entry_text, MIN(a.entry_time) AS entry_time,a.font_num
FROM log_entries AS a INNER JOIN
log_list AS b ON a.log_id = b.log_id
WHERE ((entry_type_code NOT LIKE '%NLOG%'
AND entry_type_code <> 'daily'
AND entry_type_code <> 'shift act') or entry_type_code is null)
AND (is_open = 0 AND is_standing_order = 0 AND is_rolled_forward is null)
GROUP BY b.log_title, a.log_id, a.user_id,a.shift_id,a.operator_position_descr,a.is_open, a.entry_text,a.font_num
Order by entry_timeChange you WHERE clause to something like this... (You didn't say what kind of DB you were using so I used SQL Server syntax)
WHERE ((entry_type_code NOT LIKE '%NLOG%'
AND entry_type_code IN ('daily', 'shift act')) OR entry_type_code is null)
AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0)))
AND is_standing_order = 0
AND is_rolled_forward is null
The biggest change is this... AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0))).
It allows is_open = 1 if the shift_date is => midnight of the of the current day.
HTH,
Jason -
Hoping there is a SQL guru out there that can help me with this
I have two tables that I want to pull data from and display a report, based on a particular date range, for this example let's say 08/01/2011 to 08/31/2011
In one table there would be an affiliate ID - AFF_UID and also the date and a counter for that date, IMP_COUNTER , now there may only be a few records not every day might be covered, say
TABLE IMP
date,aff_uid,imp_counter
08/01/2011,999,2000
08/02/2011,999,2050
08/20/2011,999,2030
etc
I then have another date, similar set up only there are multiple records in here for a single day, again not all days covered, I would need to total up each row for each day to get a count. So it might be:
TABLE LEAD
date,aff_uid
08/01/2011,999
08/01/2011,999
08/01/2011,999
08/01/2011,999
08/12/2011,999
So we have different dates covered, sometimes the same date, I need the counter from the first table, and from the second table I need to add them up for a total, and then display any date that has a value and put both counter and lead count together
Result from above
date,imp total,lead total
08/01/2011,2000,4
08/02/2011,2050,0
08/12,2011,0,1
08/20/2011,2030,0
I am sure there must be a SQL command that can gel all of this together with some grouping? Last thing I need is a ton of SQL statements in a loop!
My alternative is to add a counter to the IMP table for each lead, so every time I update the lead table with a record, I will also update the counter, but that's unncessary storage of data I already have an an extra update statement that I might be able to do without, but maybe it would make generating reports faster, just pulling to counters with no 'addition' required.
Appreciate any feedback
Thanks
MarkWell I thought that I had this one up and running, but once it went into production I found that it didn't give the desired results.
I have an account that has 3 'tracking'/aff accounts, so what it's doing is giving out 3 lines for each date rather than join them together into one. The values are also incorrect, I'm still trying to figure out just where it's even getting those numbers, I manually added up the numbers in the dbase and it didn't match
Here's the command
<CFQUERY name="GetStats" DATASOURCE="#datasource#">
SELECT
COALESCE(IMP.imp_date, LEAD.lead_date) AS report_date
, COALESCE(IMP.imp_counter,0) AS imp_counter
, COALESCE(LEAD.lead_count,0) AS lead_count
, COALESCE(LEAD.lead_aff_payment,0) AS lead_aff_payment
FROM
SELECT
imp_date
, imp_counter
FROM impressions
WHERE imp_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
<CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
AND imp_aff_uid IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
<CFELSEIF #val(ListGetAt(form_aff_UID,1))# IS "2">
AND imp_aff_uid = #val(ListGetAt(form_aff_UID,2))#
<CFELSE>
AND imp_aff_uid IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
</CFIF>
) AS IMP
FULL OUTER JOIN
SELECT
lead_date, COUNT(*) AS lead_count, SUM(lead_aff_payment) AS lead_aff_payment
FROM leads
WHERE lead_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
AND lead_data_status = 1
<CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
AND lead_aff_uid IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
<CFELSEIF #ListGetAt(form_aff_UID,1)# IS "2">
AND lead_aff_uid = #val(ListGetAt(form_aff_uid,2))#
<CFELSE>
AND lead_aff_uid IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
</CFIF>
GROUP BY lead_date
) AS LEAD
ON ( IMP.imp_date = LEAD.lead_date )
ORDER BY report_date;
</CFQUERY>
and here are the results
TRAFFIC REPORT: 01/01/2012 - 01/21/2012
All Accounts
Date
Offers
Served
Total
Leads
Revenue
01/19/2012
249
1
$0.38
01/19/2012
11
1
$0.38
01/19/2012
30
1
$0.38
01/20/2012
1,006
7
$2.66
01/20/2012
40
7
$2.66
01/20/2012
1,090
7
$2.66
01/21/2012
582
6
$2.28
01/21/2012
33
6
$2.28
01/21/2012
515
6
$2.28
Total
3,556
42
Sub-Total
$15.96
Referral Revenue
$0.00
Total
$15.96
$15.96 is NOT correct, I need to find out whats going on there, but the other issue is look how it's duplicating the dates, it's one line for each account by the look of it
Can anybody help! This SQL command already got a little beyond me
Thanks
Mark
Maybe you are looking for
-
How do i get the music from my old ipod to go on my itunes
i just got a itunes acct and i had an ipod but i got a new computer how do i get the music from the ipod to my nedw computers itunes
-
Did not get Acrobat 9 with my CS5 Design premium download ???
I have the license key sent by my company for CS5 Design Premium. We upgraded from a previous version of CS3 and I was issued a new laptop to install the upgrade. - I no longer have the computer with the CS3 version or a disk from the past. This is a
-
FND_FLEX_VALUES API needed
Dear All, I want to insert the values in to the FND_FLEX_VALUES table. Can any tell me wht is the API that can be used to insert the values. Please do paste me the API if you have used it before. I am new to oracle apps. its very urgent.
-
Hi all, Please forgive me if i'm wrong but I think Adobe is trying to pull a fast one on us. If you're an Audition 3.0 user, like me you will soon find out that Audition 5.5 is simply Sound booth with a few audition filters included. It's as simple a
-
Hi, It seems one of the on-board disk controllers is "burned out," so I need to get a PCI IDE Controller. Do these cards really need to say Mac-compatible? Are they universal cards like USB cards? I was looking at the prices at OWC and they are ridic