Modifying sql query in "region source" depending on hidden parameter?
Hi,
Is there a way to run 2 sql queries in "region source" depending on the hidden parameter passed? In other words, if I want to show all employees "select * from emp" when clicking on a "total" link as opposed to "select * from emp where dept=:xxx" when clicking on a dept link, how does the "region source" account for another sql statement?
thanks.
My understanding is that based on the link you click on in some page (PX) , it will go to a page (PY) that has a report in it and a hidden item with som passed value.
If that is correct then do the following in PY:
select * from emp
where dept=:xxx
or
:PY_PASSED_VALUE = 'total'this will show ALL records in emp if the passed value is total , i.e you clicked on the totals link and passed 'total' to the hidden item in PY : PY_PASSED_VALUE
but it will show only specific dept records otherwise.
Hope this helps,
Sam
Similar Messages
-
Multiple SQL Query as Data Source
I have an SQL Query as Data Source of my Crystal Report. It combine the contents of two tables.
I want to do another SQL query based on the previuos SQL Query.
Can I do this in CR ? How I can reference the new SQL query to the main SQL query ?
Thanks,
GabrielThis is my main Query
SELECT
SBO_001.dbo.JDT1.Account,
sum(SBO_001.dbo.JDT1.SYSDeb - SBO_001.dbo.JDT1.SYSCred) AS Balance_001,
0 as Balance_004
FROM SBO_001.dbo.JDT1
GROUP BY SBO_001.dbo.JDT1.Account
UNION
SELECT
SBO_004.dbo.JDT1.Account,
0 as Balance_001,
sum(SBO_004.dbo.JDT1.SYSDeb - SBO_004.dbo.JDT1.SYSCred) AS Balance_004
FROM SBO_004.dbo.JDT1
GROUP BY SBO_004.dbo.JDT1.Account
This is a result
Account Balance_001 Balance_004
80800005 0 -431.67
80800005 590121.07 0
80800006 -3621028.250 0
88780056 5000.00 0
90731001 0 174780.11
I want to obtain this result
Account Balance_001 Balance_004
80800005 590121.07 -431.67
80800006 -3621028.250 0
88780056 5000.00 0
90731001 0 174780.11
How I Can modify this Query?
Thanks,
Edited by: gablus on Aug 7, 2009 1:43 AM -
SQL Query report region that only queries on first load
Hello all,
Is there any way in which you can prevent a SQL Query report region from quering data after every refresh?
I would like to make a report that queries on the first load, but then I would like to change the individual values, and reload to show the change, but every time I reload the page the columns are queried and the original values are displayed once again...
any ideas?
-MuxChet,
I created a header process to create the HTMLDB_COLLECTION. It is something like:
HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
p_collection_name => 'Course_Data',
p_query => 'SELECT DISTINCT COURSE_ID, HTMLDB_ITEM.CHECKBOX(14,COURSE_ID) as "checker", TITLE, SUBJECT, COURSE_NUMB, SECTION, ENROLLED, null as "temp_term", null as "temp_title", null as "temp_crse_id", null as "temp_subj", null as "temp_crse_numb", null as "temp_sect", FROM DB_TBL_A, DB_TBL_B, DB_TBL_C, DB_TBL_D, DB_TBL_E, DB_TBL_F WHERE ...');
The names were changed, for obvious reasons.
I then created an SQL Report Region to see if it would work. The SQL is:
SELECT c001, c002, c003
FROM htmldb_collections
WHERE collection_name = 'COURSE_DATA'
When I run the page it says:
ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ExecErr:ORA-01008: not all variables bound
Any idea why this is happening?
I'm new to HTMLDB_COLLECTIONS, so I may be doing something wrong
-Mux -
Sql query in report/source
Is possible use this kind of select select a,(select b from b) from b
in sql query in report/source?Pretty much any valid select statement can be used.
If it works in SQL*Plus, then it should work in Application Express.
I think your example would not be valid if table b has more than one row.
A scalar subquery (like your "select b from b") must only return a single value.
SQL> select ename, (select job from emp) from emp e;
ORA-01427: single-row subquery returns more than one rowIf your subquery can be restricted to return one value, then it should work.
SQL> select ename, (select job from emp where empno = e.empno) job from emp e;
ENAME JOB
KING PRESIDENT
BLAKE MANAGER
CLARK MANAGER
JONES MANAGER
SCOTT ANALYST
FORD ANALYST
SMITH CLERK
ALLEN SALESMAN
WARD SALESMAN
MARTIN SALESMAN
TURNER SALESMAN
ADAMS CLERK
JAMES CLERK
MILLER CLERK
14 rows selectedBut is that the kind of result you were looking for? -
Displaying a radio group in SQL QUERY report region
Good morning everyone,
I have a report in which a column - ORDER STATUS, will come in with a value of 1, 2 or 3...being order unfilled, order partially filled, or order filled, respectively.
I would like to display the order status as a radio group on the report so that it will be easy to run down the column of radio buttons to see what is filled, etc.
I've gone to the manual and checked the doco on HTMLDB_ITEM.RADIOGROUP. But the example given there is actually for CHECKBOX (is this an error?!?).
I went to the forums and found nothing suitable.
My region is an SQL QUERY. Can I display the STATUS as a radio group in the SELECT ?
This is the question.
Thankyou in anticipation. TC. 23/11/2004Tony,
There may be better solutions, but here's what I was thinking: create table orders (id number, status number, customer varchar(30))
insert into orders (id,status,customer) values(1,1,'ACME')
insert into orders (id,status,customer) values(2,2,'BENSON')
insert into orders (id,status,customer) values(3,3,'CLARKE')
commit
Query Source
select
id "ORDER NUMBER",
decode(status,
1,htmldb_item.RADIOGROUP(1,status,'1','unfilled')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
2,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
3,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled'))
"STATUS",
customer "Customer Name"
from orders;Scott -
SQL Query as Item Source/Oracle Reports w/ HTML DB?
I have successfully used a SQL Query as an item source in the past on several occasions. However, in this instance, every time I try to do this, I get the following error:
Error ERR-1019 Error computing item default value: page=3 name=P3_TEST_ITEM.
ORA-01460: unimplemented or unreasonable conversion requested ORA-02063: preceding line from [database_name]
If I use the exact same query in creating a report region, the page displays fine and the query returns the correct data. Why might this be happening, and what can I do to fix it?
Also - off the subject - is there a way to use HTML DB to deploy reports that are created in Oracle Reports Builder? I have created several employee productivity reports for supervisors and managers in HTML DB, which is great for allowing them to run them live and have fields as parameters for varying employees, date ranges, etc... but formatting them to be browser and printer friendly is an absolute nightmare so far. If I could create and format the reports in Reports Builder and then deploy them using HTML DB, while still being able to offer parameters to the user, that would be perfect. Is this possible?Here is my query:
SELECT
TO_CHAR((sum(decode(ef.production_function,'Y',ef.function_minutes+ef.function_ot_minutes))/60)/8, '9999999.99')
FROM
RLAPPLSG.EMPLOYEE_INFO@REMOTE_SERVER EI,
RLAPPLSG.SC_EMP_FUNCTIONS@REMOTE_SERVER EF,
RLAPPLSG.SC_EMP@REMOTE_SERVER E
WHERE
( e.SC_EMP_NBR=ef.SC_EMP_NBR )
AND ( ei.EMP_ID=e.EMP_ID )
AND (
( trunc(( e.SC_DATE )) BETWEEN :P2_BEGIN_DATE AND :P2_END_DATE )
AND (ei.EMP_MGRS_ID = :P2_SUPERVISOR_ID
OR ei.EMP_ID = :P2_SUPERVISOR_ID)
Every table and/or view that is referenced here is done so remotely. The column datatype breakdown is as follows:
production_function - BOOLEAN
function_minutes - NUMBER
function_ot_minutes - NUMBER -
Include Button that executes PL/SQL procedure to SQL query based region
I would like to add two columns to a SQL query region.
These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
For example, I would like to have a manager approve or deny adding an additional employee to the department.
There would be one button for APPROVE. And, one button for DENY.
The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
A sample output would look like this:
<APPROVE>, <DENY>, John Doe, Accountant
<APPROVE>, <DENY>, Jane Doe, Accountant
Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
Thanks!
-ReidIs there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page
-
Selecting values between 2 dates for an SQL query report region
I have a region where im selecting between 2 dates
select hp.NAME, hp.VALUE, hp.UPDATEDATE, hp.DESCRIPTION, hp.UPDATE_COMMENT, hp.HASH, hp.IDCATEGORY
from HIST_REPORT hr, HIST_PARAM hp
where hp.dbid = hr.dbid and hr.id = :P7_ID and hp.UPDATEDATE between :P7_BDATE and :P7_EDATE
The problem is that if I have a row thats dated today (april 1) and if I set the beginning date (BDATE) to april 1 as well as the ending date (EDATE), no rows show and I would like the april 1 row to show. How can I modify my query to fix this?and hp.UPDATEDATE between :P7_BDATE
and decode(:P7_EDATE,:P7_BDATE,:P7_EDATE+1,:P7_EDATE)This assumes, though, that the time component of your items is implicitly 00:00.
Joel -
SQL Query (report region) without full page reset
Hello,
I have a page with several items, some of them with default values, and a report region, performing SQL query based on one of the items text field (always submits page when Enter pressed). When the page submits, the HTML DB engine performs and display the query, but at the same time, reset the other page items to their default values.
Is it possible to run the query without the HTML DB reset the item values to their default state?
Thanks,
Arie.Hi Peter,
Well, this is not exactly the case. I have an Item File Browse which defined as "Only when current value in session state is null", and a HTML text region, which contain Iframe, with default src tag (which I'm changing, using JavaScript, prior to the running of the SQL query). After running the query in a report region both the item and the Iframe reset to their original state.
Any Ideas on how to prevent that?
Thanks,
Arie. -
How to pass a variable for a SQL query in OLEDB source?
Hi All,
I am new to SSIS and working on it past few days. Can anyone please help me getting through a scenario where I need to pass a variable in the SQL statement in OLEDB source connection. Please find below for the details.
eg:
1) I have a SQL table with the columns SerialNumber, Name, IsValid, FileName with multiple rows.
2) I have the file Name in a variable called Variable1.
3) I want to read the data from my SQL table filtering based on the FileName (Variable1) within a data flow task and pull that data to the destination table.
Question: In the data flow task, added source and destination DB connection with a script component in between to perform my validations. When trying to retrieve the data from source using the variable (i.e. SQL Query with variable), I am not able to add
the query as the SQL statement box is disabled. How to filter the data based on the variable in the source DB ?
Any help/suggestions would be of great help.
Thanks,
SriJust to add with Vaibhav comment .
SQL Command : SQL query either with SQL variable or any condition or simple Sql statement
Like ;
Select * from dimcustomer
SQL Command using Varible :
Sometimes we design our dynamic query in variable and directly use that variable name in oledb source.
If you Sql query needs a condition based on SSIS variable .
you can find a Example here :
http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
http://www.select-sql.com/mssql/how-to-use-a-variable-inside-sql-in-ssis-data-flow-tasks.html
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
Hi,
Please find my query below:
SELECT T2.STATUS
,COUNT(*) CNT
FROM (
SELECT T1.ID, MAX(T1.STATUS_ID) STATUS_ID
FROM TABLE1 T1
WHERE TRUNC(T1.START_DT) >= TO_DATE(RegisteredDateFrom,'dd/MM/yyyy')
AND TRUNC(T1.START_DT) <= TO_DATE(RegisteredDateTo,'dd/MM/yyyy')
AND (T1.STATUS IN ('100', '700','300'))
GROUP BY T1.ID
) Result1
LEFT JOIN TABLE2 T2 ON (Result1.STATUS_ID = T2.STATUS_ID)
GROUP BY T2.STATUS
This query returns me few rows along with the count for the specific time period.
I want to remove this date filter and provide this Start_DT as a slicer to the end user in Power Pivot. Also CNT should be the calculated based on the START_DT selection from the slicer.
Anybody help me to modify the query? I am not the query expert.
Thanks,
SSIt does not look like T-SQL syntax? Please ask people who work with Oracle.
https://community.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Modify SQL query in Crystal Reports 2013
Bonjour,
Je voulais savoir s'il était possible de modifier la requête SQL dans Crystal Reports 2013, car les bases de données de notre application pour bibliothèque utilise un format de date particulier qu'il nous faut corriger directement dans la requête SQL.
Merci pour vos informations.
Cordialement
Claude Marcilly
Cannes - France
Hello,
I wanted to know if it was possible to modify the SQL query in Crystal Reports 2013. Databases of our application library indeed use a particular date format that we need to fix directly into the SQL query.
Thank you for your information.
Best regards
Claude Marcilly
Cannes - FranceHi Claude,
If you are creating reports using tables then go in Database menu and click on show SQL query, this will show the SQL generated by crystal reports. Now go in database expert and expend your connection and double click on Add Command and past the query which was generated by Crystal and try to modify the date format and click OK.
Now you need to redesign your reports based on Add command.
or
If your reports datasource is Add command you can directly go in add command and change it.
-Sastry -
Hi,
Can the below SQL Query be modified in any simpler way.
IF (V_BillingTypeID = 2) THEN
select count(*)
into V_AuthCount
from payerauthorization pa
where pa.patientidentificationno = IV_PatientIdentifierno
and pa.registrationno = IV_UHID;
if (V_AuthCount > 0) then
select pa.responsetype, pa.payerapprovedamount
into V_ResponseType, V_ApprovedAmt
from payerauthorization pa
where pa.patientidentificationno = IV_PatientIdentifierno
and pa.registrationno = IV_UHID;
if V_ResponseType = 3 then
V_ServiceTariff := V_ServiceTariff -
(V_ServiceTariff * (V_ApprovedAmt / 100));
end if;
if V_ResponseType = 2 then
select (pb.totalbillamount + pb.discountamount)
into V_GrossBillAmt
from patientbill pb
where pb.billno = IV_BillNo;
V_AuthPercentage := ((V_ApprovedAmt / V_GrossBillAmt) * 100);
V_ServiceTariff := round(V_ServiceTariff -
(V_AuthPercentage *
(V_ServiceTariff / 100)));
end if;
if V_ResponseType = 5 then
select (pb.totalbillamount + pb.discountamount)
into V_GrossBillAmt
from patientbill pb
where pb.billno = IV_BillNo;
V_AuthPercentage := ((V_ApprovedAmt / V_GrossBillAmt) * 100);
V_ServiceTariff := round(V_ServiceTariff -
(V_AuthPercentage *
(V_ServiceTariff / 100)));
end if;
end if;
select Count(*)
into V_CRCount
from creditnote cr
where cr.billno = iv_Billno;
if (V_CRCount > 0) then
select cr.creditnoteamount
into V_RefundedAmount
from creditnote cr
where cr.billno = iv_Billno;
end if;
SELECT SUM(GC.REFUNDAMOUNT) INTO V_GCREFUNDAMOUNT FROM GBCREDITNOTE GC;
V_MAXREFUNDAMOUNT := (V_PatientPaidAmount - (NVL(V_GCREFUNDAMOUNT, 0) +
NVL(V_RefundedAmount, 0)));
END IF;Thanks in advance.Few things i came across are
1. You could remove the query where you do COUNT() just to check if data exist before SELECT..INTO. You can use EXCEPTION handling insted.
2. The condition V_ResponseType = 2 adn V_ResponseType = 5 looks same so you can combine it into a single condition.
I have modified it like this.
if (v_billingtypeid = 2) then
begin
select pa.responsetype
, pa.payerapprovedamount
into v_responsetype
, v_approvedamt
from payerauthorization pa
where pa.patientidentificationno = iv_patientidentifierno
and pa.registrationno = iv_uhid;
if v_responsetype = 3 then
v_servicetariff := v_servicetariff - (v_servicetariff * (v_approvedamt / 100));
end if;
if v_responsetype in (2, 5) then
select (pb.totalbillamount + pb.discountamount)
into v_grossbillamt
from patientbill pb
where pb.billno = iv_billno;
v_authpercentage := ((v_approvedamt / v_grossbillamt) * 100);
v_servicetariff := round(v_servicetariff -(v_authpercentage *(v_servicetariff / 100)));
end if;
exception
when no_data_found then
null;
end;
begin
select cr.creditnoteamount
into v_refundedamount
from creditnote cr
where cr.billno = iv_billno;
exception
when no_data_found then
null;
end;
select sum(gc.refundamount)
into v_gcrefundamount
from gbcreditnote gc;
v_maxrefundamount := (v_patientpaidamount - (nvl(v_gcrefundamount, 0) + nvl(v_refundedamount, 0)));
end if;Edited by: Karthick_Arp on Feb 21, 2013 3:26 AM
Fixed BEGIN..END mismatch. -
Need generic dynamic sql query to generate nodes depending on dealer levels
Input table:
create table #test(dealerid integer ,dealerlvl integer)
insert into #test values(1,1)
insert into #test values(1,2)
insert into #test values(1,3)
insert into #test values(1,4)
insert into #test values(2,1)
insert into #test values(2,2)
insert into #test values(2,3)
insert into #test values(2,4)
insert into #test values(2,5)
insert into #test values(2,6)
go
create table #test2(dealerid integer,node integer,prntnode integer,dealerlvl integer)
insert into #test2 values (1,234,124,2)
insert into #test2 values (1,123,234,1)
insert into #test2 values (1,238,123,2)
insert into #test2 values (1,235,238,3)
insert into #test2 values (1,253,235,4)
insert into #test2 values (2,21674,124,3)
insert into #test2 values (2,1233,21674,1)
insert into #test2 values (2,2144,1233,2)
insert into #test2 values (2,2354,2144,3)
insert into #test2 values (2,24353,2354,4)
insert into #test2 values (2,245213,24353,5)
insert into #test2 values (2,2213,245213,6)
Expected result :
I have two test case here with dealerID1 and dealerID 2
Result for DealerID1
Result needed for DealerID2:
the levels for dealers might change (Dealer1 has 4 levels, and Dealer 2 has 6 levels) so i need to create an dynamic sql query which lists each node as separate columns depending on the levels.
I have hacked the query to give the result I need
select a.dealerid,a.node as Lvl1,b.node as lvl2,c.node as lvl3,d.node as lvl4
from #test2 a
join #test2 b on a.node=b.prntnode
join #test2 c on b.node=c.prntnode
join #test2 d on c.node=d.prntnode
where a.dealerid=1 and a.dealerlvl=2
select a.dealerid,a.node asLvl1,
b.node as lvl2,c.node as lvl3,d.node as lvl4,e.node as lvl5,f.node as lvl6--,a.dealerlvl,a.dealerid
from #test2 a
join #test2 b on a.node=b.prntnode
join #test2 c on b.node=c.prntnode
join #test2 d on c.node=d.prntnode
join #test2 e on d.node=e.prntnode
join #test2 f on e.node=f.prntnode
where a.dealerid=2 and a.dealerlvl=3
I am sure there is a better way to do this with dynamic sql. please help.
Thanks-- Dynamic PIVOT
DECLARE @T AS TABLE(y INT NOT NULL PRIMARY KEY);
DECLARE
@cols AS NVARCHAR(MAX),
@y AS INT,
@sql AS NVARCHAR(MAX);
-- Construct the column list for the IN clause
SET @cols = STUFF(
(SELECT N',' + QUOTENAME(y) AS [text()]
FROM (SELECT DISTINCT dealerlvl AS y FROM dbo.test2) AS Y
ORDER BY y
FOR XML PATH('')),
1, 1, N'');
-- Construct the full T-SQL statement
-- and execute dynamically
SET @sql = N'SELECT *
FROM (SELECT dealerid, dealerlvl, node
FROM dbo.Test2) AS D
PIVOT(MAX(node) FOR dealerlvl IN(' + @cols + N')) AS P;';
EXEC sp_executesql @sql;
GO -
We just upgraded from Crystal Reports 8.0 to 2008 and are unable to modify the SQL query for any of our old Crystal Report files. I can view the query by going to "Database", "Show SQL Query..." but am unable to edit the SQL statement in any way.
If there a setting within "Options" or anywhere else that has this locked? Is there another place with the application that allows me to edit the SQL Query? I looked at the "Select Expert" but none of my WHERE elements show up there.The SQL query cannot be modified. (It is my understanding that you could in older versions... Not sure in which version that changed.)
The latest versions of CR allow the use of SQL Commands. SQL Commands allow you to "paste" the SQL generated by CR and modify it or write your own SQL from scratch.
HTH,
Jason
Maybe you are looking for
-
Hi, Is there a way to link a PO with its invoice details? Thanks
-
Do I need to change simple settings? This Macbook is brand new. The music worked when I got it, but then I installed Adobe Flash Player and since then it hasn't worked.
-
When is the best time to buy my MacBook Pro
Hi, I'm planning on buying a MacBook Pro. I'm either buying it now or in March. Should I wait until March because their will be a newer model out? Or should I buy it now?
-
Help - Software Updates has error, "No repository found"
I just launched Flash Builder 4.7 (latest version) for the first time and went to Help -> Software Updates and get this error. "'Contacting Software Sites' has encountered a problem. No repository found at http://aesplugins.adobe.com/aes/tooling/plug
-
I have two ODS's - ODS1 and ODS2 . ODS1 feeds data to ODS2 using an uppdate rule .ODS1 data is as follows Billno Itemno cond keyfig 10 1 a 1 10 1 b 3 10 1 c 5 20 1 d 7 20 1 e 8 20 1