Really weird.
I have an Oracle function
function highlightDesc(desc IN VARCHAR2, keyword IN VARCHAR2) return VARCHAR2
return 'paragraphtag' ||
REPLACE(desc, keyword, 'boldtag' || keyword || 'boldtag') || 'paragraphtag';
this gets called this way
select a.*, highlightDesc(a.Desc) as highlightedDesc
from tablea a
The weird thing is that when I call this sql from within sqlplus or plsql developer the highlightedDesc column contains all the right markup.
When I call it from Junit, I get all the right markup.
When I call it from a struts2 app running on jboss(winxp/redhat) with the oracle thin drivers,
I get the enclosing paragraphtag tags and the content but not the boldtag .
Does that make sense?
Any thoughts?
Edit:
I apologize, I cant log into SO from work. Lame I know.
I am using the commons dbutils queryrunner (BeanListHandler) to execute the sql from a java class.
My action is doing nothing but calling my service class and setting the value.
I looked at the src for queryrunner, it ends up calling a class called BeanProcessor which gets the highlightedDesc column as a String via rs.getString(index);
I thought it might be an encoding problem??? so I tried to change the jvm encoding and also the jboss encoding, but it had no effect.
I think I might see if converting the character set in oracle has any effect?
Thanks.
Most likely, the keyword isn't passed correctly to the function, so the REPLACE function does effectively nothing.
Related
in oracle form builder my form does not access trigger named WNFI i call it on when- new- form-instance like this
execute_trigger('WNFI') ;
it doesn't enter it at all
what is the problem ?
Which Forms version do you use?
I've just tried it on Forms 10g, and it works OK - trigger is called and does its job (in my test, displays a message).
Anyway, just in case you didn't understand what APC says: move code from the WNFI trigger into a procedure (not a stored procedure, in the database; create it under the Program units node in the Object Navigator). For example:
-- This is P_WNFI procedure; this code was previously in WNFI trigger
message('wnfi');
message('wnfi');
Modify WHEN-NEW-FORM-INSTANCE trigger:
-- instead of
-- execute_trigger('WNFI');
-- use
p_wnfi;
If you open Forms Online Help system and search for execute_trigger, you'll see a note:
EXECUTE_TRIGGER is not the preferred method for executing a user-named trigger. Writing a user-named subprogram is the preferred method.
If I were you, I'd do as told. execute_trigger might be here for backward compatibility for some time, but not forever. Who knows; maybe Oracle corp. does.
Below is part of my plsql code for webservice call, if am hardcoding lv_activity_token code is working fine,same is not working when am getting it from below expression
iv_offset_cnt:=0;
lv_activity_token:= substr(iv_activity_token,instr(iv_activity_token,'/',2)+1);--with this code is not working
--iv_activity_token is coming from oracle table which i stored in table from different web service response
-- lv_activity_token:='2562432'; hardcoding the same value which is coming from above expression,with this code is working
lv_ws_url:='https://secure.p03.eloqua.com:443/api/bulk/2.0/syncs/';
lv_ws_url1:='/data?limit=200&offset=';
gv_ws_url := lv_ws_url || lv_activity_token || lv_ws_url1 || iv_offset_cnt;
--at the end gv_ws_url value is:
--https://secure.p03.eloqua.com:443/api/bulk/2.0/syncs/2562432/data?limit=200&offset=0
additional detials:
gv_ws_url --passing this to get the response.
Please let me know if you need any other details.
(i was doubting with data which is storing in table(may be character set issue))
thanks in advance.
Trying to configure tigase to use hsqldb (hsqldb-1.8.0.9-1jpp.2) instead of derby (don't ask why, that's not the point) and everything works fine, except for setting some properties in the end. In Derby I had
CREATE procedure TigAddUserPlainPw(userId varchar(2049), userPw varchar(255))
PARAMETER STYLE JAVA
LANGUAGE JAVA
MODIFIES SQL DATA
DYNAMIC RESULT SETS 1
EXTERNAL NAME 'tigase.db.derby.StoredProcedures.tigAddUserPlainPw';
and
call TigAddUserPlainPw('db-properties', NULL);
When I try to replices this with hsqldb by
CREATE ALIAS TigAddUserPlainPw
FOR "tigase.db.derby.StoredProcedures.tigAddUserPlainPw";
and
CALL TigAddUserPlainPw('db-properties', NULL);
I get this error message
[root#tikanga scripts]# ./hsqldb-db-create.sh /var/lib/tigase/db/tigase
SQL Error at '/etc/tigase/database/hsqldb-schema-4-props.sql' line 1:
"CALL TigAddUserPlainPw('db-properties', NULL)"
Wrong data type: [Ljava.sql.ResultSet; in statement [CALL TigAddUserPlainPw(]
Any idea, what I am doing wrong?
You cannot use the Java static methods as they are. The Result[] parameters are not acceptable to HSQLDB 1.8.x.
It would be easier to convert to HSQLDB 2.0, as its stored procedure support has improved over version 1.8.
Your example shows we need to make some more improvements to HSQLDB to support these procedure declarations.
As far as I know, HSQLDB supports Java functions that return a ResultSet (Fred will correct me if I'm wrong): http://hsqldb.org/doc/2.0/guide/sqlroutines-chapt.html#N12835
You would need a new method:
public static ResultSet tigAddUserPlainPw(
String userId, String userPw) throws SQLException;
I have a java stored procedure that takes in a clob representing a chunk of javascript and mins it. The structure of the function calling the JSP is as follows:
function MIN_JS(pcl_js in clob) return clob as
language java name 'JSMin.min(oracle.sql.CLOB) return oracle.sql.CLOB';
In the actual JSP, I have the following:
import oracle.sql.CLOB;
public class JSMin {
...
public static min(CLOB js) {
...
}
The problem I'm having is that whenever I pass a clob to JS_MIN, it is always interpreted as null inside the JSP. I've checked the clob before calling JS_MIN annd it definitely has contents. Any ideas as to what I'm missing? Any help is greatly appreciated.
As it turns out, one of the javascript chunks I was sending was in fact null. We have several packages that generate javascript for various controls and one is apparently still under development and wrapped in a way that it always returns null unless you are logged in as a particular user.
In my code, I loop across all the javascript packages, sending each to JS_MIN. Everything was working peachy until the package still in development came along and passed null. I added a simple check for null and everything works perfectly now.
So the short answer is: Doh!
Has anyone seen this error when trying to call an external C function from an Oracle query? I'm using Oracle 10g and get this error every time I try to call one of the two functions in the library. A call to the other function returns fine every time, though the function that works is all self-contained, no calls to any OCI* functions.
Here's the stored procedure that is used to call the failing C code:
CREATE OR REPLACE PROCEDURE index_procedure(text in clob, tokens in out nocopy clob, location_needed in boolean)
as language c
name "c_index_proc"
library lexer_lib
with context
parameters
(
context,
text,
tokens,
location_needed
);
Any help would be appreciated. Everything I've found on this error message says that the action to take is: Contact Oracle customer support.
Edit: I've narrowed it down to the point that I know that there is a segfault deep in libclntsh after I call OCILobTrim (to truncate it down to 0 length) on the tokens clob. Here is the code I've been using to call this procedure.
declare text CLOB; tokens CLOB;
begin
dbms_lob.createtemporary(tokens, TRUE);
dbms_lob.append(tokens, 'token');
dbms_lob.createtemporary(text, TRUE);
dbms_lob.append(text, '<BODY>Test Document</BODY>');
index_procedure(text, tokens, FALSE);
dbms_output.put_line(tokens);
end;
/
Is there something wrong with this setup that might be causing OCILobTrim problems?
It looks like this is one of those errors that essentially means any number of things could have gone wrong with the external procedure.
There is a known bug in 10.2.0.3, no idea if it's relevant:
ORA-28579 occurs when trying to select
data from a pipelined table function
implemented in "C" using the
ODCITable/ANYDATASET interface.
ODCITableDescribe works fine but
ODCITableFetch generates an ORA-28579
error.
I would suggest:
Look in the database server
trace directories, and the directory
where the external proc is located,
for any log or trace files generated
when the error occurs.
Instrument your external proc in
some way so that you can try to
trace its execution yourself.
Contact Oracle support
Well, an upgrade to 10.2.0.4 (was using 10.2.0.1) at least gave me an understandable error instead of a fairly useless core file and the ORA-28579.
It turns out that the code I was debugging was assuming that calling OCILobRead would return all of the data in one pass. This is the case for any client using a fixed width character set.
For clients using a variable width character set, this isn't the case, OCILobRead was actually reading part of the data and returning OCI_NEED_DATA and future calls to OCILobTrim and OCILobWrite were failing because of the still pending call to OCILobRead. The solution was to loop OCILobRead calls until OCI_NEED_DATA was no longer returned and we had all of the needed data in our buffer.
A call to OCIBreak also would have allowed the OCILobTrim and OCILobWrite functions to continue, though we wouldn't have had all of the needed input data.