Using In operator in Formula Column,URGENT!!!!!!!!!
Hi...
I want to ask if I have a formula Column(REPORTS 6i),and I want in where condition using parameter to some condition as this example:
function CF_1Formula return Number is
S NUMBER(10);
begin
SELECT SUM(SAL) INTO S FROM EMP
WHERE DEPTNO IN (:DEPT);
RETURN(S);
end;
Where :DEPT is user parameter of char Datatype and it is value 10,20 and may be 10,30,40
and so on.
on runtime the sql will be:
SELECT SUM(SAL) INTO S FROM EMP
WHERE DEPTNO IN (10,20);
but this not work.So what is the correct way to deal with this sql stat.,
and :dept always have different values.
So PLS any ONE help me ASAP
Something like this will work (10g onwards)
SQL> ed
Wrote file afiedt.buf
1 with req as (select '&required_empnos' as empno from dual)
2 --
3 select *
4 from emp
5 where empno in
6 (select regexp_substr(empno, '[^,]+', 1, rownum)
7 from req
8* connect by rownum <= length(regexp_replace(empno, '[^,]'))+1)
SQL> /
Enter value for required_empnos: 7839,7499,7934
old 1: with req as (select '&required_empnos' as empno from dual)
new 1: with req as (select '7839,7499,7934' as empno from dual)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
SQL>
Similar Messages
-
Using a select or forumal column "urgent"
hi, i am working on a huge system and i have two tables
emp table , company table
and i am searching the employees whom meet the search criteria(salary), and i want to display for every employee his company name and his company address.
so what will be the best way to do so regarding the performance :
1. to add a formula colum that retrive the company name for each employee who meet the search critiria .
or
2. or to match the two tables.
please note that the emp table contain about 3 million record, and the company table about 250,000,000 record and the retrieved records that match the search critiria varies from ( 1 record to 50,000,000 record).
so what is the best way to perform this ( method 1 or 2) or is there another way to do so.
best regardsHello,
Like Marilyn, I think that the option 2 is the best
http://download-uk.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_tune.htm#sthref2219
20.4.3 Calculations
Within a report (either through summary or formula columns), ensure that most of the calculations are performed by the data source. In case of SQL queries, calculations are performed on the database rather than on the data retrieved by the report. User-defined functions and procedures stored by the database can also be included in the query select list of an Oracle Database or a JDBC query. This is more efficient than using a local function, since the calculated data is returned as part of the result set from the database.
Regards -
How to make an order on repeating frame using Formula Column?
Hi All,
I have a repeating frame dependent on some query, how to make an order on this repeating frame using a formula column defined in its group and dependet on values from the query?
Note: I'm using Reports 6iPlace your formula column at the top of the itm group and set the BREAK_ORDER to assc.. or desc...
Hope this helps
Hamid
if problem solved, close the thread. -
Problem in Report Formula Column
I recently Transfer my databse 9i to 10g and iam using developer 2.1 release 5 as a front hand.
so problem is that my reports run successfully with oracle 9i but when i change my database to oracle 10g iam facing error in reports formula column. when i use select statement in formula column. i gave u an example about that.
function CF_1Formula return Number is
lc_count NUMBER;
begin
SELECT count(*)
INTO lc_count
FROM tab;
RETURN (NVL(lc_count,0));
end;
when i compile formula column i got this error.
ORA-00600 internal error , argument:[17069], [19156148],[],[],[],[],[],[]
please help me in this matter.
Thanks.
M.Sohail Taihi fs,
Thanks for reply me my friend.
i also use the column name but same error is appeared when i compile formula column . this is only the example i gave to u. now i give u actual code.
function CF_Close_Rate1Formula return Number is
lc_rate number;
begin
select CL_RATES_CLOSE
into lc_rate
from sys_cl_rates
where cp_id = :v_cp_id
and loc_id = :v_loc_id
and trade_type_id = :trade_type_id
and cp_list_id = :cp_list_id
and CL_RATES_DATE = (select max(cl_rates_date)
from sys_cl_rates
where cp_id = :V_CP_ID
and loc_id = :V_LOC_ID
and trade_type_id = :trade_type_id
and cp_list_id = :cp_list_id);
--= :lc_closing_date;
return (nvl(lc_rate,0));
EXCEPTION WHEN NO_DATA_FOUND THEN
RETURN(0);
end;
This work properly with 9i database but not with 10g database.
Reply me soon .
Thanks,
M.Sohail Tai -
Applying order by for the data comming from the formula column
Dear Friends,
I am having a report in which some of the columns in which data is comming from the formula columns,but i need the data in asc order.
How can i do it.
Please advice.I am having a report in which some of the columns in
which data is coming from the formula columns,but i
need the data in asc order.Lets say you have this query:
select empno, sal, comm from emp
And you have empno, sal, comm and a formula column 'f_percentage' in one group. Add one dummy column in the query, like this:
select 'temp' temp, empno, sal, comm from emp
Move this 'temp' column into the second group (drag and drop outside the first group). You don't have to create repeating frame/or need to show this 'temp' column on the report.
Now if you use break order on formula column, that should work. Make sure you have break order on other columns also. Arrange items (change order) in data model as you needed. Run your report before and after this change and make sure you have same number of rows before and after this change.
(from reports builder's help)
"Break Order has no effect on columns that belong to the lowest group of a particular query. Break Order only affects columns in groups that are above the lowest child group of a query" -
Can we use formula column in lexical parameter in sql query ...
hi
can we use formula column in lexical parameter in sql query ...
as example
i want to give
select * from & c_table
forumula
function c_table
if :p_sort = 1 then
return 'dept'
else
return 'emp'
end;
c_table formula column
is this possible ...
i have such example in oracle apps reports
if i try in ordinary report usinf emp table it show error ..
how we can give formula column...
please help me in this regard...
Edited by: 797525 on Feb 20, 2012 9:31 PMthanks sir,
iam not exactly saying select * from &c_table but some thing that like columns in select stmt also will be populated in user_parameters ,there are lot of table select.......from mtl_demand md, mtl_system_items msi, mtl_txn_source_types mtst, mtl_item_locations loc &C_source_from &C_from_cat
&c_source_from and &c_from_cat formula column and there are defined at report level only ......
pl/sql code &c_source_from is
function C_source_fromFormula return VARCHAR2 is
begin
if :P_source_type_id = 2 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id = 3 then return(',GL_CODE_COMBINATIONS gl');
else if :P_source_type_id = 6 then return(',MTL_GENERIC_DISPOSITIONS mdsp');
else if :P_source_type_id = 5 then
if :C_source_where is null then
return NULL;
else
return(',WIP_ENTITIES wip');
end if;
else if :P_source_type_id = 8 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id is null then
return(',MTL_SALES_ORDERS mkts,
MTL_GENERIC_DISPOSITIONS mdsp,
GL_CODE_COMBINATIONS gl ');
else null;
end if; end if; end if; end if; end if; end if;
RETURN NULL; end;
this is forumula column i hope that you understand what iam saying
please help me in this regard....
thanking you... -
Formula column help needed(urgent)
Hi ,
I am using the data template for generating XML data.
BIP provided functions like SUM(), AVG(), COUNT(), MAX(), etc to use as
below
<group name="G_DEPT" source="Q1">
<element name="DEPT_NUMBER" value="DEPTNO" />
<element name="DEPTSAL" value="G_EMP.SALARY" function="SUM()"/>
<group name="G_EMP" source="Q2">
<element name="EMPLOYEE_NUMBER" value="EMPNO" />
<element name="NAME" value="ENAME"/>
<element name="JOB" value="JOB" />
<element name="SALARY" value="SAL"/>
</group>
</group>
but suppose if I want to do a sum like
Sum(ALLdebits - All credits - All refunds).
We use to have formula good old formula column. like in ORACLE Reports...
below is my query in the data template....can someone please suggest?
<dataTemplate name="R007" dataSourceRef="xyz">
<properties>
<property name="include_rowsettag" value="false"/>
<property name="include_rowtag" value="false"/>
<property name="xml_tag_case" value="as_are"/>
</properties>
<parameters include_in_output="false">
<parameter name="DATE_FROM" dataType="varchar2" include_in_output="false"/>
<parameter name="DATE_TO" dataType="varchar2" include_in_output="false"/>
<parameter name="BANK_GIRO_NUMBER" dataType="varchar2" include_in_output="false"/>
</parameters>
<dataQuery>
<sqlstatement name="Q1">
<![CDATA[SELECT
DISTINCT
SYSDATE todayDate
,substr(trim(CR_BG_NO),3,8) creditorBGNumber
,CREDITOR_SHORT_NAME creditorName
,COUNT(*) itemCount
FROM
R00777_REPORT R1
WHERE
R1.TXN_DATE BETWEEN TO_DATE(:DATE_FROM,'YYYY-MM-DD') AND TO_DATE(:DATE_TO,'YYYY-MM-DD') AND
R1.CR_BG_NO = :BANK_GIRO_NUMBER
GROUP BY
substr(trim(CR_BG_NO),3,8)
,CREDITOR_SHORT_NAME]]>
</sqlstatement>
<sqlstatement name="Q2">
<![CDATA[
SELECT
TXN_DATE
,substr(trim(CR_BG_NO),3,8)
,PAYMENT_TYPE
,TXN_SERIAL_NO
,decode(PAYMENT_TYPE,'AGDEBIT_TRANSFER',DR_TXN_AMOUNT,'AG_REFUND',-RE_TXN_AMOUNT,'AGCREDIT_TRANSFER',-CR_TXN_AMOUNT)
SIGN_AMOUNT
FROM
R00777_REPORT R2
WHERE
R2.TXN_DATE BETWEEN TO_DATE(:DATE_FROM,'YYYY-MM-DD') AND TO_DATE(:DATE_TO,'YYYY-MM-DD')
AND R2.CR_BG_NO = :BANK_GIRO_NUMBER
]]>
</sqlstatement>
</dataQuery>
<dataStructure>
<group name="response" source="Q1">
<group name="head" source="Q1">
<element name="itemCount" value="itemCount"/>
<element name="todayDate" value="todayDate"/>
<element name="creditorBGNumber" value="creditorBGNumber"/>
<element name="creditorName" value="creditorName"/>
</group>
<group name="list" source="Q2">
<group name="listItem" source="Q2">
<element name="transactionDate" value="TXN_DATE"/>
<group name="transactions" source="Q2">
<group name="transaction" source="Q2">
<element name="transactionType" value="PAYMENT_TYPE"/>
<element name="serialNumber" value="TXN_SERIAL_NO"/>
<element name="amount" value="SIGN_AMOUNT"/>
</group>
</group>
<element name="netSum" value="transaction.SIGN_AMOUNT" function="SUM()"/>
</group>
</group>
</group>
</dataStructure>
</dataTemplate>Hi Rainer,
Many Thanks for your reply
I had done all the calculations in the report view earlier
and when i accessed it in the data template as follows
<element name="netSum" value="netSum" />
the xml output that i got was like
<R007>
<response>
<head>
<itemCount>8</itemCount>
<todayDate>2009-02-05T15:50:12.000+01:00</todayDate>
<creditorBGNumber>01829209</creditorBGNumber>
<creditorName>ANDROMEDA</creditorName>
</head>
<list>
<listItem>
<transactionDate>2008-09-03T00:00:00.000+02:00</transactionDate>
<netSum>-6647999</netSum>
<transactions>
<transaction>
<transactionType>AGCREDIT_TRANSFER</transactionType>
<serialNumber>5</serialNumber>
<amount>-1687200</amount>
</transaction>
</transactions>
</listItem>
</list>
</response>
</R007>
But the output that i want is something like this
<R007>
<response>
<head>
<itemCount>8</itemCount>
<todayDate>2009-02-05T15:50:12.000+01:00</todayDate>
<creditorBGNumber>01829209</creditorBGNumber>
<creditorName>ANDROMEDA</creditorName>
</head>
<list>
<listItem>
<transactionDate>2008-09-03T00:00:00.000+02:00</transactionDate>
<transactions>
<transaction>
<transactionType>AGCREDIT_TRANSFER</transactionType>
<serialNumber>5</serialNumber>
<amount>-1687200</amount>
</transaction>
</transactions>
<netSum>-6647999</netSum>
</listItem>
</list>
</response>
</R007>
Hence I used the BIP built in template function like this
<element name="netSum" value="transaction.SIGN_AMOUNT" function="SUM()"/>
but the sum() function is adding up all amounts as expexted,I want
the above newsum value as
Sum(AGdebit-AGCREDIT-AG_refund). -
How to use a Formula Column in the main query?
Hi All,
I've tried to use a formula columns defined in some query in the condition of that query like this:
where (:cf_ex - :cf_ex2) >= 5
but when I run the report no data returned! Why? and how to use it the condition of the query?
Note: I'm using Forms 6iwhere (:cf_ex - :cf_ex2) >= 5You cannot do that. Formula columns are not part of the select statement (which runs in the database), but are processed in the report.
When you created this query, my guess is that you got the message "Note: the query Q1 has created the bind parameter(s) cf_ex, cf_ex2". Check these User Parameters in your data model. So, you are actually referencing user parameters in the query, not formula columns.
I made a computations and things using PL/SQL that can't be done in the select statement in the data model!If it's pl/sql you can probably use that in your query. Create some database functions for cf_ex and cf_ex2 and use these in your query. -
Howto use formula columns in matrix reports
Hello
How can i use a formula column in matrix report whose function would be
Formula_Column_Result=A-B where A=Cell A
B =Cell B
Regards
FahadHii guys
I solved my problem on my own.
i wrote
SELECT * FROM EMP WHERE EMP.DEPTNO=P_DEPT_NO
and it worked.
Thanks guys..i luv this forum
Regards
Fahad Hameed -
Can text be displayed in a formula column using mathematical functions?
I am working with Financial Reports version 11.1.1.3 and I'm trying to accomplish the following scenario:
Column D is a data column
Column E is a text column containing the value "TEXT"
Column F is a formula column with the following formula: IfThen([D]=0,[E],[D])
What I want to see happen is if the value in column D is 0 then I want the value "TEXT" to appear in column F, otherwise; I want to show the data value that is in column D. Is it possible to display text in a formula column and if so, what is the syntax for that? Or does anyone have another way to accomplish this? Any help would be appreciated.
Thanks!Short answer: No.
For your particular issue, I would suggest putting your TEXT value in the #zero and #missing overrides in Report Studio.
In general, Hyeprion Reporting does not do any real text validations or functions like you could use in Excel. -
Can formula column values be used as parameters
Post Author: vdm
CA Forum: Formula
Hi,
I have various formula columns setup in my crystal report, these formula columns act as prompts when end users run the report. i am using crystal reports xi and sql server databse.
Now I would like to use these formula columns to restrict my result set. basically, these should act as predicates (where clauses) to my query.
Is there a way to pass formula columns as parameters to stored procedures or to commands or to simpy add them to a sql query ?
thanks in advancePost Author: foghat
CA Forum: Formula
Have you tried adding the formula fields as a filter in the Record Selection Formula editor?So Report --> Selection Formulas --> Recordand add: {database.field_a} = and {database.field_b} = and so on -
Using Sybase query in Placeholder/Formula columns
Hi,
This is addendum to the post subjected as "JDBC query with Sybase database".
I am working with 9i Reports builder conecting to Sybase db through jdbc-odbc component. I can execute any statement in the form of query / procedure in jdbc query wizard.
I would like to know, how can i give/execute sybase compliant sql statements in placeholder, formula or for that matter any other place in reports builder.
Say, I have selected a column of in char format "020925" which represents a date of 25th Septemeber'2002. I want to give a statement like, "convert(datetime,'020925')", which converts to date format.
How can I specify this statement in a formula column.?? (formula column plsql editor recognize only oracle related statements)
Thanks & Regards
AnandHi Sachin,
So you mean to say, any other feature of Reports builder can't be used along with Sybase db. say triggers, local procedure / functions, etc.,
Is there any workaround to this setback?
Rgds
Anand -
I've tried several ways of doing this, and this seems to be the easiest way. Basically, depending on the type of record, I need to use one of two columns to link to another query. So, if a row in query A has type 1, I need to use column X to link to query B. If a row in query A has type 2, I need to use column Y to link to query B.
I thought the easiest way to do this would be to create a formula column in Query A that was the value of column X or Y as appropriate and then link to Query B using this formula field. However, I can't seem to link queries using a formula.
Does anyone have any ideas how I can accomplish this? I'm new with Oracle reports, so go easy on me :)
Thanks,
Julie.What error are you getting?
Is it: REP-1297: Data link child column 'CF_1' must be a database column?
If so, the reason is the child column cannot be a formula column. The parent column, on the other hand, can be a formula column.
If I understand your data model correctly, "A" is your parent query/group and "CF_1" is the formula column in query/group "A".
"B" is your child query. "FK_1" (the foreign key column in query "B") is your child column.
You should be able to link "CF_1" in "A" to "FK_1" in "B" by doing:
- click on the link tool
- click on "CF_1" in "A"
- drag to "FK_1" in "B"
- A link should be created. Double click on it to bring up the property palette for that link and you'd see the link properties.
Hope that helps... -
Using PL/SQL in a formula column in Oracle Reports Builder.
Hi,
I need to SUM two record from the result of an SQL interrogation.
Here's what it looks like
function CF_1Formula return Number is
nTot1 NUMBER :=0;
nTot2 NUMBER :=0;
begin
select sum(:TOT1) into nTot1 from table(Q1) ;
select sum(:TOT2) into nTot2 from table(Q1) ;
return (nTot1 + nTot2);
end;I'm kind of new to formula column programming any link of interest would be appreciated.
The from table(Q1) part Q1 represents my SQL interrogation name and the group below it is G_MAIN.Hi Hong Kong King Kong,
From looking at that function name (and the group name): Is this an Oracle Reports generated function?
If so, there's also a dedicated Reports forum: Reports
By the way, I like your synonym for 'query'.
I'm sure I'll confuse some of my collegues tomorrow when I will mention 'database interrogation' instead of 'query'. ;)
edit
Doh...I should not underestimate the information that is posted in thread subjects.
Edited by: hoek on May 5, 2010 9:24 PM -
Formula Column help please - URGENT
I'm trying to create a formula column as follows:
function NO_REPLIESFormula return Number is
NOREPLY number;
begin
SELECT COUNT(reply) INTO NOREPLY
FROM letters
WHERE reply = 'N'
GROUP BY ltrtype, batch;
RETURN (NOREPLY);
end;
This PL/SQL compiles fine, but when I run the report, I get the following messages:
REP-1401 no_repliesformula FATAL PL/SQL error occured. ORA-01422 exact fetch returns more than requested number of rows.
If I remove the GROUP BY ltrtype, batch, I don't get the error messages, but the result I get is the total no_replies instead of the total no_replies for each ltrtype/batch grouping.
Could someone please help me with this?
Thank you.Hi irish,
I think i am not sure about what you are trying to say, but let me guess, You want the values to be return on the bases of "ltrtype, batch". Which mea that you want more then one values, i mean there can be more then one Groups based on ltrtype and batch. and you want to display these values with repective record???
If i am right, then there is a fault in your code, and that is , you are not specifing in your code that which value is to be diplayed with which record in this report. For that there must be ltrtype, batch colums displayed in the report, you must add those values in your Code in the query, i.e.
function NO_REPLIESFormula return Number is
NOREPLY number;
begin
SELECT COUNT(reply) INTO NOREPLY
FROM letters
WHERE reply = 'N' and ltrtype= :V_ltrtype and batch=:v_batch;
RETURN (NOREPLY);
end;
Where :V_ltrtype and :v_batch are the run time values of each records displayed in the report.
Remember that if you don't sepecify this then your code will return as many records as many distich values of ltrtype, batch. and your variable NOREPLY can hold only one value at a time. I hope you understand both, Solution and the logic behind the error.
Please correct me if i am wrong.
Thanks.
Mohib ur Rehman
Maybe you are looking for
-
Playlist folders do not contain the correct number of songs
I have many manually generated playlists and I categorize them in a hierarchal manner using folders so that I can click on the folder and see all the songs contained in each of the sub-playlists. What I've realized recently (although I suspect it's b
-
Hi, I got an iPod Nano 16GB for Xmas and was wondering if anyone could help me with my battery query? Have downloaded the pdf from Apple, but am still none the wiser. When I plug it in my laptop it gives me 'Connected; Eject before disconnecting' scr
-
Amount was deducted and credit amount no shown in ...
Dear Sir, I have suscribed for India 800 mins plan and today that amount was deducted from my credit card for subscription and this amount calls was not added in my account and also I unsubscribe for the plan. Could you please let me know when I can
-
Is anyone as frustrated as i am...just bought a brand new 13" powerbook to find that I can't load my adobe creative suite 2.3 software using the lion os! I need solutions that do not involve spending more $$$$ one the newest CS version. After goog
-
Licensing question: In 2011, I purchased a student license to CS5 for my mac. I have installed it on one laptop that I am the primary user of. The laptop has two user logins, mine and my husbands. Can my husband use CS5 on the computer on an occass