Calling a function in the select part of a query
I am integrating Apex with E-Bus Suite 11.5.10.2.
I have a function in a sql query. The function calls an apps view. When i run the sql query in TOAD, I get the correct data. When I run it in Apex, i get an error - it says "Invalid number"
My apex report is registered in my 11i menu. Who is the user that is running this report? Is it apps?
thanks
When you run it in TOAD, you are passing through a value, correct? Maybe when your EBS call to your APEX report is done, it is passing through a character value as apposed to a number. You might want to convert your passed in value in your function to a number to be sure..
Also, it is not always the best idea to call a function in a select statement.. Is there a reason you can't do in sql what your function is doing?
Thank you,
Tony Miller
Webster, TX
Similar Messages
-
Can call a function in the select statement?
Is there any ways to call a function in the select statement?
what I like to do is this:
select deptno, totalEmployees(deptno), TotalSalary(deptno)
from emp;
I know it can be done by count(*) and join tables, but my case
is much more complex and the where clauses are different from
one function to another, and have many tables to join and many
combinations
ThanksFunctions can be used in a select statement subject to certain
restrictions, see
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
server.817/a85397/statem9b.htm#2062024
It's under "CREATE FUNCTION> Keywords and Parameters> function>
Restrictions on User-Defined Functions"
Here is an except...
When a function is called from within a query or DML statement,
the function cannot:
a) Have OUT or IN OUT parameters
b) Commit or roll back the current transaction, create or roll
back to a savepoint, or alter the session or the system. DDL
statements implicitly commit the current transaction, so a user-
defined function cannot execute any DDL statements.
c) Write to the database, if the function is being called from a
SELECT statement. However, a function called from a subquery in
a DML statement can write to the database.
d) Write to the same table that is being modified by the
statement from which the function is called, if the function is
called from a DML statement.
Except for the restriction on OUT and IN OUT parameters, Oracle
enforces these restrictions not only for the function called
directly from the SQL statement, but also for any functions that
function calls, and on any functions called from the SQL
statements executed by that function or any function it calls. -
Calling a function in the select clause.
I am using Oracle 11g.
I am trying to write a query like this
select name,age, sal, avg = avg_salary(age)
from customer
where sal >= avg;
However, I am not able to do so. What the query is trying to do is print the name, age and salary of every customer as well as the average salary for the customer's age where the customer's salary is greater than the average salary for his age.
Please help. Thanks.Hi,
The way to assign a column alias is to put the alais after the expression. It makes your code clearer if you put the keyword AS after the expression and before the alias, but this is not required.
SELECT name
, age
, sal
, avg_salary (age) AS avg_salary_age
FROM customer
WHERE sal >= avg_salary (age)
;You can't reference a column alais in the same query where it is defined (except in an ORDER BY clause). If you want to reference the alias anywhere else (e.g., in the WHERE clause) you have to define it in a sub-query; then you can use it anywhere you want in the super-query, liek this:
WITH got_avg_salary_age AS
SELECT name
, age
, sal
, avg_salary (age) AS avg_salary_age
FROM customer
SELECT *
FROM got_avg_salary_age
WHERE sal >= avg_salary_age
;Since AVG is the name of a built-in function, there could be problems using it as a column alias. You could call it average, if you don't like avg_salary_age. -
ODI Error - Calling a function in the source database
I am using this directly in the Interface mapping and getting the following error
This is the syntax I am using SUM(CASE WHEN ((main.getCertDate(person_id,getdate()) >= current_timestamp) THEN 1 ELSE 0 END)
ODI-1228: Task Load_Fact_Table1 (Integration) fails on the target MICROSOFT_SQL_SERVER connection SQLSERVER_USA.
Caused By: java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver][SQLServer]Cannot find either column "main" or the user-defined function or aggregate "main.dbo.getCertDate", or the name is ambiguous.
Am I missing any additional steps, before calling a function in the mapping. Do I have to do something in the model to include teh function etc., Please help in fixing this issue.
Thanks for your time and help.Hi Michael, Please see below.
IKM - MSSQL Incremental Update
Failing on Step 3 - Integration - Insert flow into I$ table
insert into db11.dbo.##I$_FCT_TABLE
COMP_ID,
CNT_CLP_TARGET_MET,
CNT_CERTIFIED,
CNT_NOTCERT_WITHIN_GRACE_PRD,
CNT_CERT_OR_WITHIN_GRACE_PRD,
CNT_CERT_DELINQUENT,
SUM_OF_AGE,
SUM_OF_YEARS_EXPERIENCE,
LOAD_DATE,
IND_UPDATE
select
CASE WHEN DIM_COMP.COMP_ID IS null then -9999
ELSE DIM_COMP.COMP_ID
END,
SUM(CASE WHEN ((main.dbo.getCertDate ([DISTINCT_RWF.MASTERKEY],GETDATE()) >= CURRENT_TIMESTAMP) OR DISTINCT_RWF = 'NO') THEN 1 ELSE 0 END),
CURRENT_TIMESTAMP,
'I' IND_UPDATE
from ((
select DISTINCT
REPORT_WORKFORCE_REVIEW.REGION as REGION, REPORT_WORKFORCE_REVIEW.COMPO as COMPO, REPORT_WORKFORCE_REVIEW.PERSON_ID as PERSON_ID, REPORT_WORKFORCE_REVIEW.WF_STATUS as WF_STATUS, REPORT_WORKFORCE_REVIEW.PERSON_NAME as PERSON_NAME, REPORT_WORKFORCE_REVIEW.CPCN_NUM as CPCN_NUM, REPORT_WORKFORCE_REVIEW.COMMAND as COMMAND, REPORT_WORKFORCE_REVIEW.UIC as UIC, REPORT_WORKFORCE_REVIEW.UIC_STATE as UIC_STATE, REPORT_WORKFORCE_REVIEW.ORG_STRUCTURE_CODE as ORG_STRUCTURE_CODE, REPORT_WORKFORCE_REVIEW.ORG_DESC as ORG_DESC, REPORT_WORKFORCE_REVIEW.LOCATION as LOCATION, REPORT_WORKFORCE_REVIEW.STATE as STATE, REPORT_WORKFORCE_REVIEW.SVC_COMP_DATE as SVC_COMP_DATE, REPORT_WORKFORCE_REVIEW.YRS_OF_SERVICE as YRS_OF_SERVICE, REPORT_WORKFORCE_REVIEW.POSITION_ENTER_DATE as POSITION_ENTER_DATE, REPORT_WORKFORCE_REVIEW.MTHS_EXP_IN_PRESENT_POS as MTHS_EXP_IN_PRESENT_POS, REPORT_WORKFORCE_REVIEW.MTHS_EXP_IN_CURRENT_APC_ACL as MTHS_EXP_IN_CURRENT_APC_ACL, REPORT_WORKFORCE_REVIEW.AGE as AGE, REPORT_WORKFORCE_REVIEW.SEX as SEX, REPORT_WORKFORCE_REVIEW.SUPV_CODE as SUPV_CODE, REPORT_WORKFORCE_REVIEW.ACF as ACF, REPORT_WORKFORCE_REVIEW.CP as CP, REPORT_WORKFORCE_REVIEW.SERIES as SERIES, REPORT_WORKFORCE_REVIEW.DUTY_TITLE as DUTY_TITLE, REPORT_WORKFORCE_REVIEW.APT as APT, REPORT_WORKFORCE_REVIEW.APT_DESC as APT_DESC, REPORT_WORKFORCE_REVIEW.API as API, REPORT_WORKFORCE_REVIEW.SAA as SAA, REPORT_WORKFORCE_REVIEW.GRADE as GRADE, REPORT_WORKFORCE_REVIEW.HI_DEGREE as HI_DEGREE, REPORT_WORKFORCE_REVIEW.LVL_DESC as LVL_DESC, REPORT_WORKFORCE_REVIEW.APC as APC, REPORT_WORKFORCE_REVIEW.ACL as ACL, REPORT_WORKFORCE_REVIEW.CERT_LVL_ACHIEVED_IN_APC as CERT_LVL_ACHIEVED_IN_APC, REPORT_WORKFORCE_REVIEW.CERT_IN_POSITION as CERT_IN_POSITION, REPORT_WORKFORCE_REVIEW.CERT_BELOW_POSITION as CERT_BELOW_POSITION, REPORT_WORKFORCE_REVIEW.NOT_CERTIFIED as NOT_CERTIFIED, REPORT_WORKFORCE_REVIEW.CLP as CLP, REPORT_WORKFORCE_REVIEW.LAST_IDP_UPDATE as LAST_IDP_UPDATE, REPORT_WORKFORCE_REVIEW.LAST_IDP_UPDATE_MTHS as LAST_IDP_UPDATE_MTHS, REPORT_WORKFORCE_REVIEW.SUPV_REVIEW_DATE as SUPV_REVIEW_DATE, REPORT_WORKFORCE_REVIEW.SUPV_REVIEW_DATE_MTHS as SUPV_REVIEW_DATE_MTHS, REPORT_WORKFORCE_REVIEW.EMAIL as EMAIL, REPORT_WORKFORCE_REVIEW.MASTERKEY as MASTERKEY
from main.dbo.REPORT_WORKFORCE_REVIEW as REPORT_WORKFORCE_REVIEW
where (1=1)
) as DISTINCT_REPORT_WORKFORCE_REVIEW LEFT JOIN main.dbo.PERSON as PERSON ON DISTINCT_REPORT_WORKFORCE_REVIEW.MASTERKEY=PERSON.MASTERKEY) LEFT JOIN main.dbo.ACQUISITION_CORPS_QUALIFICATION as ACQUISITION_CORPS_QUALIFICATION ON DISTINCT_REPORT_WORKFORCE_REVIEW.MASTERKEY=ACQUISITION_CORPS_QUALIFICATION.MASTERKEY) LEFT JOIN main.dbo.PERSONS_POSITIONS as PERSONS_POSITIONS ON DISTINCT_REPORT_WORKFORCE_REVIEW.PERSON_ID=PERSONS_POSITIONS.MASTERKEY
AND PERSONS_POSITIONS.POSITION_END_DATE IS NULL) INNER JOIN db11.dbo.DIM_COMP as DIM_COMP ON DISTINCT_REPORT_WORKFORCE_REVIEW.COMPO=DIM_COMP.COMP_CODE AND DIM_COMP.CURRENT_RECORD_IND = 1) LEFT JOIN db11.dbo.DIM_POSITION_TYPE as DIM_POSITION_TYPE ON DISTINCT_REPORT_WORKFORCE_REVIEW.APT=DIM_POSITION_TYPE.POSITION_CODE
AND DIM_POSITION_TYPE.CURRENT_RECORD_IND=1) -
Hi
can someone please show me how to call a function from a select* statement.
Thanks
Helenaselect age
from show_details
where age=func_test();
Here the function returns some value that function definition is like
CREATE OR REPLACE FUNCTION func_test RETURN NUMBER
AS
lv_a NUMBER;
BEGIN
lv_a := 0;
lv_a := lv_a + 1;
RETURN lv_a;
dbms_output.put_line(lv_a);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error is '||SQLERRM);
END;
This is to manually call a function
DECLARE
v_a NUMBER;
BEGIN
v_a := func_test();
dbms_output.PUT_LINE(v_a);
END;
************The o/p is '1'.
If the show_details table contains the age value as 1 then the field will be selected by calling the function. -
Calling a Function in the Parent Window from the Child Window
QUESTION: How do I call a function resident in the parent
window from a child window?
BACKGROUND
I have a JavaScript function resident in the parent window
that reformats information obtained from the Date object and writes
the result to the parent window using the document.write( ) method.
I would like to call this function from the child window and have
it write to the child window instead. Is this possible? If not,
must I rewrite the entire function and nest it in the below code?
If so, what is the proper form of nesting?
CODE: The code that creates and fills the child window is
provided below. The highlighted area indicates where I would like
to enter the information from the function resident in the parent
window. I have tried every imaginable permutation of code that I
can imagine and nearly destroyed my parent document in the process.
I am very happy that I had a back-up copy!
function openCitationWindow() {
ciDow = window.open("", "", "width=450, height=175, top=300,
left=300");
ciDow.document.write("A proper way to cite a passage of text
on this page:<br /><br />Stegemann, R. A. 2000.
<cite>Imagine: Bridging a Historical Gap</cite>. " +
document.title + ". [<a href='" + location.href + "'
target='_blank'>online book</a>] <" + location.href
+ "> (");
MISSING CODE;
ciDow.document.write(").<br /><br /><input
type='button' value='Close Window' onclick='window.close()'>");
ciDow.focus();Never mind - I was doing something very stupid and wasn't
calling the function as a method of a movie clip. I was simply
calling checkTarget(event) rather than
event.currentTarget.checkTarget(event); which seems to work. -
Calling a function in the main movie from a loaded swf
I realize this is probably a very basic question, but I have
loaded a SWF file into another movie. I now want to call a function
in the main SWF. Is there a way to do that? Alternatively, I have a
custom class where I could put the function, but I haven't been
able to figure out how to call it from the loaded SWF either. Do I
somehow need to associate the class with the main movie,
or...?Never mind - I was doing something very stupid and wasn't
calling the function as a method of a movie clip. I was simply
calling checkTarget(event) rather than
event.currentTarget.checkTarget(event); which seems to work. -
Calling a function in the HTML window the course sits inside - Captivate 8
Hi,
I've scoured the forums for an answer to this but as yet have come up blank.
Our LMS launches a course in a popup window and inside of this the .htm Captivate output file sits.
Currently this pop up window has a button in it which executes a function. The problem is this button is rather unsightly sitting above the course in the HTML window and I'd like to be able to call this function from inside the Captivate course itself.
The function is called closeSCOContent() and it closes the course window but crucially forwards the user to a feedback page.
So essentially is it possible to call this function using the Javascript function in Captivate 8?
I hope I've explained that sufficiently
Many thanks!Hi,
This gave me the nudge in the right direction I needed, after a bit of basic frameset research I've got the desired functionality.
Huge thanks! -
How do i call a function within the jsp?
Hi,
What i am doing is now allow a user to type in comment and when the user click on "Add" button, it will call my function and write to a txt file.How can i call a custom jsp function within my jsp page or what is the correct way to do this?
[My current codes]
<form name="SubmitEvent" method="post" action="addComment()">
</form>
function addComment()
System.out.println("Entered Add Comment function");
Thanks for your help!You can define a Java Bean (I presume you know the rules to write a Java Bean) and send the read value as parameter to the Bean and then call a function in the Bean from the JSP.
Contact me if you need more help! -
Call a function in the shell SWF from a imported SWF
We have flash set up as a shell to take lesson data from XML
and display it frame by frame.
We import SWF files when the XML tells it to to be displayed
on the frame.
How can I get the imported SWF file to call a function in the
shell....
basically have a button or movie clip in the imported swf
call the "gotoNextFrame()" function in the shell.We found a "bit" easier way if anyone is interested.. we have
the have an eventlistner added to the loader to assign a event to
the swf file thats imported:
flashLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
addEventHandlers);
then when its completed, it adds event listeners and calls
our "goNextFrame" function (then clears it when its removed from
the stage):
function addEventHandlers(event:Event):void
var swfMC:MovieClip = event.target.content as MovieClip;
swfMC.addEventListener("NextFrame", goNextFrame);
swfMC.addEventListener("PreviousFrame", goPrevFrame);
swfMC.addEventListener(Event.REMOVED_FROM_STAGE,
clearEventListeners);
Then in the swf file thats to be imported, its real simple:
next_btn.addEventListener(MouseEvent.CLICK, MoveToNextFrame);
prev_btn.addEventListener(MouseEvent.CLICK,
MoveToPreviousFrame);
function MoveToNextFrame(e:MouseEvent):void
dispatchEvent(new Event("NextFrame"));
function MoveToPreviousFrame(e:MouseEvent):void
dispatchEvent(new Event("PreviousFrame")); -
Is there a call block function for the iPhone 4S?
Is there a call block function for the iPhone 4S? If not, will it be offered in the future? what else can I do to the phishing calls?
No.
Apple has not said.
Don't answer your phone. -
Access to the logic functions on the numeric part of a Logickeyboard
I have connected a logic keyboard (the one with the coloured shortcuts) to my Mac Book Pro. However, the numeric part (with stop, play, record, etc) is not working. Logic does not respond on the input through that numeric part. The main part of the keyboard works well, including the shortcuts to for example the bin, the mixer
Does anyone has experience with this problem?
I mean, there isn't a numlock key on the keyboard. So how do you get access to the functions on the numeric part?Q1: yes i have tested it in word and then numbers appears
Q2: the key commands are the simple ones
Like the enter is play, the 0 is stop, the 2 is mixer
What i'm looking for is the key (like shift or fn) that changes the functions of the numpad -
I need use conditions in the select fields of a query.
Hello,
Is possible, that I can have conditions in the select fields of a query? In a invoice when the type is cancellation I want to put *-1 to price and if is other type the price is normally.
If VBRK.FKART = 'S1' THEN KWERT*-1 else KWERT .
Thank you very much.you can do two things:
1. select the data into internal table and loop through the internal table and do the necessary changes
SELECT fkart kwert
FROM vbrk
INTO TABLE itab
WHERE ...
LOOP AT itab.
IF itab-fkart EQ 'S1'.
itab-kwert = itab-kwert * -1 .
MODIFY itab.
ENDIF.
ENDLOOP.
2. use select-endselect and change the data acc. to your needs inbetween and append the internal table.
SELECT fkart kwert
FROM vbrk
INTO wa
WHERE ...
IF wa-fkart EQ 'S1'.
wa-kwert = wa-kwert * -1 .
ENDIF.
APPEND wa TO itab.
ENDSELECT.
(The first approach is probably faster.) -
Order of the selection fields in SAP QUERY
Hello All,
How can we set the order of the selection fields in SAP QUERY!
Regards!
AshishHi,
You can go into infoset and change the order.
Or you can select 1 by 1 in the same order, you want to display.
Below is the link which might help you:
help.sap.com/printdocu/core/Print46c/EN/data/.../BCSRVQUE.pdf
Please revert, if needed more clarifications
Regards,
Yashwin -
Call a function when the active document is closed
Hi friends
I have a portion of my script (at true a specific function) that I´d need to be executed every time the user close the app.activeDocument in Photoshop.
I know there´s a Photoshop script called "Script Event Manager" where we can associate actions and scripts with events (like closing the document). I´d not like to use this script because..as I told...it´s not my entire script to be runned when closing a file..but only a function.
Tried to search in the Script Event Manager for any event called "onClose" () but sure there´s nothing.
How could I insert an event in the body of my own script that calls a function every time user close the active document?
Thank you a lot for the help
Best Regards
Gustavo.As I said before the close event is really not that useful. In addition to the document already being closed the event descriptor will only have the path to the closed file if it was saved as part of the close event.
But if you want to play around with this to see if it will be helpful to you here is one way. You will need to add the notifer. This only needs to be done once unless it is removed.
app.notifiersEnabled = true;
app.notifiers.add( "Cls ",new File('~/desktop/closeEventHandler.jsx') );
Then for the event handler script, something like this.
try {
if (arguments.length >= 2) {
var filePath;
var desc = arguments[0];
if( desc.hasKey( stringIDToTypeID('in') ) ) filePath = desc.getPath(stringIDToTypeID('in'));
if( filePath != undefined ) alert( decodeURI( filePath ) );
} catch (e) {}
Maybe you are looking for
-
Unable to successfully download Production Premium CS5.5
Hello I am using a corporate broadband network and have tried for 3 days and 2 nights to download Production Premium CS5.5 for Mac (the main installer which is 8.8 GB). We purchased 4 licenses, but I'm unable to download the installer. Friday, I left
-
I have been working on a project for quite some time involving a jpeg. A client wanted me to flip the picture so the font pops up better. Upon removing the picture from the An folder (where the links are) and then getting it back there, I can no long
-
I've been having a go at a few time lapse movies using Photoshop CS5 on the Mac. I have kind of 2 linked queries: 1) The easy way to make a movie is to use file>open and choose a batch of photos while ticking Image Sequence. However this doesn't seem
-
Loading variations between T1 and DSL
When I test my website using the simulate download I get different results for T1 and DSL. T1 loads the site perfectly, however DSL skips certain components. This is the site in question: www.meyerhoffer.com My client says that they experience this e
-
Dear All, let me explain my current situation we have 2 server, one is running SQL Server 2008 (32 bit) and the others running SQL Server 2012 (64 bit). when we try to backup restore the data from SQL Server 2008 (32 bit) to SQL Server 2012 (64 bit