How to call oracle Function which has If else condition in Data Template
Hi,
currently I am working on creating Data Template which uses a Oracle Function which I need to make use in my data template. But I have some confusions on using the same. Could anybody please help me in this regard.
I have a function like this,
function invoice_query (p_facility_id facility.facility_id%TYPE,
p_wave_nbr pick_directive.wave_nbr%TYPE,
p_container_id unit_pick_group_detail.container_id%TYPE,
p_distro_nbr unit_pick_group_detail.distro_nbr%TYPE) return invoice_refcur IS
refcur invoice_refcur;
begin
IF p_wave_nbr IS NOT NULL THEN
OPEN refcur FOR SELECT t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
min(t2.pick_order),
NULL,
t2.wave_nbr
FROM stock_order t1,
pick_directive t2,
unit_pick_group_detail t3
WHERE t1.facility_id = t2.facility_id
AND t1.facility_id = t3.facility_id
AND t2.facility_id = t3.facility_id
AND t1.distro_nbr = t2.distro_nbr
AND t1.distro_nbr = t3.distro_nbr
AND t2.distro_nbr = t3.distro_nbr
AND t1.facility_id = p_facility_id
AND t2.wave_nbr = p_wave_nbr
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.pick_type = 'U'
AND t3.group_id in (SELECT t4.group_id
FROM unit_pick_group t4
WHERE t4.facility_id = p_facility_id
AND t4.wave_nbr = p_wave_nbr)
GROUP BY t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
t2.wave_nbr
ORDER BY MIN(t3.group_id), MAX(t3.slot);
elsif p_container_id is not null then
OPEN refcur FOR SELECT distinct t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
NULL,
t2.dest_id,
null
FROM stock_order t1,
unit_pick_group_detail t2
WHERE t1.facility_id = t2.facility_id
and t1.distro_nbr = t2.distro_nbr
and t1.facility_id = p_facility_id
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.container_id = p_container_id;
else
open refcur for SELECT distinct t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
NULL,
NULL,
t3.wave_nbr
FROM stock_order t1,
unit_pick_group_detail t2,
unit_pick_group t3
WHERE t1.facility_id = t2.facility_id
and t2.facility_id = t3.facility_id
and t1.distro_nbr = t2.distro_nbr
and t2.group_id = t3.group_id
and t1.facility_id = p_facility_id
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.distro_nbr = p_distro_nbr;
END IF;
return refcur;
end;
I have created data template like following,
<sqlStatement name="Q_INVOICE">
<![CDATA[
SELECT Pack_Slip_R.invoice_query(:P_FACILITY_ID,:P_WAVE_NBR,:P_CONTAINER_ID,:P_DISTRO_NBR) from dual
]]>
</sqlStatement>
But how does I create a element for the "t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip" column in the oracle function. I normally create an element like following,
<group name="G_INVOICE" source="Q_INVOICE">
<element name="CUST_ORDER_NBR" value="cust_order_nbr"/>
<element name=":dest_id" value="dest_id"/>
</Group>
But how do i create element if a column name is kind of dynamic. Please help. I cannot Rename/change the Column in SQL Query. Please let me know If I could handle this whole logic in BI Publsiher.
Regards,
Ashoka BL
try useing alias
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip as <COLUMN_ALIAS>
Similar Messages
-
How to call a function which has a cursor
hey folks I have a function which has a cursor,,like this
CREATE OR REPLACE FUNCTION EMPCU RETURN VARCHAR
AS
CURSOR EMPC IS
SELECT LNAME,SALARY,SSN
FROM EMPLOYEE
WHERE DNO IN(4,5);
EMPV EMPC%ROWTYPE;
BEGIN
OPEN EMPC;
LOOP
FETCH EMPC INTO EMPV;
EXIT WHEN EMPC%NOTFOUND;
/*DBMS_OUTPUT.PUT_LINE(EMPV.LNAME||' '||EMPV.SALARY||' '||EMPV.SSN);*/
RETURN EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN;
END LOOP;
CLOSE EMPC;
END EMPCU;
Above function created successfully. I called above function like this
DECLARE
ENAMESAL VARCHAR2(70);
BEGIN
ENAMESAL:=EMPCU();
DBMS_OUTPUT.PUT_LINE(ENAMESAL);
END;
Function is called and function is returning only one row instead of 7 rows. Actually cursor is supposed to return 7 rows but it is returning only one row. Is there any snytax to call a function which has a cursor. So experts please tell me where I have to make changes. I would be very thankful to youWell, you've told the function to RETURN within the loop, so after the first record in the loop, the function returns as you've instructed it.
You would need to change your function to accept a specific input from the EMP table and then do a look up for that specific record and return the values you wanted, and wrap the function call in a loop in your anonymous block.
Or you could just have the anonymous block like this....
BEGIN
FOR X IN
SELECT EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN AS Line_Data
FROM EMPLOYEE
WHERE DNO IN(4,5)
LOOP
DBMS_OUTPUT.PUT_LINE(x.Line_Data);
END LOOP;
END;
/ -
How to call oracle function from ejb3
i'm trying to call an oracle query-function from ejb3.
The oracle function:
create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
m_sql VARCHAR2(250);
BEGIN
m_sql:='select count(thrId) from thread where secId='|| secid||'
and thrAvai='|| avai;
open cur for m_sql;
return cur;
END;
I'v tried several ways to call it,but all failed:
1. the calling code:
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");
query.setParameter(1, secId);
query.setParameter(2, avai);
return query.getSingleResult();
but i got the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
ORA-06550: row 1, col 7:
PL/SQL: Statement ignored
2. the calling code:
@SqlResultSetMapping(name = "getSecThreadCount_Mapping")
@NamedNativeQuery(name = "getSecThreadCount",
query = "{?=call getSecThreadCount(:secId,:avai)}",
resultSetMapping = "getSecThreadCount_Mapping",
hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
@QueryHint(name = "org.hibernate.readOnly", value = "true")})
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNamedQuery("getSecThreadCount");
query.setParameter("secId", secId);
query.setParameter("avai", avai);
return query.getSingleResult();
but i run into the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
Could anyone tell me how to call the function from EJB3?
Thanks.Here's a working model:
package.procedure: (created in example schema scott)
CREATE OR REPLACE package body data_pkg as
type c_refcursor is ref cursor;
-- function that return all emps of a certain dept
function getEmployees ( p_deptId in number
return c_refcursor
is
l_refcursor c_refcursor;
begin
open l_refcursor
for
select e.empno as emp_id
, e.ename as emp_name
, e.job as emp_job
, e.hiredate as emp_hiredate
from emp e
where e.DEPTNO = p_deptId;
return l_refcursor;
end getEmployees;
end data_pkg;
/entity class:
package net.app.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.QueryHint;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@SuppressWarnings("serial")
@Entity
@Table (name="emp")
@SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
@NamedNativeQuery( name = "getEmpsByDeptId"
, query = "{ ? = call data_pkg.getEmployees(?)}"
, resultClass = Employee.class
, hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
, @QueryHint(name = "org.hibernate.readOnly", value = "true")
public class Employee implements Serializable
@Id
@Column(name="emp_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
private int id;
@Column(name="emp_name")
private String name;
@Column(name="emp_job")
private String job;
@Column(name="emp_hiredate")
private Date hiredate;
// constructor
public Employee (){}
// getters and setters
public int getId()
return id;
etc...session bean:
package net.app.entity;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
@Stateless
public class ScottAdminImpl implements ScottAdmin
@PersistenceContext
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public List<Employee> getEmployeesByDeptId(int deptId)
ArrayList<Employee> empList;
try
Query query = entityManager.createNamedQuery("getEmpsByDeptId");
query.setParameter(1, deptId);
empList = (ArrayList<Employee>) query.getResultList();
return empList;
catch (Exception e)
e.printStackTrace(System.out);
return null;
}client:
package net.app.client;
import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
public class ScottClient
public static void main(String[] args)
try
// create local interface
InitialContext ctx = new InitialContext();
ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
// select employees by deptno
int deptno = 20;
List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
// output
System.out.println("Listing employees:");
for (Employee emp : empList)
System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
catch (NamingException e)
e.printStackTrace(System.out);
}Basically you just ignore the refcursor outbound parameter.
This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
Edited by: _Locutus on Apr 2, 2009 2:37 PM -
(How) Can a SP call the Function which has BULK COLLECT return?
I have a function using BULL COLLECT to put (XML data) many line into a table type record. (I had this as a function because it's gong to call many times).
From one SP program, I will need to call it to get converted XML data info, how should i call it? If it's single line return, I could use
my_result := get_tbl_xml(p_xml);
but when it's table type, even I defined it, it still get error. Here is the program:
Declare (at package spec)
TYPE OrderDtl_Tab IS TABLE OF xxx%ROWTYPE INDEX BY BINARY_INTEGER;
in_OrderDtlTab OrderDtl_Tab;
FUNCTION get_tbl_xml (p_xml IN CLOB ) RETURN OrderDtl_Tab IS
BEGIN
SELECT extractvalue(VALUE(x), '/xxxx/xxxx') AS xxxx BULK COLLECT
INTO in_OrderDtlTab
FROM TABLE(xmlsequence(extract(xmltype(p_xml), '/Order/Lines/*'))) x;
RETURN in_OrderDtlTab;
END;
PROCEDURE SAVE_A (p_xml IN CLOB )
BEGIN
--- how to call get_tbl_xml to get result, so I will be able to insert into DB table
in_OrderDtlTab := get_tbl_xml(p_xml);
END;
--------------------------------------------------------------------------------------------------------------------May be this is better
FUNCTION get_tbl_xml (p_xml IN CLOB ) RETURN OrderDtl_Tab IS
BEGIN
SELECT extractvalue(VALUE(x), '/xxxx/xxxx') AS xxxx BULK COLLECT
INTO in_OrderDtlTab
FROM TABLE(xmlsequence(extract(xmltype(p_xml), '/Order/Lines/*'))) x;
RETURN in_OrderDtlTab;
END;
PROCEDURE SAVE_A (p_xml IN CLOB )
yourrow your_table%rowtype;
BEGIN
--- how to call get_tbl_xml to get result, so I will be able to insert into DB table
in_OrderDtlTab := get_tbl_xml(p_xml);
FORALL myrowtype
IN in_OrderDtlTab .FIRST .. in_OrderDtlTab .LAST
INSERT INTO Your_table
VALUES in_OrderDtlTab(yourrow);
END;
END; -
Calling a function which has a CLOB parameter via an anonymous block.
OK,
we are moving a lot of exports currently done by Crystal to just be done by stored procs.
So we have a load of existing, some extremely length SQL statements used for these exports.
IN the exports, we have meaningful column headings, so we have a 'lookup' file where all the column names are listed with the desired column name text listed against it.
So - to make our lives easier(i thought) , I have written a Oracle function to extract al;l of the column names as a list (see below).
It works fine except for when I am trying to pass in a SQL treatment that is longer than 4000 character.
What I want to be able to do is simply have an anonymous block that callls my function, I will be running this via SQL explorer.
Something like......
DECLARE
theSQL CLOB;
BEGFIN
theSQL := 'SELECT * FROM ORDERS WHERE 1=0';
SELECT GET_COLUNS_AS_LIST( theSQL, 0 ) FROM DUAL;
END;
However, when I run this I get the error................
PLS-00428: an INTO clause is expected in this SELECT statement
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
If I hard code the SQL like this, SELECT GET_COLUNS_AS_LIST( 'SELECT * FROM ORDERS WHERE 1=0', 0 ) FROM DUAL; all is well.
Also, I am going to need to be able to pass in SQL ststement longer that 4000 characters as weel so please bear that in mind.
I am not an Oracle guy, so I guess I am missing something fundamental - Please enlighten me with regards to this.
Any help extremely appreciated.
CREATE OR REPLACE FUNCTION GET_COLUNS_AS_LIST( P_SQL IN VARCHAR2, Add_Equals_Sign Number := 0)
RETURN CLOB
IS
fResult VARCHAR2(32000);
HNDL NUMBER;
d NUMBER;
colCount INTEGER;
i INTEGER;
rec_tab DBMS_SQL.DESC_TAB;
cCRLF VARCHAR(2) := CHR(13) || CHR(10);
LONG_SQL dbms_sql.varchar2s;
n INTEGER;
l INTEGER;
u INTEGER;
StartPos INTEGER;
BEGIN
--INITIIALISE RESULT
fResult := '';
HNDL := DBMS_SQL.OPEN_CURSOR;
l := Length( P_SQL );
u := ( l / 1000 ) + 1;
FOR n IN 1..u
LOOP
StartPos := ( n - 1 ) + 1;
LONG_SQL( n ) := SubStr( P_SQL, StartPos, 1000 );
END LOOP;
if HNDL <> 0 THEN
DBMS_SQL.PARSE ( c => HNDL,
statement => LONG_SQL,
lb => 1,
ub => u,
lfflg => false,
language_flag => DBMS_SQL.NATIVE );
--DBMS_SQL.PARSE( HNDL, P_SQL, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE( HNDL );
DBMS_SQL.DESCRIBE_COLUMNS( HNDL, colCount, rec_tab);
FOR i in 1..colCount
LOOP
IF Add_Equals_Sign > 0 AND i > 1 THEN
fResult := ltrim( fResult || '=' || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
ELSE
fResult := ltrim( fResult || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
END IF;
END LOOP;
IF Add_Equals_Sign > 0 THEN
fResult := fResult ||'=';
END IF;
ELSE
fResult := '!!COULD NOT OPEN CURSOR!!';
fResult := P_SQL;
END IF;
RETURN fResult;
--Tidy Up
DBMS_SQL.CLOSE_CURSOR(HNDL);
Return 'EGG';
END;
--EXAMPLE USAGE
--Select GET_COLUNS_AS_LIST
--Select * from SALES_TYPE
--', 1) FROM DUAL;So I have ended up with this.
When I next get some time, I'd like to be able to strip out the table and simply output the results to an SQL Developer script window without having to go through the table.
Now this works - but if you see that I am doing something wrong - please point it out.
Many thanks,
Ant
CREATE OR REPLACE FUNCTION GET_COLUNS_AS_LIST( P_SQL IN CLOB, Add_Equals_Sign Number := 0)
RETURN VARCHAR2
IS
fResult VARCHAR2(32000);
HNDL NUMBER;
d NUMBER;
colCount INTEGER;
i INTEGER;
ChunkSize INTEGER;
rec_tab DBMS_SQL.DESC_TAB;
cCRLF VARCHAR(2) := CHR(13) || CHR(10);
LONG_SQL dbms_sql.varchar2s;
n INTEGER;
l INTEGER;
u INTEGER;
StartPos INTEGER;
BEGIN
--INITIIALISE RESULT
HNDL := 0;
ChunkSize := 4;
fResult := '';
--fResult := fResult|| 'A';
HNDL := DBMS_SQL.OPEN_CURSOR;
--l := Length( P_SQL );
l := dbms_lob.getLength( P_SQL );
--l := 50;
u := Round( l / ChunkSize ) + 1;
--fResult := fResult|| 'B';
FOR n IN 1..u
LOOP
StartPos := ( ( n - 1 ) * ChunkSize ) + 1;
IF StartPos = 0 THEN
StartPos := 1;
END IF;
--LONG_SQL( n ) := SubStr( P_SQL, StartPos, ChunkSize );
LONG_SQL( n ) := DBMS_LOB.SUBSTR( P_SQL, ChunkSize, StartPos );
END LOOP;
--fResult := fResult|| 'C';
if HNDL <> 0 THEN
DBMS_SQL.PARSE ( c => HNDL,
statement => LONG_SQL,
lb => 1,
ub => u,
lfflg => false,
language_flag => DBMS_SQL.NATIVE );
--DBMS_SQL.PARSE( HNDL, P_SQL, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE( HNDL );
DBMS_SQL.DESCRIBE_COLUMNS( HNDL, colCount, rec_tab);
--fResult := fResult|| 'D';
FOR i in 1..colCount
LOOP
IF Add_Equals_Sign > 0 AND i > 1 THEN
fResult := ltrim( fResult || '=' || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
ELSE
fResult := ltrim( fResult || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
END IF;
END LOOP;
IF Add_Equals_Sign > 0 THEN
fResult := fResult ||'=';
END IF;
ELSE
fResult := '!!COULD NOT OPEN CURSOR!!';
END IF;
RETURN fResult;
--Tidy Up
IF HNDL <> 0 THEN
DBMS_SQL.CLOSE_CURSOR(HNDL);
END IF;
END;
-- !!!!HOW TO USE THIS FUNCTION!!!!
BEGIN
EXECUTE IMMEDIATE ('DROP TABLE RPT_COLNAME_LOOKUPS;');
COMMIT;
EXECUTE IMMEDIATE ('CREATE TABLE RPT_COLNAME_LOOKUPS( COLUMN_NAME CLOB );');
COMMIT;
EXCEPTION WHEN OTHERS THEN NULL;
END;
DECLARE
theSQL Clob;
myresult CLOB;
BEGIN
--CLEAR OUT PREVIOUS RWS
DELETE FROM RPT_COLNAME_LOOKUPS; COMMIT;
--ASSIGN THE SQL TO RUN IT FOR
theSQL := '
SELECT
EVENT.EVENT_ID AS COCK_SUCKER,
EVENT.EVENT_CODE, BLAH, BLAH, VERY LONG SQL STATEMENT';
--CALL THE FUNCTION PASSING IN THE SQL AND IF I WANT THE = OR NOT
SELECT GET_COLUNS_AS_LIST( theSQL, 1 ) INTO myresult FROM DUAL;
--INSERT THE RESULTS INTO A TABLE SO WE CAN GRAB THEM
INSERT INTO RPT_COLNAME_LOOKUPS SELECT myresult FROM DUAL;
COMMIT;
END;
--THEN LOOK AT THE COLUMNS NAMES IN THIS TABLE
--SELECT * FROM RPT_COLNAME_LOOKUPS;
--############################################################################# -
How to call a dll which has one VISA name as input
Hi there,
The Labview application builder can generate a dll file from a vi which is a simple serial comunication program using VISA name as one control.
The problem is how to call the dll file in Labview which has a VISA name as INPUT?
Thanks!
GeorgeI would suggest modifying the LabVIEW VI so that the input is a string control instead of a visa control. The LabVIEW application will work the same and there is no need for any casting. All visa VIs can take a string as an input. Then when you recreate the dll make the input a string. Then you can easily pass a string to the dll from any API.
-Josh -
How to call Java function which returns byteArray
context I have a class say
public class ByteArray{
public byte[] getByteArray(String str){
return str.getBytes();
}Consider i have object of ByteArray (some how) in native C code. I want to call getByteArray("Test") and obtain a byteArray. what is the C JNI function can i use?hy
CREATE OR REPLACE FUNCTION GET_SAL1(NN in NUMBER)
RETURN BOOLEAN
IS
BEGIN
INSERT INTO STD(ENO) VALUES(NN);
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN
RETURN false;
END;
you can call :
if GET_SAL1(NN) then
else
error
end if;
I hope i understand
Regards -
How to call a function, which name is stored in table?
Dear members,
I have a function with return number, and store its name in a table.
now I want to select this function name from table and run it and return the value to a variable in my form.
here is my code in when-button-pressed trigger.
DECLARE
v_value number;
V_FUNC VARCHAR2(100);
V_PARAM VARCHAR2(100);
begin
select FUNCTION_NAME, PARAM
INTO V_FUNC, V_PARAM
from function_table
where id =1;
message('V_FUNC='||V_FUNC); pause;
v_value := v_func||';'; --run_tb_function;
:text01 := v_value;
end;this code gives the following error:
ora-06502
regards:
Edited by: user2040934 on Feb 2, 2013 9:47 AMBelow is the modified code:
DECLARE
v_value number;
V_FUNC VARCHAR2(100);
V_PARAM VARCHAR2(100);
v_cmd varchar2(1000);
begin
select FUNCTION_NAME, PARAM
INTO V_FUNC, V_PARAM
from function_table
where id =1;
-- create a valuetable with one column vval varchar2 type
v_cmd := 'declare val varchar2(100); Begin val := '||v_func||'; delete from valuetable; insert into valuetable(vval) values (v); commit; end;';
forms_ddl(v_cmd);
begin
select vval into :text01 from valuetable where rownum = 1;
exception
when no_data_found then
-- do your action....
null;
end;
end;
Edited by: user5213229 on Feb 2, 2013 4:33 PM -
How to call a function/event after a Remote Object's data is loaded?
I'm making a call to a remote object that is loading a good
amount of data. I've set up a "please wait" label that is supposed
to display while the data is being loaded and then clear the label
when the data finishes loading.
At the moment I've got it set up like so...
label = 'Loading data, please wait..."
remoteObj.read.send();
label = ''
The problem with this is that the 'please wait' label doesn't
even display because the actual call to the remote object I'm
making finishes so quickly even though the data load does not. So
what I need is possibly an IF statement to check if the data has
finished loading. If it hasn't finished loading, the label stays in
the "please wait" status, or if the data does finish loading, then
the label clears out.
What would be ideal is...
remoteObj.read.send(); // gets the data
if(data is loaded){
label = '';
}else{
label = 'Please wait'
I just don't know how to form the statement for the data
loading in the IF statement.You are seeing the difference between data loading and UI
rendereing.
Reasonable amounts of data load very fast, expecially with
RemoteObject. Bur rendering the UI is almost always the bottleneck,
event with AS3 FP8+, which is about 30 percent faster than AS2!
I have not found a perfect solution for this myself, but i
think you will want to look into the component data events, to find
one that fires after the component is actually rendered.
Tracy -
Ora-06502 while calling oracle function
I am using 9.2.0.4.0 database.
I have vb.net application that uses oracle provider for .net to connect to database.
I am calling Oracle function which returns varchar2 value back.
when i execute cmd2.ExecuteNonQuery, I get ora-06502 error.
CREATE OR REPLACE FUNCTION ZZZ_TEMP( p_val IN VARCHAR2) RETURN varchar2
AS
BEGIN
RETURN 'HELLO';
EXCEPTION WHEN OTHERS THEN
RETURN SQLCODE||' - '||SUBSTR(SQLERRM,1,100);
END;
************** vb.net code
Dim cmd2 As New Oracle.DataAccess.Client.OracleCommand(UserSchemaName & ".ZZZ_TEMP", con)
Dim VAL As String
Try
cmd2.Parameters.Add("RetVal", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.ReturnValue)
cmd2.Parameters.Add("p_val", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.Input).Value = "XYZ"
cmd2.Connection = con
cmd2.CommandType = CommandType.StoredProcedure
cmd2.ExecuteNonQuery()
VAL = cmd2.Parameters("RetVal").Value
Catch ex As Oracle.DataAccess.Client.OracleException
MsgBox(ex.Message)
End TryIf I change this function to retrun number rather than Varchar2 and change my
RetVal parameter as follow it works. I am noticing that there might be a bug when function returns varchar2
cmd2.Parameters.Add("RetVal", Oracle.DataAccess.Client.OracleDbType.int32, ParameterDirection.ReturnValue)
cmd2.Parameters.Add("p_Val", Oracle.DataAccess.Client.OracleDbType.int32, ParameterDirection.Input).valu ="XYZ" -
How to call java function from PL/sql in oracle applications
I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
Thanks
Kranthihttp://www.oracle.com/technology/tech/java/jsp/index.html
Good Luck,
Avi. -
How to call java function in javascript
Hello Everyone,
Can anyone tell me solution that:
How to call java function in javascript?
Thanks,
VIDsYou can't since Java is running on the server and javascript is running in the browser long after the Java side of things has finished executing. Assuming you're not talking about an applet here.
But you can make calls back to the server through Ajax. All you need is something like a servlet on the receiving end which you can invoke through Ajax; from that point you can execute any Java code you want. -
How to bring oracle function into ODI
Hi,
I have a oracle function which I have to bring into ODI, could you please let me know how to do that?
Thanks!
Regards,
SupreethHi Supreeth ,
Before invoking a stored procedure from Oracle Data Integrator (ODI), run it outside ODI (i.e. SqlPlus), on the database, using the same database user as entered in the ODI Topology for this connection and make sure it is working properly .
Then, when invoking the stored procedure from Oracle Data Integrator (ODI):
1. Create an ODI Specific Procedure.
2. Insert a step and, in the "Technology" drill down box, choose the appropriate RDBMS. Leave the context to "<Execution Context>".
3. The precise syntax for calling RDBMS stored procedures in ODI may vary from one Technology to another one.
For Oracle technologies, the syntax is as follows:
BEGIN
<%=odiRef.getObjectName (pMode, My_Procedure, pLogicalSchemaName, pContextName, pLocation)%> (MY_PARAM1, MY_PARAM2...);
END;
where
* My_Procedure - is the stored procedure name
* MY_PARAM1, MY_PARAM2... - are stored procedure parameter values
* pMode, pLogicalSchemaName, pContextName, pLocation - are parameters of the getObjectName Substitution Method.
At my Oracle instance I have a function called MY_FUNCTION
So my syntax would be
<%=odiRef.getObjectName ("L","MY_FUNCTION","D")%>
Thanks,
Sutirtha -
JAVA Calling Oracle Function and Returning OBJECT
HI,
I am working as a developer in java/j2ee project.
I am facing one issue:
I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
Can you please help me
With Best Regardsgolduniya wrote:
I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
Can you please help meIt requires a great deal of Oracle jdbc driver specific code.
[http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraint.htm#1012664] -
How to call a function in an item ?
hi,
i have an item where i want to call a function, which will return some different value in runtime in r/o of item value.
so how can i call a function?
thanksHi,
So you want to enter the data in to the item and display the result to that item itself?
Or the data is fetching from database, and you want to pass that value to the function, and display the result in to the item?
If your requirement is 2, then in the POST-QUERY trigger write,
:<block_name>.<item_name> := <function_name>(:<block_name>.<item_name>);And if your requirement is 1, then you can do in 2 ways,
1) If you don't want to see the entered data, and want to replace with the entered data.
write in the KEY-NEXT-ITEM trigger
:<block_name>.<item_name> := <function_name>(:<block_name>.<item_name>);2) if you want to see both values,
Then you have to add 1 more item, and in the new item's properties set as in my first post.
Regards,
Manu.
If my response or the response of another was helpful or Correct, please mark it accordingly
Maybe you are looking for
-
Maximum length of a prompt which can be recorded in UCCX ver 8.5?
I have a customer who would like to be able to record company announcements via a script in UCCX and have it saved as a prompt. Is there a time limit on the length of a prompt which can be recorded?
-
Is there gonna' be a change in design?
I love my palm pre (bell) but have already lost 400$ (can) on it, and I'm sort of disappointed in functionality... By which I mean that it lags when I open an app, battery takes about 4 and a half hours to charge. I, in general don't like that there
-
Windows 7 - USB Drive - Mac OS X
I recently and successfully installed Windows 7 onto my i7 Macbook Pro (Early 2011) via bootcamp. While on my Windows 7/PC side, I simply copied a small mp4 video file from my desktop to my 8GB USB drive (FAT 32). If I run the file, both the video an
-
Anyone aware of a 3.0 USB hub without a power cord?
Anyone aware of a 3.0 USB hub without a power cord?
-
Hi, I have a problem with the built-in microphone it make a noise absurd, if I talk it feels very low voice but when there is sound coming from the PC (like when you connect a USB, jack, etc.) disappears and then returns. I tried a bit of everything