Function calls in cfscript
i am looking for an example of using cfscript to pass varibles into a query and NOT HARDCODED into the addParam value attribute.
Sugesstions ?
You could just create your own custom function. To illustrate, take the following example from the documentation:
<cfscript>
queryService = new query();
queryService.setDatasource("cfdocexamples");
queryService.setName("getParks");
queryService.addParam(name="state",value="MD",cfsqltype="cf_sql_varchar");
queryService.addParam(value="National Capital Region",cfsqltype="cf_sql_varchar");
result = queryService.execute(sql="SELECT PARKNAME, REGION, STATE FROM Parks WHERE STATE = :state and REGION = ? ORDER BY ParkName, State ");
getParks = result.getResult();
</cfscript>
<cfdump var="#getParks#">
You could customize it as follows:
<cfscript>
queryService = new query();
queryService.setDatasource("cfdocexamples");
queryService.setName("getParks");
qParams = getQueryParams();
result = queryService.execute(sql="SELECT PARKNAME, REGION, STATE FROM Parks WHERE STATE LIKE '#qParams.stateFirstLetter#%' and REGION LIKE '#qParams.regionFirstLetter#%' ORDER BY State, ParkName");
getParks = result.getResult();
function getQueryParams() {
var myParams=structnew();
myParams.stateFirstLetter = "M";
myParams.regionFirstLetter = "N";
return myParams;
</cfscript>
<cfdump var="#getParks#">
Similar Messages
-
Help:Function call from CFScript
I need to write a function call within
<cfscript></cfscript> but not sure with the syntax. I
got error message with the suntax I wrote (see below).
All I need is for the function AddVal () to pass an Array
within the existing loop.
<CFSCRIPT>
//Existing codes
Function ExistingFunction(ParameterA) {
//some codes here
for ( i = 1; i LTE listLen( fileCon, crlf ); i = i + 1 ) {
//some codes was written here to generate a 2 dimensional
Array called: MyArray
// I need to write my function here, so on every loop it
will pass an array to be inserted to DB
function AddVa(MyArray); >>>>> ??????????????
<CFFUNCTION name="AddVal">
<cfargument name="MyVal" type="Array" required="true">
<cfquery name="MyQuery datasource="MyDatasource>
// insert statement here
</cfquery>
</CFFUNCTION>
</CFSCRIPT>pls try this.
//syntax to call a function inside cfscript is given below.
//variablename = functionname(pass ur argument);
change ur code like this.
<!--- First, clean up the CFSCRIPT block --->
<CFSCRIPT>
function ExistingFunction(ParameterA) {
//some codes here
for ( i = 1; i LTE listLen( fileCon, crlf ); i = i + 1 ) {
//some codes was written here to generate a 2 dimensional
Array called: MyArray
getIP=AddVal(MyArray);//syntax to call a function inside
cfscript.
</CFSCRIPT>
<!--- since you're doing a query move this function
outside the CFSCRIPT block
...you can still call it from your CFSCRIPT block --->
<CFFUNCTION name="AddVal">
<cfargument name="MyVal" type="Array" required="true">
<cfquery name="MyQuery datasource="MyDatasource>
// insert statement here
</cfquery>
</CFFUNCTION>
try this and inform. -
Revision: 3045
Author: [email protected]
Date: 2008-08-29 10:59:25 -0700 (Fri, 29 Aug 2008)
Log Message:
Fix FB-13900: Expression Evaluator: 'is' and 'as' expressions return 'Target player does not support function calls'
Ticket Links:
http://bugs.adobe.com/jira/browse/FB-13900
Modified Paths:
flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/BinaryOp.java
flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/PlayerSession.javaRevision: 3045
Author: [email protected]
Date: 2008-08-29 10:59:25 -0700 (Fri, 29 Aug 2008)
Log Message:
Fix FB-13900: Expression Evaluator: 'is' and 'as' expressions return 'Target player does not support function calls'
Ticket Links:
http://bugs.adobe.com/jira/browse/FB-13900
Modified Paths:
flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/BinaryOp.java
flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/PlayerSession.java -
How to call a C function calling a Java Method from another C function ?
Hi everyone,
I'm just starting to learn JNI and my problem is that I don't know if it is possible to call a C function calling a Java Method (or doing anything else with JNI) from another C function.
In fact, after receiving datas in a socket made by a C function, I would like to create a class instance (and I don't know how to do it too ; ) ) and init this instance with the strings I received in the socket.
Is all that possible ?
Thank you very much for your help !Hard to understand the question, but by most interpretations the answer is going to be yes.
You do of course understand that JNI is the "API" that sits between Java and C and that every call between the two must go through that. You can't call it directly. -
Is it possible to get the caller object in a function call hierarchy ?
Hi,
I have a problem in hand for adding a new functionality to an existing code with MINIMAL code change. For this I need to get some extra information in a function call from its caller. And for this I do not want to change the signature of the method, as it requires a lot of code change. So I need to have a programming facility by which I can get the object from which the function was invoked. Some thing like "{code}this.CALLEROBJECT{code}".
Please let me know whether we can achieve this in JAVA. I wonder if such a facility exists in any programming language...
Thanks in advance.
Regards
JobyNo.
Youd have to buy it Germany or see if an Apple Authrorized reseller in Singapore could order you the keyboard. -
I am experiencing this error with one of our cluster environment. Can anyone help me in this issue.
The Cluster Service function call 'ClusterResourceControl' failed with error code '1008(An attempt was made to reference a token that does not exist.)' while verifying the file path. Verify that your failover cluster is configured properly.
Thanks,
Venu S.
Venugopal S ----------------------------------------------------------- Please click the Mark as Answer button if a post solves your problem!Hi Venu S,
Based on my research, you might encounter a known issue, please try the hotfix in this KB:
http://support.microsoft.com/kb/928385
Meanwhile since there is less information about this issue, before further investigation, please provide us the following information:
The version of Windows Server you are using
The result of SELECT @@VERSION
The scenario when you get this error
If anything is unclear, please let me know.
Regards,
Tom Li -
Is there a way to avoid the function call ?
Given the following test case
CREATE USER TESTER
IDENTIFIED BY "tester"
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
GRANT CONNECT, RESOURCE TO TESTER
GRANT CREATE TYPE TO TESTER
GRANT CREATE SESSION TO TESTER
GRANT CREATE PROCEDURE TO TESTER
GRANT CREATE TABLE TO TESTER
GRANT UNLIMITED TABLESPACE TO TESTER
ALTER USER TESTER QUOTA UNLIMITED ON USERS
COMMIT
CONNECT TESTER/tester
CREATE OR REPLACE TYPE TESTER.PATTERN_LIST AS TABLE OF VARCHAR2(1023 CHAR)
SHOW ERRORS
CREATE TABLE TESTER.PARENT_TABLE
FIELD_ID NUMBER(10) NOT NULL,
FIELD_NAME VARCHAR2( 255 CHAR) NOT NULL,
FIELD_PATH VARCHAR2(1023 CHAR) NOT NULL,
FIELD_VALUE VARCHAR2( 255 CHAR)
CREATE TABLE TESTER.CHILD_TABLE
FIELD_PATH VARCHAR2(1023 CHAR) NOT NULL,
MIN_STR_LEN NUMBER(10),
MAX_STR_LEN NUMBER(10),
PATTERNS TESTER.PATTERN_LIST
NESTED TABLE PATTERNS STORE AS PATTERN_TABLE RETURN AS VALUE
ALTER TABLE TESTER.PARENT_TABLE ADD (
CONSTRAINT PARENT_TABLE_PK
PRIMARY KEY
(FIELD_ID))
INSERT ALL
INTO TESTER.PARENT_TABLE
VALUES (1, 'FIELD_A', '/A', NULL)
INTO TESTER.PARENT_TABLE
VALUES (2, 'FIELD_AB', '/A/B', '20090731')
INTO TESTER.PARENT_TABLE
VALUES (3, 'FIELD_AC', '/A/C', '2167')
INTO TESTER.PARENT_TABLE
VALUES (4, 'FIELD_AC', '/A/C', '1144')
INTO TESTER.PARENT_TABLE
VALUES (5, 'FIELD_AD', '/A/D', 'XS10')
INTO TESTER.PARENT_TABLE
VALUES (6, 'FIELD_AB', '/A/B', '20090229')
INTO TESTER.PARENT_TABLE
VALUES (7, 'FIELD_AD', '/A/D', 'ART')
INTO TESTER.PARENT_TABLE
VALUES (8, 'FIELD_AD', '/A/D', 'TESTED')
INTO TESTER.CHILD_TABLE
VALUES ('/A', NULL, NULL, PATTERN_LIST())
INTO TESTER.CHILD_TABLE
VALUES ('/A/B', NULL, NULL, PATTERN_LIST( '[12][0-9]{3}[0][13578]([0][1-9]|[12][0-9]|[3][01])'
, '[12][0-9]{3}[0][469]([0][1-9]|[12][0-9]|[3][0])'
, '[12][0-9]{3}[1][02][3][1]'
, '[12][0-9]{3}[1][1][3][0]'
, '[12][0-9]{3}[0][2][2][8]'
, '([2][048]|[1][26])([02468][048]|[13579][26])[0][2][2][9]'))
INTO TESTER.CHILD_TABLE
VALUES ('/A/C', NULL, NULL, PATTERN_LIST( '[0-1][0-9][0-5][0-9]'
, '[2][0-3][0-5][0-9]'))
INTO TESTER.CHILD_TABLE
VALUES ('/A/D', 3, 4, PATTERN_LIST('[^0-9]*'))
SELECT * FROM DUAL
CREATE OR REPLACE FUNCTION TESTER.MATCH_PATTERN(p_value IN VARCHAR2, p_patterns IN TESTER.PATTERN_LIST) RETURN NUMBER
AS
v_count NUMBER := 0;
BEGIN
SELECT COUNT(*)
INTO v_count
FROM TABLE(p_patterns)
WHERE REGEXP_SUBSTR(p_value, COLUMN_VALUE) = p_value;
RETURN v_count;
END MATCH_PATTERN;
SHOW ERRORS
COMMIT
/the query
SELECT FIELD_ID
, FIELD_PATH
, ERRINDEX
, FIELD_VALUE
FROM (
SELECT a.FIELD_ID
, a.FIELD_PATH
, b.PATTERNS
, CASE
WHEN ((b.MIN_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) < b.MIN_STR_LEN))) THEN 1
END AS ERRINDEX_1
, CASE
WHEN ((b.MAX_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) > b.MAX_STR_LEN))) THEN 2
END AS ERRINDEX_2
, CASE
WHEN ((b.PATTERNS IS NOT EMPTY) AND ((SELECT COUNT(*) FROM TABLE(b.PATTERNS) WHERE REGEXP_SUBSTR(a.FIELD_VALUE, COLUMN_VALUE) = a.FIELD_VALUE) = 0)) THEN 4
END AS ERRINDEX_4
, a.FIELD_VALUE
FROM TESTER.PARENT_TABLE a
INNER JOIN TESTER.CHILD_TABLE b ON a.FIELD_PATH = b.FIELD_PATH
UNPIVOT
ERRINDEX
FOR COL IN (ERRINDEX_1, ERRINDEX_2, ERRINDEX_4)
)gives me ORA-03113: end-of-file on communication channel
If on the other hand, I replace the nested single-row SELECT with the function call like this
SELECT FIELD_ID
, FIELD_PATH
, ERRINDEX
, FIELD_VALUE
FROM (
SELECT a.FIELD_ID
, a.FIELD_PATH
, b.PATTERNS
, CASE
WHEN ((b.MIN_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) < b.MIN_STR_LEN))) THEN 1
END AS ERRINDEX_1
, CASE
WHEN ((b.MAX_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) > b.MAX_STR_LEN))) THEN 2
END AS ERRINDEX_2
, CASE
WHEN ((b.PATTERNS IS NOT EMPTY) AND (TESTER.MATCH_PATTERN(a.FIELD_VALUE, b.PATTERNS) = 0)) THEN 4
END AS ERRINDEX_4
, a.FIELD_VALUE
FROM TESTER.PARENT_TABLE a
INNER JOIN TESTER.CHILD_TABLE b ON a.FIELD_PATH = b.FIELD_PATH
UNPIVOT
ERRINDEX
FOR COL IN (ERRINDEX_1, ERRINDEX_2, ERRINDEX_4)
)the query gives the correct results which should be
FIELD_ID FIELD_PATH ERRINDEX FIELD_VALUE
6 /A/B 4 20090229
3 /A/C 4 2167
5 /A/D 4 XS10
8 /A/D 2 TESTEDIs there a way to do this without the PL/SQL function call and at the same time avoid the ORA-03113 ? Or, have I hit a bug on 11.1.0.7 ?
Many thanks in advance
Best Regards
PhilipI found the Oracle Bug on my own in the end, in the most unlikely of places !
The following code
SELECT FIELD_ID
, FIELD_PATH
, ERRINDEX
, FIELD_VALUE
FROM (
SELECT a.FIELD_ID
, a.FIELD_PATH
, CASE
WHEN ((b.MIN_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) < b.MIN_STR_LEN))) THEN 1
END AS ERRINDEX_1
, CASE
WHEN ((b.MAX_STR_LEN IS NOT NULL) AND ((a.FIELD_VALUE IS NULL) OR (LENGTH(a.FIELD_VALUE) > b.MAX_STR_LEN))) THEN 2
END AS ERRINDEX_2
, CASE
WHEN ((b.PATTERNS IS NOT EMPTY) AND ((SELECT COUNT(*) FROM TABLE(b.PATTERNS) WHERE REGEXP_SUBSTR(a.FIELD_VALUE, COLUMN_VALUE) = a.FIELD_VALUE) = 0)) THEN 4
END AS ERRINDEX_4
, a.FIELD_VALUE
FROM TESTER.PARENT_TABLE a, TESTER.CHILD_TABLE b
WHERE a.FIELD_PATH = b.FIELD_PATH
UNPIVOT
ERRINDEX
FOR COL IN (ERRINDEX_1, ERRINDEX_2, ERRINDEX_4)
)works as intended i.e. like a charm !
The only difference between the one that gives the ORA-03113 and the above is the way the join is written. The ANSI way (INNER JOIN) fails, the old way (WHERE clause) succeeds.
I will open a SR with Oracle so that it may be recorded and fixed.
Best Regards
Philip -
Is it possible to pass table name as parameter to function calls?
Let's say I would like to retrieve data from table BSAD, BSID, BSIS, BSAS with the exact same WHERE conditions.
I.E.
SELECT SINGLE * FROM bsis
WHERE bukrs = zbukrs
AND belnr = zbelnr
AND gjahr = zgjahr
AND buzei = bseg-buzei.
SELECT SINGLE * FROM bsas
WHERE bukrs = zbukrs
AND belnr = zbelnr
AND gjahr = zgjahr
AND buzei = bseg-buzei.
Is there a way that I could put them into a function and do something like?
perform select_table_bsas using 'bsas'.
perform select_table_bsis using 'bsis'.
and I should get SELECT * FROM passed from the function calls.
Thanks.Hello,
You can try something like this
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.
FIELD-SYMBOLS: <ITAB> TYPE ANY TABLE. " used to store dynamic tables
LV_DBTAB1 = 'MARA'. " in caps
CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN DREF->* TO <ITAB> .
* chooses only english values
SELECT * FROM (LV_DBTAB1) INTO TABLE <ITAB> WHERE SPRAS = 'E'.
here, even the internal table is dynamic, but that can be static if you know the structure for sure -
I do not have a problem getting in the iTunes stores. My issue is once on the site I can not use the "search". It says there is a pure virtual function call R6025. How can I solve this problem? Do I have to create a new account? Do I have to uninstall and re-install? Thanks
Thanks so much for your feedback. I really appreciate any input here.
If someone from Adobe could GUARANTEE that this problem would go away if I
purchased CS4, I would pony up the cash and do it. However, I'm skeptical
about that because I just saw someone else post a message on the forum today
who is running CS4 and getting the exact same runtime error as me.
I'll try un-installing and re-installing as Admin, and if that doesn't work,
maybe I can find a used copy of CS3.
In the meantime, I'm also wondering if a Photoshop file can carry any sort
of corrupt metadata inside it once it has errored out? Reason I ask is, I
had to port all of my old PSD files to the new computer, and I only seem to
be getting this error when I attempt to work on one of the files that
previously got the runtime error when they were sitting on my XP machine.
When I create new files from scratch on this new computer, they seem to be
working just fine (at least, for now).
If so, I would probably be smart to never open those troublesome
"errored-out" files again. -
Error while activating expression Functional call
Hi All,
I created a functional call expression..I mainteined target function name and result object as well..The syntax check doesn't return any error messages.But when I try to activate it , I get an error message
ZCALL_FUNCTION_1 (Expression) : No active version found for time stamp 20.111.018.120.507 (Details) Display Longtext.
I activated all the subobjects..But I still I get the above mentioned error.. Could anyone please suggest me the solution..
Regards,
Raghu.Hi ,
Please implement note 1639477.
Thanks and Regards,
Rama. -
Java.lang.VerifyError - Incompatible object argument for function call
Hi all,
I'm developing a JSP application (powered by Tomcat 4.0.1 in JDK 1.3, in Eclipse 3.3). Among other stuff I have 3 classes interacting with an Oracle database, covering 3 use cases - renaming, adding and deleting an database object. The renaming class simply updates the database with a String variable it receives from the request object, whereas the other two classes perform some calculations with the request data and update the database accordingly.
When the adding or deleting classes are executed, by performing the appropriate actions through the web application, Tomcat throws the following:
java.lang.VerifyError: (class: action/GliederungNewAction, method: insertNewNode signature: (Loracle/jdbc/driver/OracleConnection;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V) Incompatible object argument for function call
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at action.ActionMapping.perform(ActionMapping.java:53)
at ControllerServlet.doResponse(ControllerServlet.java:92)
at ControllerServlet.doPost(ControllerServlet.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
...The renaming works fine though. I have checked mailing lists and forums as well as contacted the company's java support but everything I have tried out so far, from exchanging the xerces.jar files found in JDOM and Tomcat to rebuidling the project didn't help.
I just can't explain to myself why this error occurs and I don't see how some additional Java code in the other 2 classes could cause it?
I realize that the Tomcat and JDK versions I'm using are totally out of date, but that's company's current standard and I can't really change that.
Here's the source code. I moved parts of the business logic from Java to Oracle recently but I left the SQL statements that the Oracle stored procedures are executing if it helps someone.
package action;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import oracle.jdbc.driver.OracleConnection;
* This class enables the creation and insertion of a new catalogue node. A new node
* is always inserted as the last child of the selected parent node.
public class GliederungNewAction implements Action {
public String perform(ActionMapping mapping, HttpServletRequest request,
HttpServletResponse response) {
// fetch the necessary parameters from the JSP site
// the parent attribute is the selected attribute!
String parent_attribute = request.getParameter("attr");
String catalogue = request.getParameter("catalogue");
int parent_sequenceNr = Integer.parseInt(request.getParameter("sort_sequence"));
// connect to database
HttpSession session = request.getSession();
db.SessionConnection sessConn = (db.SessionConnection) session.getAttribute("connection");
if (sessConn != null) {
try {
sessConn.setAutoCommit(false);
OracleConnection connection = (OracleConnection)sessConn.getConnection();
int lastPosition = getLastNodePosition( getLastChildAttribute(connection, catalogue, parent_attribute) );
String newNodeAttribute = createNewNodeAttribute(parent_attribute, lastPosition);
// calculate the sequence number
int precedingSequenceNumber = getPrecedingSequenceNumber(connection, catalogue, parent_attribute);
if ( precedingSequenceNumber == -1 ) {
precedingSequenceNumber = parent_sequenceNr;
int sortSequence = precedingSequenceNumber + 1;
setSequenceNumbers(connection, catalogue, sortSequence);
// insert the new node into DB
insertNewNode(connection, catalogue, newNodeAttribute, parent_attribute, "Neuer Punkt", sortSequence);
connection.commit();
} catch(SQLException ex) {
ex.printStackTrace();
return mapping.getForward();
* Creates, fills and executes a prepared statement to insert a new entry into the specified table, representing
* a new node in the catalogue.
private void insertNewNode(OracleConnection connection, String catalogue, String attribute, String parent_attribute, String description, int sortSequence) {
try {
String callAddNode = "{ call fasi_lob.pack_gliederung.addNode(:1, :2, :3, :4, :5) }";
CallableStatement cst;
cst = connection.prepareCall(callAddNode);
cst.setString(1, catalogue);
cst.setString(2, attribute);
cst.setString(3, parent_attribute);
cst.setString(4, description);
cst.setInt(5, sortSequence);
cst.execute();
cst.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
// String insertNewNode = "INSERT INTO vstd_media_cat_attributes " +
// "(catalogue, attribute, parent_attr, description, sort_sequence) VALUES(:1, :2, :3, :4, :5)";
// PreparedStatement insertStmt;
// try {
// insertStmt = connection.prepareStatement(insertNewNode);
// insertStmt.setString(1, catalogue);
// insertStmt.setString(2, attribute);
// insertStmt.setString(3, parent_attribute);
// insertStmt.setString(4, description);
// insertStmt.setInt(5, sortSequence);
// insertStmt.execute();
// insertStmt.close();
// } catch (SQLException e) {
// e.printStackTrace();
* This method returns the attribute value of the last child of the parent under which
* we want to insert a new node. The result set is sorted in descending order and only the
* first result (that is, the last child under this parent) is fetched.
* If the parent node has no children, "parent_attr.0" is returned.
* @param connection
* @param catalogue
* @param parent_attribute
* @return attribute of the last child under this parent, or "parent_attr.0" if parent has no children
private String getLastChildAttribute(OracleConnection connection, String catalogue, String parent_attribute) {
String queryLastChild = "SELECT attribute FROM vstd_media_cat_attributes " +
"WHERE catalogue=:1 AND parent_attr=:2 ORDER BY sort_sequence DESC";
String lastChildAttribute;
PreparedStatement ps;
try {
ps = connection.prepareStatement(queryLastChild);
ps.setString(1, catalogue);
ps.setString(2, parent_attribute);
ResultSet rs = ps.executeQuery();
/* If a result is returned, the selected parent already has children.
* If not set the lastChildAttribute to parent_attr.0
if (rs.next()) {
lastChildAttribute = rs.getString("attribute");
} else {
lastChildAttribute = parent_attribute.concat(".0");
rs.close();
return lastChildAttribute;
} catch (SQLException e) {
e.printStackTrace();
return null;
* This helper method determines the position of the last node in the attribute.
* i.e for 3.5.2 it returns 2, for 2.1 it returns 1 etc.
* @param attribute
* @return position of last node in this attribute
private int getLastNodePosition(String attribute) {
StringTokenizer tokenizer = new StringTokenizer(attribute, ".");
String lastNodePosition = "0";
while( tokenizer.hasMoreTokens() ) {
lastNodePosition = tokenizer.nextToken();
return Integer.parseInt(lastNodePosition);
* This method calculates the attribute of a node being inserted
* by incrementing the last child position by 1 and attaching the
* incremented position to the parent.
* @param parent_attr
* @param lastPosition
* @return attribute of the new node
private String createNewNodeAttribute(String parent_attr, int lastPosition) {
String newPosition = new Integer(lastPosition + 1).toString();
return parent_attr.concat("." + newPosition);
* This method checks if the required sequence number for a new node is already in use and
* handles the sequence numbers accordingly.
* If the sequence number for a new node is NOT IN USE, the method doesn't do anything.
* If the sequence number for a new node is IN USE, the method searches for the next free
* sequence number by incrementing the number by one and repeating the query until no result
* is found. Then all the sequence numbers between the required number (including, >= relation)
* and the nearest found free number (not including, < relation) are incremented by 1, as to
* make space for the new node.
* @param connection
* @param catalogue
* @param newNodeSequenceNumber required sequence number for the new node
private void setSequenceNumbers(OracleConnection connection, String catalogue, int newNodeSequenceNumber) {
// 1. check if the new sequence number exists - if no do nothing
// if yes - increment by one and see if exists
// repeat until free sequence number exists
// when found increment all sequence numbers freeSeqNr > seqNr >= newSeqNr
String query = "SELECT sort_sequence FROM vstd_media_cat_attributes " +
"WHERE catalogue=:1 AND sort_sequence=:2";
PreparedStatement ps;
try {
ps = connection.prepareStatement(query);
ps.setString(1, catalogue);
ps.setInt(2, newNodeSequenceNumber);
ResultSet rs = ps.executeQuery();
// if no result, the required sequence number is free - nothing to do
if( rs.next() ) {
int freeSequenceNumber = newNodeSequenceNumber;
do {
ps.setString(1, catalogue);
ps.setInt(2, freeSequenceNumber++);
rs = ps.executeQuery();
} while( rs.next() );
// increment sequence numbers - call stored procedure
String callUpdateSeqeunceNrs = "{ call fasi_lob.pack_gliederung.updateSeqNumbers(:1, :2, :3) }";
CallableStatement cst = connection.prepareCall(callUpdateSeqeunceNrs);
cst.setString(1, catalogue);
cst.setInt(2, newNodeSequenceNumber);
cst.setInt(3, freeSequenceNumber);
cst.execute();
cst.close();
// String query2 = "UPDATE vstd_media_cat_attributes " +
// "SET sort_sequence = (sort_sequence + 1 ) " +
// "WHERE catalogue=:1 sort_sequnce >=:2 AND sort_sequence <:3";
// PreparedStatement ps2;
// ps2 = connection.prepareStatement(query2);
// ps2.setString(1, catalogue);
// ps2.setInt(2, newNodeSequenceNumber);
// ps2.setInt(3, freeSequenceNumber);
// ps.executeUpdate();
// ps.close();
} // end of if block
rs.close();
} catch (SQLException e) {
e.printStackTrace();
* This method finds the last sequence number preceding the sequence number of a node
* that is going to be inserted. The preceding sequence number is required to calculate
* the sequence number of the new node.
* We perform a hierarchical query starting from the parent node: if a result is returned,
* we assign the parent's farthest descendant's node sequence number; if no result
* is returned, we assign the parent's sequence number.
* @param connection
* @param catalogue
* @param parent_attr parent attribute of the new node
* @return
private int getPrecedingSequenceNumber(OracleConnection connection, String catalogue, String parent_attr) {
int sequenceNumber = 0;
String query = "SELECT sort_sequence FROM vstd_media_cat_attributes " +
"WHERE catalogue=:1 " +
"CONNECT BY PRIOR attribute = parent_attr START WITH parent_attr=:2 " +
"ORDER BY sort_sequence DESC";
try {
PreparedStatement ps = connection.prepareStatement(query);
ps.setString(1, catalogue);
ps.setString(2, parent_attr);
ResultSet rs = ps.executeQuery();
if ( rs.next() ) {
sequenceNumber = rs.getInt("sort_sequence");
} else {
// TODO: ggf fetch from request!
sequenceNumber = -1;
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
return sequenceNumber;
}After further googling I figured out what was causing the problem: in eclipse I was referring to external libraries located in eclipse/plugins directory, whereas Tomcat was referring to the same libraries (possibly older versions) in it's common/lib directory.
-
when i open my i3tunes on my computer i get an error message telling me that iTunes has stopped working..the message is as follows...Microsoft Visual C runtime library Program C:\program files (86) iTunes\iTunes.exe R6025 -Pure virtual function call.. How do i fix this
For general advice see Troubleshooting issues with iTunes for Windows updates.
The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
tt2 -
iTunes crashes when doing a power search. I get a Microsoft Visual C Runtime Library Error message: Program C:\Program Files (x86)\iTunes\iTunes.exe R6025. Pure virtual functional call. If I select ok, Windows 7 pops up with iTunes has stopped working and then it shuts iTunes down. Anyone else every have this issue. Any ideas on a fix?
Thanks,For general advice see Troubleshooting issues with iTunes for Windows updates.
The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
tt2 -
Java function call from Trigger in Oracle
Moderator edit:
This post was branched from an eleven-year-old long dead thread
Java function call from Trigger in Oracle
@ user 861498,
For the future, if a forum discussion is more than (let's say) a month old, NEVER resurrect it to append your new issue. Always start a new thread. Feel free to include a link to that old discussion if you think it might be relevant.
Also, ALWAYS use code tags as is described in the forum FAQ that is linked at the upper corner of e\very page. Your formulae will be so very much more readable.
{end of edit, what follows is their posting}
I am attempting to do a similar function, however everything is loaded, written, compiled and resolved correct, however, nothing is happening. No errors or anything. Would I have a permission issue or something?
My code is the following, (the last four lines of java code is meant to do activate a particular badge which will later be dynamic)
Trigger:
CREATE OR REPLACE PROCEDURE java_contact_t4 (member_id_in NUMBER)
IS LANGUAGE JAVA
NAME 'ThrowAnError.contactTrigger(java.lang.Integer)';
Java:
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ThrowAnError" AS
// Required class libraries.
import java.sql.*;
import oracle.jdbc.driver.*;
import com.ekahau.common.sdk.*;
import com.ekahau.engine.sdk.*;
// Define class.
public class ThrowAnError {
// Connect and verify new insert would be a duplicate.
public static void contactTrigger(Integer memberID) throws Exception {
String badgeId;
// Create a Java 5 and Oracle 11g connection.
Connection conn = DriverManager.getConnection("jdbc:default:connection:");
// Create a prepared statement that accepts binding a number.
PreparedStatement ps = conn.prepareStatement("SELECT \"Note\" " +
"FROM Users " +
"WHERE \"User\" = ? ");
// Bind the local variable to the statement placeholder.
ps.setInt(1, memberID);
// Execute query and check if there is a second value.
ResultSet rs = ps.executeQuery();
while (rs.next()) {
badgeId = rs.getString("Note");
// Clean up resources.
rs.close();
ps.close();
conn.close();
// davids badge is 105463705637
EConnection mEngineConnection = new econnection("10.25.10.5",8550);
mEngineConnection.setUserCredentials("choff", "badge00");
mEngineConnection.call("/epe/cfg/tagcommandadd?tagid=105463705637&cmd=mmt%203");
mEngineConnection.call("/epe/msg/tagsendmsg?tagid=105463705637&messagetype=instant&message=Hello%20World%20from%20Axium-Oracle");
Edited by: rukbat on May 31, 2011 1:12 PMTo followup on the posting:
Okay, being a oracle noob, I didn't know I needed to tell anything to get the java error messages out to the console
Having figured that out on my own, I minified my code to just run the one line of code:
// Required class libraries.
import java.sql.*;
import oracle.jdbc.driver.*;
import com.ekahau.common.sdk.*;
import com.ekahau.engine.sdk.*;
// Define class.
public class ThrowAnError {
public static void testEkahau(Integer memberID) throws Exception {
try {
EConnection mEngineConnection = new EConnection("10.25.10.5",8550);
} catch (Throwable e) {
System.out.println("got an error");
e.printStackTrace();
}So, after the following:
SQL> {as sysdba on another command prompt} exec dbms_java.grant_permission('AXIUM',"SYS:java.util.PropertyPermission','javax.security.auth.usersubjectCredsOnly','write');
and the following as the user
SQL> set serveroutput on
SQL> exec dbms_java.set_output(10000);
I run the procedure and receive the following message.
SQL> call java_contact_t4(801);
got an error
java.lang.NoClassDefFoundError
at ThrowAnError.testEkahau(ThrowAnError:13)
Call completed.
NoClassDefFoundError tells me that it can't find the jar file to run my call to EConnection.
Now, I've notice when I loaded the sdk jar file, it skipped some classes it contained:
c:\Users\me\Documents>loadjava -r -f -v -r "axium/-----@axaxiumtrain" ekahau-engine-sdk.jar
arguments: '-u' 'axium/***@axaxiumtrain' '-r' '-f' '-v' 'ekahau-engine-sdk.jar'
creating : resource META-INF/MANIFEST.MF
loading : resource META-INF/MANIFEST.MF
creating : class com/ekahau/common/sdk/EConnection
loading : class com/ekahau/common/sdk/EConnection
creating : class com/ekahau/common/sdk/EErrorCodes
loading : class com/ekahau/common/sdk/EErrorCodes
skipping : resource META-INF/MANIFEST.MF
resolving: class com/ekahau/common/sdk/EConnection
skipping : class com/ekahau/common/sdk/EErrorCodes
skipping : class com/ekahau/common/sdk/EException
skipping : class com/ekahau/common/sdk/EMsg$EMSGIterator
skipping : class com/ekahau/common/sdk/EMsg
skipping : class com/ekahau/common/sdk/EMsgEncoder
skipping : class com/ekahau/common/sdk/EMsgKeyValueParser
skipping : class com/ekahau/common/sdk/EMsgProperty
resolving: class com/ekahau/engine/sdk/impl/LocationImpl
skipping : class com/ekahau/engine/sdk/status/IStatusListener
skipping : class com/ekahau/engine/sdk/status/StatusChangeEntry
Classes Loaded: 114
Resources Loaded: 1
Sources Loaded: 0
Published Interfaces: 0
Classes generated: 0
Classes skipped: 0
Synonyms Created: 0
Errors: 0
.... with no explanation.
Can anyone tell me why it would skip resolving a class? Especially after I use the -r flag to have loadjava resolve it upon loading.
How do i get it to resolve the entire jar file?
Edited by: themadprogrammer on Aug 5, 2011 7:15 AM
Edited by: themadprogrammer on Aug 5, 2011 7:21 AM
Edited by: themadprogrammer on Aug 5, 2011 7:22 AM
Edited by: themadprogrammer on Aug 5, 2011 7:23 AM
Edited by: themadprogrammer on Aug 5, 2011 7:26 AM -
Function calls in WHERE clause
Hello,
I have several procedures that all share a similar snippet of code in the WHERE clause. I tried to make this a function but, using a function increases the execution time of the calling procedure by a factor of ten. I am currently on 8i and will be moving to 9i soon. Was just wondering if there will be any performance increase from this type of function call on 9i vs. 8i.
Thanks
:)sometimes a perforance hit it worth the maintability factor.I disagree, strongly. The developer's Prime Directive is to make the user's experience a good one. Inflicting poorly performing code on the user in the name of maintinability is not on.
Q: Why does the code have to be maintained so much?
A: Because the users' keep complaining about how slow it runs....
[SOAPBOX]
Of course in the real world things get confused and it can be quite difficult to distinguish programmers' issues - encapsulation, flexibility, maintainability - from users' issues - correctness, completeness, performance.
But the relative worth of these things is easy to assess. A highly-modular parameter driven architecture that delivers the wrong answer and takes an age to do it ain't worth jack. Even if it is so maintainable that it's easy to fix every bug in it.
[SOAPBOX]
"Whatever waits for us behind those doors, we have a better chance of survival if we stick together." Gladiator
Cheers, APC
Maybe you are looking for
-
hi, I'm using Oracle 11g. I'm storing text files in XML DB and accessing them using FTP, pl/sql and Java. Sometimes this files are huge, and all I need is to append a line. Is there any way to do this, without reading the full content of the file, us
-
only opens to auto fill
-
Payment Proposal List - DME generaion
Hi, I am implementing SAP E-Banking solution, my requirement as follows, One Payment proposal generated for following amounts, 1. Amount 10000 - one approval 2. Amount 15000 - One approval 3. Amount 50000 - Two Approvals 4. Amount 100,
-
Hello, This is relating to one of the previous posts. CASE STATEMENT PERFORMANCE As it has been a discussion of case statement performance. I tried to compare both the filter function and case statement. they both actually generate the same physical
-
Hi, what are the types of G\L Accounts? What is the T.code to create the g\l account at the chrt of accounts level? what is meant by Group account? Thanks.