Calling a cfc through a udf
Is it possible to call a cfc function through a udf, or maybe im just looking at this the wrong way but here is what im ultimately trying to do.
I have the following table:
tbl_users
=====================
uid name
=====================
1 John
2 Steve
3 Joe
4 Bob
Then throughout the program i am given a few of the uid, and i have to loop through them and get the names, so im trying to figure out a way to make a function so i can call it like this and it checks the db and gives me the name:
getName(uid) = returns name
Is there any easy way of doing something like this?
case 1: user-defined function alone
<cffunction name="getNameFromId">
<cfargument name="id" default="1">
<cfset var selectedUser = "">
<cfset user = arrayNew(1)>
<cfset user[1] = "John">
<cfset user[2] = "Steve">
<cfset user[3] = "Joe">
<cfset user[4] = "Bob">
<cfset selectedUser = user[arguments.id]>
<cfreturn selectedUser>
</cffunction>
<cfoutput>#getNameFromId(3)#</cfoutput>
case 2: (a) content of CFM page userName.cfm
<cfset userObject = createobject("component", "User")>
<cfoutput>#userObject.getNameFromId(2)#</cfoutput>
<!--- Alternative, using cfinvoke --->
<!---
<cfinvoke component="User" method="getNameFromId" returnVariable="userName">
<cfinvokeargument name="id" value="2">
</cfinvoke>
<cfoutput>#userName#</cfoutput>
--->
(b) The user-defined function is in a component saved as User.cfc in the same directory as the page userName.cfm
<cfcomponent displayname="User">
<cffunction name="getNameFromId">
<cfargument name="id" default="1">
<cfset var selectedUser = "">
<cfset user = arrayNew(1)>
<cfset user[1] = "John">
<cfset user[2] = "Steve">
<cfset user[3] = "Joe">
<cfset user[4] = "Bob">
<cfset selectedUser = user[arguments.id]>
<cfreturn selectedUser>
</cffunction>
</cfcomponent>
Similar Messages
-
Calling UDF through another UDF
Hi Experts,
I have defined a function library and defined few UDFs in it.
I have a requirement where i need to create a new UDF which has the logic for all the other UDFs defined.
Is it possible to call one UDF defined in the FL in another UDF?
If yes, please suggest how it can be achieved.
Alpa.Hi,
There is a possibilty of calling java function in a udf .
Suppose u write a udf java code( suppose funcion name is Average()) to find out average of 3 numbers and save it as java archive and go to mesage mapping-> functions tab-> imported archives,
there u can add your jar file.
Now u can write a udf in your functions tab, there you can call Average() function and it will work.
Thanks,
Rohini -
RPC fault when calling a CFC from flex
Hello there,
I'm having some startup problems getting Flex and Colfusion 8
to play nice with FDS. I'm using Flexbuilder 2.0.1 and Coldfusion 8
developer edition on IIS on a windows box (XP professional).
I use a very simple test CFC in my coldfusion site with just
one function called 'getstring' which, surprise, surprise returns a
string. I want to show this string on a label in my Flex frontend
by using <mx:remoteobject>, the whole thing compiles
perfectly, I use this mxml:
<mx:RemoteObject id="TestService"
source="cfc.DataTest"
destination="ColdFusion"
concurrency="multiple"
makeObjectsBindable="true"
showBusyCursor="true">
<mx:method name="getString"
result="doResult(event.result)" fault="doFault(event.fault)"/>
</mx:RemoteObject>
but after calling the remote method I get this error back:
[RPC Fault faultString="coldfusion.xml.rpc.CFCServlet cannot
be cast to coldfusion.runtime.CFPage" faultCode="Server.Processing"
faultDetail="null"]
Which is the same type of error I get when I call a CFC
directly through the address bar in my browser, for example
http://localhost/cfc/datatest.cfc
I tried googling the error message but so far found nothing
that indicated what I'm doing wrong...
I'd really appreciate some help here, if you need more info
let me know...
thanx in advanceOk, nevermind, I figured out what I was doing wrong. I had
accidentally setup my application.cfc in a wrong way, I had set all
of the onrequest en onapplication event handlers to
access="package" instead of "public", this generated an error
ofcourse...
I'll just go bang my head against a wall for a while
now.... -
is there a way to find out who invoked a CFC? I would like to
check and log who the calling .CFM or .CFC file is from within the
CFC being invoked. Sort of like back in the Custom Tag days, I need
to know which templated called me. I am looking at the
GetMetaData() and GetPageContext() functions but nothing stands out
yet as how to do what I need to do.
Thanks All for the Posts below,
This is a pretty tough one, and I wish I could diagram it to
help explain.
cfc1
cfc2
cfc55
In any of these CFC's, we have code wraped in try/catch
statements. When an exception is thrown, the catch statements kick
in. in the catch blocks, I invoke a cfc called myErrorCFC.cfc..
err = createObject("component", "myError");
From there inside of the catch block I am invoking a method
(see below) which performs legancy handling/logging.
err.parseException(cfcatch.Message);
What I now need to do is extend that method to log who thrown
the exception. Yes the simple way is to pass the name of the cfc or
cfm page as an argument, but changing the code which invokes the
err cfc is out of my control. So I am left with trying to solve
this the hard way.
So far this is where I am at (in my "myErrorCFC.cfc", invoked
from within the catch blocks) which is not currently working:
tmp = getPageContext().getException();
This does not work but it may clearify the approach I am
taking. Does anyone have any good ideas on how to return the error
object from the JRun/jsp/java side of things. "getPageContext()"
returns a "coldfusion.runtime.NeoPageContext" object. The end
result I am trying to achieve is simply (ha ha) to find out which
cfc or cfm page that the exception was thrown and having access to
any additional info would be benificial as well.
Any help will be appriciated greatly.
Thank you,
ErikThx for your response, passing an argument would idealy be
the simplest approach but in the context of the problem it would
not be posible. I am working with a VERY large application and to
do so would mean modifying hundreds of lines of code where the CFC
I'm invoking is called from throughout the system. With large
legancy systems as you know, it's always exceptable to make
sweeping changes through sensitive code. If I end up not being able
to find a method in which to find who invoked the CFC I am
modifying I will just have to live with the fact. Idealy I want to
be able to track and log who it was that initiated the CFC. That
can come from a number of model cfm files or cfc's. -
Is there a software in which I can hook up my iPhone 4s to my computer and send and receive text messages and calls (via headset) through my computer? Whether it's free or cost money, can someone please give me a name of a program or software that allows me to do this? I can't seem to find anything like this for the iPhone.
No.
-
Hi,
I am using Windows Server 2012 R2 Standard, SSIS 2012. I am trying to copy files from a remote location by calling pscp.exe through a batch file (FileCopy.bat at location M:\bin\) which is referenced in a SSIS Execute Process Task. My batch file content
is,
ECHO OFF
echo. >> M:\Prod\bin\SourceFile_FileLog.txt
echo %date% - %time% - Copy Start (XYZ_a201211155952avx0_69999.NOR.gz) >> M:\Prod\bin\SourceFile_FileLog.txt
M:\ProdFiles\bin\pscp.exe -unsafe -scp -pw aaaaa myuser@sourceserver:/ABC_data/*.NOR.gz M:\Prod\FromMediation\
echo %date% - %time% - Copy Complete >> M:\Prod\bin\SourceFile_FileLog.txt
The error I am getting is
[Execute Process Task] Error: In Executing "M:\bin\FileCopy.bat" "" at "", The process exit code was "1" while the expected was "0".
Exactly same setup but using Windows Server 2003 R2 Enterprise and SSIS 2005, this works fine and copies the files successfully.
Please provide some guidance on this.
Thank you!
'In Persuit of Happiness' and ..... learning SQL.Hi,
This is what I am getting while running the batch file from command prompt
M:\bin\mttrb1>CDR_FileCopy
M:\bin\mttrb1>ECHO OFF
The system cannot find the path specified.
The system cannot find the path specified.
scp: M:\Prod\FromMediation\: Cannot create file
scp: M:\Prod\FromMediation\: Cannot create file
scp: M:\Prod\FromMediation\: Cannot create file
The system cannot find the path specified.
'In Persuit of Happiness' and ..... learning SQL. -
How to call java function through Web Service
Hello Experts,
I want to call a method through Java Web Service in my abap code. Is it possible ? If so, plz guide me.
Requirement: In SD module user enters the PAN, on after entering PAN in want to validate it on NSDL. For that a Web Service has already been deployed on a Web Server. and that the deployed Web Service I want to call in abap code.Hi,
check this link
Re: Call to WS from one backend to other backend
regards
afzal -
How to call java fanction through Web Service
Hello Experts,
I want to call a method through Java Web Service in my abap code. Is it possible ? If so, plz guide me.
Requirement: In SD module user enters the PAN, on after entering PAN in want to validate it on NSDL. For that a Web Service has already been deployed on a Web Server. and that the deployed Web Service I want to call in abap code.Hi,
check this link
Re: Call to WS from one backend to other backend
regards
afzal -
How to call the Jsp through BPM Obejct
Hi,
I have gone through the some topic, how to call the Jsp through BPM Object.
I have followed step below,
1. I have create the sample jsp page
2. Import into BPM studio under webroot\custom Jsp
3. Created the screenflow and added the "Interactive Component call" object
4. Right Click the Object and selected Maintask and Implementation type as "BPM Object Interactive Call"
5. Selected the use JSP presentation object option and when i click ok its showing "BPM instance object must be selected"
But when i select the Instance Variable tab, its not showing anything.
Can any one help me how to call the Jsp in screenflow with step by step procedure, that would be very greate help for me.
Regards,
Anandh PHi,
You are running a jsp report through rwservlet. In this case paper layout will be displayed. You have to deploy your jsp as web report to get the web layout. Please refer to the doc below, which describes how to deploy the web report.
http://download-uk.oracle.com/docs/html/B10314_01/pbr_run.htm#1011901
To run the jsp report, URL may look like
http://www.wwt.com/reports/<jsp name>?<parameter list>
Hope this helps
Vinayak -
Can a third person track on messages and calls sent/received through apple id
can a third person track on messages and calls sent/received through apple id
You're welcome.
If you think this is happening to you, change your Apple ID password. -
Problem in calling stored Procedure through Toplink
Hi ,
I'm doing POC of calling stored thru toplink but facing some issues. Any pointers to it would be helpful.
This is my javaCode used to call stored proc through toplink:-
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("testdeleteLeafBox");
call.addNamedInOutputArgumentValue(
"box_id", // procedure parameter name
new Integer("1455"), // in argument value
"box_id", // out argument field name
Integer.class // Java type corresponding to type returned by procedure
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
Integer metricLength = (Integer) session.executeQuery(query);
My Stored Procedure is :-
create or replace procedure testdeleteLeafBox(
v_box_id IN NUMBER ,
result OUT number
is
v_result number;
BEGIN
SELECT client_id INTO v_result FROM tb_gvhr_box WHERE box_id=v_box_id;
result:=v_result;
end testdeleteLeafBox;
Thrown exception is :-
[TopLink Warning]: 2006.02.24 06:35:47.077--DatabaseSessionImpl(650)--Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TESTDELETELEAFBOX'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call:BEGIN testdeleteLeafBox(box_id=>?); END;
bind => [1455 => box_id]
Query:ValueReadQuery()
Exception breakpoint occurred at line 1927 of Session.java.
oracle.toplink.exceptions.DatabaseException: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TESTDELETELEAFBOX'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredThe stored procedure defined in the db has one IN and one OUT parameter, therefore in StoredProcedureCall you'll need to have one IN one OUT parameter as well (instead of a single INOUT):
call.addNamedArgumentValue(
"v_box_id", //procedure IN parameter name
new Integer("1455"));
call.addNamedOutputArgument(
"result", //procedure OUT parameter name
"box_id", // out argument field name
Integer.class // OUT parameter Java type); -
Why cant i use a bought call-tone bought through I-tones for calling tones for just one of my contacts?
What makes you believe that you can't? To set a custom ringtone (or SMS tone) for a contact, go to that contact entry, tap the Edit button in the upper right. You can then edit both ringtones and SMS tones for that contact.
-
Hello All,
I can Call from any Branch office to CUCM through Gatekeeper. But I cannot call from CUCM through Gatekeeper to any Branch.
My CUCM version is 9.1.2
Regards
BahlulDo you see anything shw up on the debugs on the branch router?
Check debug h225 asn1 to see if there is a setup coming from the CUCM. If not, that means the CUCM is not receiving the IP address of the branch gateway from the GK. This could mean a config issue on the GK with respect to the branch gateways, or on the UCM.
Take debug gatekeeper main 10 from the gatekeeper. These debugs will show what's happening on the GK while processing the incoming ARQ from CUCM.
Also please upload the config of the GK, branch gateway here.
Hantale
Sree -
Issues in calling Sql Loader through forms developer (10g)
Hi,
I am developing a form(in 10g) ,in which I am calling sql loader for loading data onto a oracle database table from external source (e.g. data file is a .CSV file).
But , somehow the sql loader is not getting executed.
Here , I am giving the environment settings , approach i am taking;
This is a distributed system , both the application server,and database server are mounted on two different servers.
The form is delpoyed on the application server.
The database table , and the sql loader are configured on the databse side.
I am using host(<sql loader command>) command to invoke the Operating System command through forms.
The sql loader is working ok , and the data is getting loaded successfully onto the required database table when I am executing the sql loader command on Unix prompt , but through the forms , it's not working.
Do I need to change some environmental setting to make this work...
Any quick help in this regard is highly appreciated.
Thanks.Hi Craig,
I have already tried out the option of calling sql loader through stored procedure,but this is not working ...
could you please share any examples to do so ...
code snippet i am using in forms:
declare
usid get_application_property(userid);
pwd get_application_property(password);
db get_application_property(host);
msqlldr varchar2(250);
begin
msqlldr:='/u01/oracle/formss/bin/sqlldr' username=<uid/pwd@db> control=<control file name> data=<data file name> log=<log file name>
hosts(msqlldr);
end;
Note that sqlldr command ,for that matter any unix shell command is not working through the hosts() command ...
could you please suggest any way out ...
Thanks. -
Calling SQL Loader through Forms using webutils
hi all,
Can anyone tell me how can i call a sqlldr through forms 9i using webutils?Let me know if anyone have a sample script.
Thanks
Best Regards,
Abrar
[email protected]If your middle tier and database server are both unix boxes you could use host(rsh...)
Are you suggesting webutil because your data to be loaded is on the PC ? If so you probably want to move it then load it as two seperate operations.
If there isn't too much data you also have the option of using text_io to load it into a forms database block, which has the advantage that the user can see what is happening, and validation rules could be added if required.
Maybe you are looking for
-
G3 B&W fails to run OS 9.2.2
We have a G3 Blue & White I'm trying to install OS 9.2.2. The installer disc I have is the latest (I believe) last release. The Mac OS ROM is version 10.1.1. The machine is currently running OS 8.6. The machine boots the CD with no problem and instal
-
Receiver Type Function Module in SWE2 use of export parameter.
i am trying to understand the underlying concept in following things:(neednot to say i have searched alot and read sap documentation already). In event type linkage table say i have an entry for BOR -> AFVC_PM. As per sap Documentation says all these
-
Hello to All, I have made A/R invoice of 10000/- now i want to make incomming payment but when i click on incomming payment form then it show me Link Primary sales accounts has not been completed what i do for same ? Thanks Dipak
-
Correct LDAP property definition in JAZN config ?
I specified LDAP in the orion-application.xml file for my app and also specified that in the jazn config file. But it seems to create only GenericProvider object. Also, when I try to get realms from the realm manager object, I get an exception - orac
-
"Unable to perform this operation because No enough ram"? Insolent!
Hello, I use Photoshop CS4 Extended and I don't speak english but..... When using the quick selection tool sometimes gives me the following message "Unable to perform this operation because the available RAM is insufficient." Actually I do not unde