Ireport Using Oracle Function - ireport

I have a oracle function(SOS_NUMBER_TO_WORD_JR_F).it has INTEGER parameter and return type is STRING. Now i want call this function from Ireport variable or text field. I did not kwnow how to do it? Any one help my problem?

Can you call it in your query?
SELECT SOS_NUMBER_TO_WORD_JR_F($P{the_integer_parameter}) AS RETURNS_A_WORD
FROM MY_TABLE
If that doesn't work, provide us with a little more information about how you normally call the function.

Related

String Aggregation that works in both oracle and postgresql

I was originally using LISTAGG to do the union of strings in oracle.
Searching for PostgreSQL I get: string_agg
I don't know if there is any way to have a function that works in both applications.
I have to do it from the query since I can't create functions
thanks for your help
Thank you all for the help, in the end I did it through functions and sub-query

function in where clause+ axapta2009

I am having Illegal use of WHERE expression for the following statement
select dateField from tableName
where dayname(dayofwk(tableName.dateField)) like 'sunday';
Pls help
Anthony is right, of course. However, there are still at leat 2 options to acheive the same result.
Create a new integer field in your table. This field should store the return value of the dayOfWk() function. Later you can easily query this table.
Second option - create a View inside AX and use a computed column feature toghether with the datePart() SQL Server function. Something like datepart(dw, tableName.DateField) should do it.
The first option will probably result in better performance.
You cannot use a function in a where clause, or in any select statement
you can't use any function on any field of the same table for which you are using the query

What is the DB2 equivalent of DUMP function in Oracle?

The dump function in Oracle displays the character set and bitwise representation of how data is stored.
Does anybody know if there is an equivalent command in DB2 please? Thank you.
Using the following query and the functions below up might be able to come up with a UDF to do what you need.
SELECT NAME, VALUE
FROM SYSIBMADM.DBCFG
where NAME in ('codepage','codeset','collate_info')
BITAND
BITOR
BITXOR
BITNOT
BITANDNOT

Getting the return value of a PL/SQL function via Hibernate

I have a PL/SQL function in an Oracle database that I can't change. This function takes a parameter which identifies an entity, creates a copy of that entity and then returns the ID of the copy. This looks something like
FUNCTION copy_entity(id IN NUMBER) RETURN NUMBER
I need to call this function from Hibernate. I tried creating a named SQL query with something similar to
CALL copy_entity(:id)
as the query, but from this I can't seem to get the return value of the function. Hibernate's "return-scalar" and similar options require a column name to return and I don't have a column name. This lead me to
SELECT copy_entity(:id) AS newEntityId
with "return-scalar" using newEntityId as column name, but this also did not work since Oracle then throws an exception that I can't call INSERT (to save the copy) in a SELECT.
Is there any way to get the return value of such a PL/SQL function? The function is actually much more complex and still required in other parts of the app, so re-writing it is not really an option.
I hope/think you can use an anonymous PL/SQL block:
begin
:myresult = copy_entity(:id);
end;
Now you have 'column name' myresult with the result.
I've never used hibernate so I hope it works. I don't know how flexible Hibernate is.
I think you are stuck using straight JDBC. The Hibernate documentation has this in the limitations section for Oracle:
For Oracle the following rules apply:
A function must return a result set.
The first parameter of a procedure
must be an OUT that returns a result
set. This is done by using a
SYS_REFCURSOR type in Oracle 9 or 10.
In Oracle you need to define a REF
CURSOR type. See Oracle literature for
further information.
Since this function accepts a number and returns a number you are out of luck with Hibernate and would probably be better off making a simple JDBC CallableStatement.

How do you convert SYS_GUID() to varchar?

In oracle 10g, how do you convert SYS_GUID() to varchar? I am trying something like:
select USER_GUID from user where email = 'user#example.com'
Which returns the RAW byte[]. Is it possible to use a function to convert the RAW to VARCHAR2 in the SQL statement?
Don't forget to use HEXTORAW(varchar2) when comparing this value to the RAW columns.
There is no implicit convesion from VARCHAR2 to RAW. That means that this clause:
WHERE raw_column = :varchar_value
will be impicitly converted into:
WHERE RAWTOHEX(raw_column) = :varchar_value
, thus making indices on raw_column unusable.
Use:
WHERE raw_column = HEXTORAW(:varchar_value)
instead.
Use RAWTOHEX(USER_GUID).
select RAWTOHEX(USER_GUID) from user where email = 'user#example.com'
Please don't mod-1 if I'm wrong. I'm going from memory so this a disclaimer to verify.
TO_CHAR is actually different between SQL and PL/SQL.
In SQL TO_CHAR does not take a raw as you have found out.
In PL/SQL To_CHAR will take a raw value.
So if you're in a procedure anyways, sometimes it easier to use a variable, but if you're just using SQL, go with the other answers here.
select CAST (USER_GUID AS VARCHAR2(100)) from user where email = 'user#example.com'

Resources