How to register PL/SQL function with Varchar2 argument in Discoverer
Hi,
I have registered a PL/SQL function in Discoverer Administrator 10.1.2.1. Function has two arguments with data type varchar2. In discoverer I've selected varchar as it doesn't have varchar2.
When i use this function in report using discoverer desktop it gives an error "One of the function argument has an incorrect datatype.
I would appreciate if somebody can help
Regards
BA
Hi,
First, do not wait to use it in order to check it.
In the discoverer admin you can "Validate" the function on after registering it.
there are couple of things you should know about registering the function:
1. the "Varchar" option you selected is correct (there is no varchar2 in the admin definition).
2. check the database function to verify that you indeed registered all its arguments and they match the names and types of the db function.
3. during the registration, type everything in UPPER CASE.
the other way to register the function (and you will not need to deal with the definition of it) is to search for the function in a list.
in order to do that, on the register function screen press the "Import" button (on the bottom right side of screen).
then search by the owner (db user / schema) that the function / package is registered.
Tamir
Similar Messages
-
How to call a SQL function from an XSL expression
Hi
In R12, in Payroll Deposit adivce/Check writer, We need to sort the earnings tag <AC_Earnings> in to two different categories as regular and other earnings. In the DB and form level of element defintiion we have a DFF which differentiates between the two kinds of earnings. But the seeded XML that is gerneated by the check writer does not have this field.
The seeded template displays all the earnings in one column. How can we achieve this in the template without modifying the seeded XML.
The one approach i have is to write a function and based on the return value sort the data. For this I need to know :
1) How to call a SQL function from an XSL expression that is allowed in BI template.
If anyone ahs faced similar requirements please share your approach.
Thanks
SrimathiThank u..
but i'd seen that link wen i searched in google..
Is it possible without using any 3rd party JARs and all?
and more importantly plz tell me what should be preferred way to call a javascript function?
Do it using addLoadEvent() or Windows.Load etc
OR
Call it thru Xsl? (I donno how to do dis)
Thanks in Advance..
Edited by: ranjjose on Jun 3, 2008 8:21 AM -
How to create a procedure function with a return value of ref cursor?
Can anybody provide a sample about how to create a procedure function with a return value of REF CURSOR?
I heard if I can create a function to return a ref cursor, I can use VB to read its recordset.
Thanks a lot.http://osi.oracle.com/~tkyte/ResultSets/index.html
-
How to connect MS-sql server with SAP BW
hi all,
i want the connection procedure to how to connect MS-sql server with SAP BW.so that i can extract the data from ms sql server and can create cubes using that data.please help me in this issue.Hi Vamshi,
Go through this DOC it explains u how to connect to other data bases like SQL...
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/58f4db47-0501-0010-a2bf-ff01b150fdff]
this is a thread related to connect the SQL server..
[DB Connect MS SQL Server;
Regards,
NR
Assign points if helpful... -
PL/SQL table with several arguments
Hi All!
I need a pl/sql table with several arguments. It should looks like this:
DECLARE
CURSOR C1
IS
SELECT ARTICLE_ID,
SALES_SECTION_ID,
COUNTRY_ID,
COLL_OF_DATA_TYPE_ID,
SYSTEM_ID
FROM F_IPV_BASE;
CURSOR C2
IS
SELECT ARTICLE_ID,
SALES_SECTION_ID,
COUNTRY_ID,
COLL_OF_DATA_TYPE_ID,
SYSTEM_ID,
COUNT (ALL ORDER_POSITION_NO) CREDIT_NOTE_POS_QTY
FROM F_IPV_BASE
WHERE DAY_ID BETWEEN tFirstDayofMonth AND tLastDayofMonth
AND BILLING_METHOD_ID = (SELECT BILLING_METHOD_ID
FROM K_BILLING_METHOD
WHERE SRC_BILLING_METHOD_ID = '2')
GROUP BY ARTICLE_ID,
SALES_SECTION_ID,
COUNTRY_ID,
COLL_OF_DATA_TYPE_ID,
SYSTEM_ID;
TYPE CREDIT_NOTE_POS_QTY_REC IS RECORD (
ARTICLE_ID F_IPV_BASE.ARTICLE_ID%TYPE,
SALES_SECTION_ID F_IPV_BASE.SALES_SECTION_ID%TYPE,
COUNTRY_ID F_IPV_BASE.COUNTRY_ID%TYPE,
COLL_OF_DATA_TYPE_ID F_IPV_BASE.COLL_OF_DATA_TYPE_ID%TYPE,
SYSTEM_ID F_IPV_BASE.SYSTEM_ID%TYPE,
CREDIT_NOTE_POS_QTY NUMBER
TYPE CREDIT_NOTE_POS_QTY_TYP IS TABLE OF CREDIT_NOTE_POS_QTY_REC
INDEX BY VARCHAR2 (30);
CREDIT_NOTE_POS_QTY_TAB CREDIT_NOTE_POS_QTY_TYP;
tPosQTY NUMBER := 0;
BEGIN
FOR TmpRec1 IN C2
LOOP
CREDIT_NOTE_POS_QTY_TAB (TmpRec1.ARTICLE_ID, TmpRec1.SALES_SECTION_ID, TmpRec1.COUNTRY_ID, TmpRec1.COLL_OF_DATA_TYPE_ID, TmpRec1.SYSTEM_ID).CREDIT_NOTE_POS_QTY := TmpRec1.CREDIT_NOTE_POS_QTY;
END LOOP;
FOR TmpRec1 IN C1
LOOP
IF (CREDIT_NOTE_POS_QTY_TAB.EXISTS (TmpRec1.ARTICLE_ID, TmpRec1.SALES_SECTION_ID, TmpRec1.COUNTRY_ID, TmpRec1.COLL_OF_DATA_TYPE_ID, TmpRec1.SYSTEM_ID) = TRUE)
THEN
tPosQTY := CREDIT_NOTE_POS_QTY_TAB (TmpRec1.ARTICLE_ID, TmpRec1.SALES_SECTION_ID, TmpRec1.COUNTRY_ID, TmpRec1.COLL_OF_DATA_TYPE_ID, TmpRec1.SYSTEM_ID).CREDIT_NOTE_POS_QTY;
ELSE
tPosQTY := 0;
END IF;
END LOOP;
END;
I get PLS-00316 in loops.
Any help will be appreciated.
With best regards,
Andrej Litowka.Hi
the .exists(n#) method will just check if the n# element exists. there is no build in function to locate or compare record or who oracle says;
Comparing Records
Records cannot be tested for nullity, or compared for equality, or inequality.
If you want to make such comparisons, write your own function that accepts two records as parameters and does the appropriate checks or comparisons on the corresponding fields. -
How to use PL/SQL Function after registering
Hi,
I have successfully registered a PL/SQL Function within Discw Admin. But i don't know how to use it further??? Please let me know the steps to use it in folders (admin) or in plus.
Actually i have a stored procedure which fetches the records from the base tables and i have to develop a report based on that data.
Please reply ASAP.
Thanks,
JayHi Jay,
If this function is a stored procedure in the right schema, you can access this function in your custom SQL like any other database functions (e.g. SUM, AVG, MAX, etc).
If you are not using a custom folder (ie. your own SQL), you can access this function in the workbook (Tools --> Calculations --> New Button --> Select Function Radio Button --> All Functions or Database Folders.). This calculation wil become a new column in the workbook.
Regards,
John -
How to register the same schema with same URL
I'm getting ORA-31085 error when try to register the same schema with same URl.
My requirement is that I should be able to reregister the same schema with the same URL .
I'm using the following function :
PROCEDURE validateXmlSchema(inp_xmlMsg IN VARCHAR2,
out_isValidDoc IN OUT NUMBER,
inp_xmlSchema IN OUT VARCHAR2,
out_varchar_notused OUT VARCHAR2)IS
xmldoc XMLType;
res number;
BEGIN
xmldoc := XMLtype(inp_xmlMsg);
res := xmldoc.isSchemaValid(inp_xmlSchema);
IF (xmldoc.isSchemaValid = 1) THEN
out_isValidDoc := 1;
ELSE
out_isValidDoc := 0;
END IF;
END validateXmlSchema;
This is used recursively.Until the schema is not validated for a given URL this function should keep on throwing error and once the schema is validated the data should be inserted in the DB.
But its not happening as of now instead the ORA-31085 is thrown second time.
Plz provide pointers to solve the issue."mjs" <[email protected]> wrote in message
news:g7kjk5$o6$[email protected]..
> "mjs" <[email protected]> wrote in message
> news:g7gl2g$i3d$[email protected]..
>> "Zorrrro" <[email protected]> wrote
in message
>> news:g7gcjv$a6n$[email protected]..
>>> I'm completely nuckered trying to find an answer
for this...
>>>
>>> Does anyone know how to keep the same width an
position of the submenus
>>> of a
>>> horizontal dropdown menu?
>>> Thank you in advance.
>>>
>>> Cheers.
>>
>> Doesn't a simple style="width:200px" in the input
tag work?
>
> I'll asume the answer is "yes", then. ;) You're welcome.
I believe the OP is talking about a dropdown menu like this
one
http://www.tjkdesign.com/articles/keyboard_friendly_dropdown_menu/default.asp
not about a "select menu".
I could be wrong though...
Thierry
Articles and Tutorials:
http://www.TJKDesign.com/go/?0
http://developer.yahoo.com/
helps you build applications and mashups -
Hi,
I want to use the EXTRACT function in Discoverer. I went through the Help for the «Import PL/SQL function» without success....
When I click the «Import» button, I see a HUGE list of functions, and I don't recognize which is the one I want.
I use that EXTRACT in the same database with PL/SQL developer and it works fine, but I get a «Function EXTRACT has not been registered with the EUL» message when I try to use it in Discoverer.
Any one knows how to «bring» the right function in the EUL ??
Thanks.I was able to import a Oracle standard package function SYS_CONTEXT and view it in Discoverer Desktop/Plus.
However when I create my own package function in a schema "xxdev" and then import via Disco Admin, I cannot view this function in Discoverer Desktop/Plus. These are the steps that I followed to implement it:
1. create package in xxdev schema
2. grant execute on package to noetix_sys & noetix_eul
3. register the function in Disco Admin
4. login to Disco Desktop/Plus and try creating a calculation field and lookup functions.
The function is not visible. I followed the exact same steps for STANDARD.SYS_CONTEXT function and it was visible. Is something missing in my steps to do?
Thanks in advance. -
Using PL/SQL Function with CLOB types and a Java Source
Hi people.
I have some problems trying to use a function in pl/sql with a CLOB parameter to a java source function.
Here is the problem: I have to read a TXT file and return a CLOB with the data of the file. The reading is done with a java source function.
The problem is how to read the file without messing the content and return it to the pl/sql function?
Another problem: If I pass a CLOB as a parameter to a pl/sql function and have to write the content to a file, how to do it without screwing the EOL chars and so?
My code is:
/******** PLSQL FUNCTIONS ********/
function fn_gravaconteudoarquivo( pv_caminho in varchar2
, pv_nomearquivo in varchar2
, pc_conteudo in clob ) return varchar2 as language java
name 'Importacao.gravaConteudoArquivo(java.lang.String, java.lang.String, oracle.sql.CLOB) return varchar2';
function fn_lerconteudoarquivoclob( pv_caminho in varchar2
, pv_nomearquivo in varchar2 ) return clob as language java
name 'Importacao.lerArquivoClob(java.lang.String, java.lang.String) return clob';
/******** JAVA SOURCE FUNCTIONS *********/
public static String gravaConteudoArquivo(String caminho, String nomeArquivo, CLOB conteudo) {
File file = new File(caminho, nomeArquivo);
PrintWriter pwFile;
String mensagem = "";
StringBuffer sb = new StringBuffer();
try {
pwFile = new PrintWriter(new BufferedWriter(new FileWriter(file,true)));
for (int i=0;i<=(conteudo.length()/32000);i++) {
sb.append(conteudo.getSubString(conteudo.getLength()+1,32000));
pwFile.println(sb.substring(0));
pwFile.close();
} catch (Exception ex) {
mensagem = "Erro: "+ex;
return mensagem;
public static CLOB lerArquivoClob(String caminho, String nomeArquivo) throws SQLException {
File file = new File(caminho, nomeArquivo);
Connection conn;
CLOB clob = null;
String lineSep = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:csdesv", "csestoque", "liberada");
clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
BufferedReader brFile = new BufferedReader(new FileReader(file.getPath()));
while (brFile.ready()) {
sb.append(brFile.readLine());
sb.append(lineSep);
clob.open(CLOB.MODE_READWRITE);
clob.setString(clob.getLength()+1, sb.toString());
clob.close();
} catch (Exception ex) {
ex.printStackTrace();
return clob;
Ah, just remembered... This will work as a JOB.... >.< ... So the connection aparently is at localhost.
Thanks.No one? I really need this....
-
How to use Pl/Sql function in Discoverer report
Hi Everybody,
Would you be able to provide a workflow/guidance how to use sql function in Discoverer right from creating the function using PLSQL Developer.
(I am new to Oracle environment... prev. worked as analyst with Microsoft Access... took PL/Sql class in school a few years ago)
We are using Discoverer Desktop.
a) Just emailed dba for permission to create pl/sql function.
b) Recently got Discoverer Administrator installed on my pc.
can you pls add to the list:
c)....
d)....
etc.?
tx for your help, sandraHi Kranthi,
Thx for your warm words....
The links you provided are great! Thx soooo much!
Thanks to you and the rest of forum members, am able to use what you've all taught me
with other Discoverer reports.... so i was able to do more on my own....
About a month ago, I got access to Discoverer Admin, and was able to paste SQL to create a custom folder.
Then i joined the custom folder to an existing baseline folder.
I have found that sometimes when I use calc within a calc when the calcs use analytic functions, that Discoverer
just displays null in the column. I thought that maybe instead I could create my own function as a work-around.
I wrote IT for permissions to create views, functions etc. Hopefully, they'll approve and can move toward learning
pl/sql functions for Discoverer.
tx again, sandra -
How to convert a sql statement with variable
hello , please how can i convert the below with cast
I need to be able to generate an explain plan, I believe I have to use cast.
SELECT TO_NUMBER (OIL.UNIQUE_ID) REBALANCE_ORDER_ID,
OIL.ORDER_QTY,
OIL.ORDER_TYPE,
OIL.ORDER_SIDE,
OIL.POSITION_TYPE,
OIL.AVAILABLE_QTY AVAILABLE_QUANTITY,
OIL.ORDER_AMT GROSS_AMOUNT,
OIL.NET_AMOUNT NET_AMOUNT,
OIL.FEE_AMT FEE_AMOUNT,
OIL.ACCRUED_INTEREST_AMT ACCRUED_INTEREST
FROM TABLE (:B6) OIL>
I need to be able to generate an explain plan, I believe I have to use cast.
SELECT TO_NUMBER (OIL.UNIQUE_ID) REBALANCE_ORDER_ID,
OIL.ORDER_QTY,
OIL.ORDER_TYPE,
OIL.ORDER_SIDE,
OIL.POSITION_TYPE,
OIL.AVAILABLE_QTY AVAILABLE_QUANTITY,
OIL.ORDER_AMT GROSS_AMOUNT,
OIL.NET_AMOUNT NET_AMOUNT,
OIL.FEE_AMT FEE_AMOUNT,
OIL.ACCRUED_INTEREST_AMT ACCRUED_INTEREST
FROM TABLE (:B6) OIL
>
You are correct - cast the bind as the proper type. I have a SQL type named emp_table_type so this works
explain plan for select * from table(cast (:e1 as emp_table_type))The types involved are
CREATE OR REPLACE TYPE SCOTT.emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
CREATE OR REPLACE TYPE SCOTT.emp_table_type as table of emp_scalar_type
/ -
How to call PL/SQL function inside column in entity
Hello,
How can I do next:
- Crete entity from existing table in database, but one column in the table gets value from function. Function is written in oracle PL/SQL language and it is located inside some package on database.
Application should run LCDS3 and tomcat.
All help is appricitatedAnil,
I'm using LCDS3, and here is what I trying to do (for example):
- I have on Oracle DB table REGION, with columns: Code, State, Population.
- I want to create entity that contains same columns as table REGION (Code, State, Population) and to have addition column RegionName witch get value from PL/SQL function (loacated in package "common" on DB) "common.fgetRegionName(Code)".
Can you explain me how to create that entity.
Thanks
Almir -
How to call pl/sql function from element values
EBS 11.5.10.2
XMLP 5.6.3
Hello,
I noticed that the output of the rdf-to-data template conversion process makes use of an undocumented feature of data templates, and I would like to get input from experts as to which situations this feature is usable.
The closest thing I can find in the documentation is a sample in the user guide. There is a "General Ledger Journals Data Template Example" that has a <dataStructure> section that contains <element> nodes which are NOT children of a <group> node. I can't find any explanation of this in the user guide.
I've noticed from converted templates that in these un-grouped elements you can make calls to PL/SQL functions in the "value" attribute, like this:
<dataStructure>
<group name="G_LINES" source="Q_MAIN">
<element name="Line_Num" value="Line_Num"/>
</group>
<element name="C_CALCULATED_VALUE" dataType="number" value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
</dataStructure>Has anyone had any success being able to call PL/SQL functions from grouped elements? Whenever I try, it doesn't seem to work.
When I try something like this:
<dataStructure>
<group name="G_LINES" source="Q_MAIN">
<element name="Line_Num" value="Line_Num"/>
<element name="some_calculation" value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
<element name="some_calculation_b" value="XX_CUSTOMPROCS.SOME_FUNCTION_B(:Line_Num)"/>
</group>
<element name="C_CALCULATED_VALUE" dataType="number" value="XX_CUSTOMPROCS.SOME_FUNCTION"/>
</dataStructure>The <SOME_CALCULATION/> and <SOME_CALCULATION_B/> nodes come out empty in the output data xml file, but <C_CALCULATED_VALUE> would have a value as desired.ah - perfect. That makes sense. Thank you for the response!
But what about when we need to pass parameters to those functions whos values are the results of aggregate element values?
This happens a lot in the converted data templates, where pl/sql package functions are meant to replace formula columns from the original Oracle Report. Take this example from the conversion of ARXAGMW.rdf (Aging Report, 7 Buckets):
(note the function call in the value of "Set_Percent_Inv_Inv" is using aggregate results from subgroups)
<group name="G_INV_INV" dataType="varchar2" source="Q_Invoice">
<element name="Total_Inv_Inv_Amt" function="sum" dataType="number" value="G_Invoice.C_Amt_Due_Rem_Inv"/>
<element name="Total_Inv_Inv_B0" function="sum" dataType="number" value="G_Invoice.C_Inv_B0"/>
<element name="Total_Inv_Inv_B1" function="sum" dataType="number" value="G_Invoice.C_Inv_B1"/>
<element name="Total_Inv_Inv_B2" function="sum" dataType="number" value="G_Invoice.C_Inv_B2"/>
<element name="Total_Inv_Inv_B3" function="sum" dataType="number" value="G_Invoice.C_Inv_B3"/>
<element name="Total_Inv_Inv_B4" function="sum" dataType="number" value="G_Invoice.C_Inv_B4"/>
<element name="Total_Inv_Inv_B5" function="sum" dataType="number" value="G_Invoice.C_Inv_B5"/>
<element name="Total_Inv_Inv_B6" function="sum" dataType="number" value="G_Invoice.C_Inv_B6"/>
<element name="Set_Percent_Inv_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.set_percent_inv_invformula(:Total_Inv_Inv_Amt, :Total_Inv_Inv_B0, :Total_Inv_Inv_B1, :Total_Inv_Inv_B2, :Total_Inv_Inv_B3, :Total_Inv_Inv_B4, :Total_Inv_Inv_B5, :Total_Inv_Inv_B6)"/>
<element name="Sum_Percent_B0_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B0_Inv_p"/>
<element name="Sum_Percent_B1_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B1_Inv_p"/>
<element name="Sum_Percent_B2_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B2_Inv_p"/>
<element name="Sum_Percent_B3_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B3_Inv_p"/>
<element name="Sum_Percent_B4_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B4_Inv_p"/>
<element name="Sum_Percent_B5_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B5_Inv_p"/>
<element name="Sum_Percent_B6_Inv" dataType="number" value="XX_CUSTOMPROCS.XXC_ARXAGMW.Sum_Percent_B6_Inv_p"/>
<group name="G_Cust_Inv" dataType="varchar2" source="Q_Invoice">
<group name="G_Site_Inv" dataType="varchar2" source="Q_Invoice">
<group name="G_1" dataType="varchar2" source="Q_Invoice">
<group name="G_Invoice" dataType="varchar2" source="Q_Invoice">
<element name="C_Amt_Due_Rem_Inv" dataType="number" value="C_Amt_Due_Rem_Inv"/>
<element name="C_Inv_B0" dataType="number" value="C_Inv_B0"/>
<element name="C_Inv_B1" dataType="number" value="C_Inv_B1"/>
<element name="C_Inv_B2" dataType="number" value="C_Inv_B2"/>
<element name="C_Inv_B3" dataType="number" value="C_Inv_B3"/>
<element name="C_Inv_B4" dataType="number" value="C_Inv_B4"/>
<element name="C_Inv_B5" dataType="number" value="C_Inv_B5"/>
<element name="C_Inv_B6" dataType="number" value="C_Inv_B6"/>
</group>
</group>
</group>
</group>
</group>
...All of these groups and sub-groups are based on one single query, so I am not sure how I would move the function call into the query without changing the results of the function.
In the example above, elements Sum_Percent_B0_Inv through Sum_Percent_B6_Inv grab the results of the calculation done in set_percent_inv_invformula. Here is the essence of that function:
sum_percent_b0_inv := ROUND ((total_inv_inv_b0 / total_inv_inv_amt) * 100, 2);
sum_percent_b1_inv := ROUND ((total_inv_inv_b1 / total_inv_inv_amt) * 100, 2);
sum_percent_b2_inv := ROUND ((total_inv_inv_b2 / total_inv_inv_amt) * 100, 2);
sum_percent_b3_inv := ROUND ((total_inv_inv_b3 / total_inv_inv_amt) * 100, 2);
sum_percent_b4_inv := ROUND ((total_inv_inv_b4 / total_inv_inv_amt) * 100, 2);
sum_percent_b5_inv := ROUND ((total_inv_inv_b5 / total_inv_inv_amt) * 100, 2);
sum_percent_b6_inv := ROUND ((total_inv_inv_b6 / total_inv_inv_amt) * 100, 2);The only solution I can think of is to have separate queries, one for each subgroup, that do the "sum" in sql; but that seems terribly inefficient. -
Help w/MaxDB Function; also: how does the "Debug SQL" function work?
Hi there forum folks,
In my former life, I was a Basis guy, but I haven't had the pleasure of working directly with SAP applications in a few months. My current project is to attempt to use MaxDB in a real estate environment. We're tracking home listings so that we can build statistical reports... such as "what agents are in the Top 100 in postal code X?"
Anyway, as part of this project, I have attempted to construct my very first MaxDB database function. Unfortunately, it doesn't give me the answers I'm hoping to see. Here's the function:
CREATE FUNCTION COUNT_LISTINGS (AGENTID CHAR(10)) RETURNS FIXED(6,1) AS
VAR COLISTINGAGENTID CHAR(10);
LISTINGAGENTID CHAR(10);
MLSNUMBER CHAR(7);
UNITS FIXED(6,1);
SET UNITS = 0;
DECLARE FUNCTIONRESULT CURSOR FOR
SELECT MLSNUMBER,
LISTINGAGENTID,
COLISTINGAGENTID FROM FREDDIE.GLAR_SOLDS
WHERE LISTINGAGENTID = :agentid OR COLISTINGAGENTID = :agentid;
IF $COUNT IS NULL THEN
BEGIN
CLOSE FUNCTIONRESULT;
RETURN UNITS;
END
ELSE
SET $RC = 0;
WHILE $RC = 0 DO BEGIN
FETCH FUNCTIONRESULT INTO :mlsnumber, :listingagentid, :colistingagentid;
IF ( LISTINGAGENTID = AGENTID AND COLISTINGAGENTID IS NULL ) OR
( COLISTINGAGENTID = AGENTID AND LISTINGAGENTID IS NULL ) THEN
SET UNITS = UNITS + 1
ELSE
SET UNITS = UNITS + 0.5;
END;
CLOSE FUNCTIONRESULT;
RETURN UNITS;
I've tried to follow the official MaxDB documentation. My first deviation from that standard was the use of the "$COUNT" variable (instead of the "$RC" variable) immediately after the DECLARE/SELECT statement above. When I tried to use $RC, for either a successful or unsuccessful query, $RC was always set to a non-zero value.
I believe I'm past that, but now my issue is down around that FETCH statement. The UNITS variable doesn't end up with the value I expect. I know that it can be terribly confusing to try to analyze someone else's logic, but here's a brief narrative that describes what I'm trying to do...
The GLAR_SOLDS table holds one line for each home sold. It's keyed by the MLSnumber. Each record also stores up to four agents who've been involved in the transaction: the listing agent, the co-listing agent, the selling agent, and the co-selling agent. The database function I've written above pertains to the listing side only. If I can get this to work, a separate function will process the selling side. If no co-listing agent is involved in a given sell, that agent should get credit for 1 unit sold. If he/she has help from a co-listing agent, the agent should only get credit for 1/2 unit sold.
Also, does anyone know how the "Debug SQL" functionality is supposed to work within Database Studio? When I right-mouse click on my function, and follow the path thru "Debug As...", after entering the connection & function arguments, I'm presented with an empty screen. If you could point me to some documentation somewhere, I'd gratefully read it.
I'm using MaxDB 7.7.06.09 on Windows XP (WIN32) with MaxDB Database Studio 7.7.06.09 (build 009-123-202-944).
Thanks everyone for your help & advice.
~FredFred,
please either provide the full SQL statements for your example or stick with mine.
I'm not going to build it up myself a second time to suit yours now.
> But now, my issue is how do I store the resultant data in its own table?
So where is the problem?
INSERT INTO <target table> (field 1, field 2, ...) (<your query>) UDPATE DUPLICATES-
With my tables this looks like this:
create table sell_result (list_agent varchar(20) primary key, SUM_CREDIT fixed (10,2))
insert
into sell_result (list_agent,sum_credit)
( select list_agent, sum (credit) as SUM_CREDIT
from ( select sh.object_id,lag.name as list_agent, 1 as credit
from soldhomes sh join agents lag on lag.id = sh.list_agent_id
union all
select sh.object_id, lag.name as list_coagent, 0.5 as credit
from soldhomes sh join agents lag on lag.id = sh.list_coagent_id
group by list_agent
update duplicates
Check what we have now
sqlcli db770=> select * from sell_result
| LIST_AGENT | SUM_CREDIT |
| -------------------- | ----------------- |
| Lars | 4.50 |
| Lisa | 3.00 |
| Mona | 2.50 |
| Paul | 2.50 |
4 rows selected (600 usec)
Now add some sales data...
Insert into soldhomes values (11, 1, 2, NULL, NULL)
Insert into soldhomes values (12, 2, NULL, NULL, NULL)
Insert into soldhomes values (13, 2, NULL, NULL, NULL)
Re-run the INSERT command and you're done:
sqlcli db770=> select * from sell_result
| LIST_AGENT | SUM_CREDIT |
| -------------------- | ----------------- |
| Lars | 5.50 |
| Lisa | 3.00 |
| Mona | 5.00 |
| Paul | 2.50 |
4 rows selected (390 usec)
Neat, isn't it? -
How can I use AGO function with aggregates
I use aggregated table and a detailed table
I have time hierarchy whose lowest level is date. For sales I
created year-to-year (YTD) comparision with AGO function. It
works OK.
BUT, I want to speed it up, so I used aggregates. I created new
time table grouped by MONTH and corresponding agg_SALES table. I
created connections and mapped the fields. It works OK for
normal queries, that means my queries at month level use
aggregates. BUT when I add YTD measures or YAGO measure in query, it goes to
then SALES table whose grain is date.
How can I force BI Server to use AGO function with aggregates?
I use OBIEE 10.1.3.4
Thank you
Ishaq
(Question originally taken from ITtoolbox and posted by Gorazd)
SORRY - THE QUESTION IS IN THE WRONG FORUM
Edited by: ishaq12 on Nov 19, 2008 12:21 PMHi,
you can not do it in Administration tool but you can set agregation for that field in Answers (fx->Agregation rule->Sum) and effect should be the same. Note that it may not work properly on Oracle 10g as generated SQL is not 100% recognized, on 11g everything is OK (at least in my case).
Regards,
Marko
Edited by: user10449532 on 2008.11.19 06:29
Maybe you are looking for
-
HT204053 Can I use one Apple ID for different itune stores in different regions?
I have itune store account in the UK. I can I use the same account to download an app. from a different store in a different region?
-
Can't retrieve pics or video from the media card in curve 8320
Hi. New & dumb to smartphones, so this 8320 is a big step into the current world. It was cheap, works great & I'm slowly getting it figured out. Only one issue so far. When I took pics without a media card & they were stored on the device, I could us
-
How to find which SDE/SIL to Customize ?
I need to do a Type 1 Customization of adding a extra column from the Source System to Target DW Table in OBIA. I am able to work out everything once i know which SDE/SIL Specifically to customize, however how to find out this one ? I went through th
-
Dialog box pop up for a second and then disappears.
For the past few weeks a dialog box has been appearing on my screen for a fraction of a second and then quickly dissappears. I am unable to read what it says, but in console it says: java is listening from ::ffff:0.0.0.0:0 proto=6. It seems to happe
-
Ios7.1 update messed up my iphone4 date & time and messages
ever since updating to ios7.1 my iphone thinks it is about 2 and 3/4 days in the future. i have tried resets, restores, reprogrammings... and it might work for a little while but then the time goes wrong again. also, in my messages, the cap locks ke