How to call a routine that returns a pointer using jni
hi this is ravi kiran,
i have a situation where i need to call a c-routine from my java program that returns a pointer.
how can i get the content of the pointer that the routine is returning.
plz help me
thanx in advance
Return it as a java long.
When you need to use it again then pass it in as a long and cast it to a pointer.
If you need to free it then you should consider writing a finalize() method (one of the few times it is appropriate) and a destroy() method as well.
Similar Messages
-
How to call a sp that returns multi_columns from another sp
Hi,
Can anybody help me to solve this problem? I called a sp which
returns ename, sal using a weak ref cursor from another sp. Is
it possible to do this? or I did something wrong? The error
messages are:
ERROR at line 1:
ORA-00904: invalid column name
ORA-06512: at "SCOTT.TESTPKG", line 14
ORA-06512: at line 1
below is my code:
create or replace package testpkg AS //12/19/01
TYPE sumCur IS REF CURSOR;
TYPE estType IS REF CURSOR;
function totalNo (
dno IN NUMBER)
RETURN estType;
procedure test(
sum_cv IN OUT NOCOPY sumCur);
END;
CREATE OR REPLACE PACKAGE BODY testpkg AS
function totalNo (
dno IN NUMBER)
RETURN estType IS est_cv estType;
BEGIN
OPEN est_cv FOR SELECT ename, sal FROM emp
where deptno = dno and job = 'MANAGER';
RETURN est_cv;
END totalno;
procedure test(
sum_cv IN OUT NOCOPY sumCur) AS
sql_statement VARCHAR2(100);
BEGIN
sql_statement :='SELECT dname, totalNo(deptno)
from dept ';
OPEN sum_cv FOR sql_statement ;
END test;
END;
ThanksThe error that you are getting is because totalNo(deptno) needs
to be testpkg.totalNo(deptno), but that is not the only error.
Maybe you can use something like this:
SQL> CREATE OR REPLACE PACKAGE testpkg
2 AS
3 TYPE sumcur IS REF CURSOR;
4 FUNCTION totalno
5 (dno IN NUMBER)
6 RETURN VARCHAR2;
7 PROCEDURE test
8 (sum_cv IN OUT sumcur);
9 END testpkg;
10 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY testpkg
2 AS
3 FUNCTION totalno
4 (dno IN NUMBER)
5 RETURN VARCHAR2
6 IS
7 est_cv VARCHAR2 (30);
8 BEGIN
9 SELECT ename || ' ' || TO_CHAR (sal)
10 INTO est_cv
11 FROM emp
12 WHERE deptno = dno
13 AND job = 'MANAGER';
14 RETURN est_cv;
15 END totalno;
16 PROCEDURE test
17 (sum_cv IN OUT sumcur)
18 AS
19 sql_statement VARCHAR2 (100);
20 BEGIN
21 sql_statement :=
22 ' SELECT dname, testpkg.totalno (deptno)'
23 || ' FROM dept';
24 OPEN sum_cv FOR sql_statement;
25 END test;
26 END testpkg;
27 /
Package body created.
SQL> VARIABLE g_ref REFCURSOR
SQL> EXEC testpkg.test (:g_ref)
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
DNAME
TESTPKG.TOTALNO(DEPTNO)
ACCOUNTING
CLARK 2450
RESEARCH
JONES 2975
SALES
BLAKE 2850
DNAME
TESTPKG.TOTALNO(DEPTNO)
OPERATIONS -
Call a procedure that returns a refcursor, use it in another proc's sql?
I have a procedure that returns a refcursor; how can I include that refcursor in a sql statement that's in another procedure, or view etc?
This is the kind of foolery I've tried so far (myproc1 returns a ref cursor):
create or replace procedure myproc2
rc ref cursor
AS
rc1 ref cursor;
begin
EXECUTE myproc1(rc1);
open rc for
select rc1.* from rc1;
end myproc2;lecaro wrote:
To reiterate, I was interested in consuming the refcursor output of one proc in another proc. I wanted to take what I regarded as the records returned by the first sproc and manipulate them using SQL in the second sproc.
Since I can't use that approach, what are some hopefully fairly straightforward solutions that might work?Something like:
create or replace
procedure p1(
p_stmt varchar2,
p_refcursor OUT sys_refcursor
is
begin
open p_refcursor for p_stmt;
end;
create or replace
procedure p2(
p_stmt varchar2
is
v_refcursor sys_refcursor;
v_var varchar2(30);
begin
p1(p_stmt,v_refcursor);
loop
fetch v_refcursor into v_var;
exit when v_refcursor%notfound;
dbms_output.put_line(v_var);
end loop;
end;
set serveroutput on
exec p2('select ename from emp where deptno = 20');
SQL> set serveroutput on
SQL> exec p2('select ename from emp where deptno = 20');
SMITH
JONES
SCOTT
ADAMS
FORD
PL/SQL procedure successfully completed.
SQL> SY. -
How to call multiple routines that do not return.
I need to create a script (pl/sql, sql*plus, unix, or whatever is best) that starts 18 instances of a stored procedure that continutes to execute without returning. (The proc wakes up periodically, looks for a file in a directory, processes it if it exists and otherwise goes back to sleep for awhile - doing this continually unless it finds a stop command in a table.)
The fellow who developed this proc just manually starts 18 command windows in pl/sql developer. I have been asked to come up with a way to automate the startup.
I could start sql*plus in 18 unix jobs but I was hoping to find a way to make one call to a SP to kick it all off.if it is already running continously why do you need to automate the process running
We need a way for server maintenance folks to stop and restart this process in an orderly manner without knowing anything about Oracle. They call operations and say "we need to take the server down for maintenance." Ops say "ok, we need to run this stop process. Let us know when we can restart it."
Ops can only run a Unix script. I don't want the Unix script to leave 18 instances of sqlplus running 24x7.
But this thread gave me the answer. The Unix script calls a S.P. that kicks off the jobs to start the 24x7 processes. The unix script terminates nicely after calling the startup routine. Voila! (the shut down process is a totally different beast and much simpler) -
JavaFX : How to call java function that returns hashtable and manipulate
I have a requirement to {color:#0000ff}create a java object in JavaFX script code{color}. Then call a java function using the created java object. The java function returns hashtable. Then traverse through each element of hashtable. Finally I need to create a similar structure in JavaFX.
If you need to use a Java class that uses generics you need to take special steps. Since JavaFX does not support generics you need to create a java wrapper to hide the calls that use generics and call the wrapper class from FX.
-
How to call a procdure that will return me list of values(JSF,ADF BC)
hi all,
any one can help me how to call a procedure that will return me list of value with using adf and jsfI did this with a LoginModule that returned a list of user roles. Below is the Java call
stmt = conn.prepareCall(authquery);
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.setString(2,username);
stmt.setString(3,new String(password));
// realm is null if not set
stmt.setString(4,_application_realm);
stmt.execute();
rolesResultSet = (ResultSet)stmt.getObject(1);
stmt.close();authquery is the name of a procedure that returned a ref Cursor
CREATE OR REPLACE PACKAGE "DBPROCLM" IS
TYPE principal_ref IS REF CURSOR;
function get_user_authentication(p_username in varchar2, p_password in varchar2, p_realm varchar2) return principal_ref;
END;
CREATE OR REPLACE PACKAGE BODY "DBPROCLM" IS
FUNCTION get_user_authentication (p_username in varchar2, p_password in varchar2, p_realm varchar2)
RETURN principal_ref
AS
var_username varchar2(100);
var_userid number(10);
var_password varchar2(100);
role_cursor principal_ref;
FAILED_AUTHENTICATION exception;
BEGIN
select userid, username, password into var_userid, var_username, var_password from sec_users where username = p_username;
if (var_password = p_password) then
begin
if (p_realm is null) then
open role_cursor for
select rolename from user_roles_view where userid = var_userid;
else
open role_cursor for
select rolename from user_roles_view where userid = var_userid and realm=p_realm;
end if; -- p_realm check
end;
-- if password doesn't match, raise Excpetion for LM to
-- abort the authentication process
else raise FAILED_AUTHENTICATION;
end if;
RETURN role_cursor;
END get_user_authentication;
END;You only ned to expose the call to teh procedure in a method (e.g. on ADF BC Application Module) and create a method binding for it.
Frank -
Function calling stored procedure that returns a cursor into a LOV
Hello,
Is it possible in HTML DB to implement a process that has a function that calls a stored procedure that returns a cursor, used to then populate a select list?
Or can I do a function call to a stored procedure in the 'List of values definition' box for the item itself that returns a cursor to populate the item's select list?Hi Vikas,
Actually, I just found another posting that shows how to do what I'm looking for:
Re: Filling a LOV with a cursor
Check it out. I posted another question in response to that discussion...maybe you could answer that? Thanks!
Laura -
Call a Stored Procedure that returns a REFCURSOR using ODI Procedure
Hi,
I have a scenario wherein the stored procedure (TEST_PROC1) that returns a REFCURSOR. The second procedure(TEST_PROC2) will use the REFCURSOR as inpuut and insert it to a table.
Now, I need to execute the test procedures (TEST_PROC1 and TEST_PROC2) using the ODI Procedure but I always get error. However, I was able to execute the test procedures using sqlplus. Here is the command I used for sqlplus:
var rc refcursor
exec TEST_PROC1(:rc);
exec TEST_PROC2(:rc);
PL/SQL Stored Procedure:
-- TEST_PROC1 --
create or replace
PROCEDURE TEST_PROC1 (p_cursor IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_cursor FOR
SELECT *
FROM test_table1;
END;
-- TEST_PROC2 --
create or replace
procedure TEST_PROC2( rc in out sys_refcursor ) is
FETCH_LIMIT constant integer := 100;
type TFetchBuffer is table of test_table2%RowType;
buffer TFetchBuffer;
begin
loop
fetch rc bulk collect into buffer limit FETCH_LIMIT;
forall i in 1..buffer.Count
insert into test_table2(
c1, c2
) values(
buffer(i).c1, buffer(i).c2
exit when rc%NotFound;
end loop;
end;
Is there a way to call a PL/SQL Stored Procedure that returns a REFCURSOR using ODI Procedure?
Thanks,
CathyThanks for the reply actdi.
The procedure TEST_PROC1 is just a sample procedure. The requirement is that I need to call a stored procedure that returns a cursor using ODI and fetch the data and insert into a table, which in this case is test_table2.
I was able to execute a simple SQL procedure (without cursor) using ODI procedure. But when i try to execute the SQL procedure with cursor in ODI, I encountered error.
Do you have any idea how to do this? -
How to call the application that submitted with the ipod touch 5?? is a ninja
how to call the application that submitted with the ipod touch 5?? is a ninja
You should not discuss beta software here at all.
This is a developer only question and should be posted in the developer forum -
How to call a class that extends a frame from a panel ?
How to call a class that extends a frame from a panel ?
I am trying to create an application say "Videoshow"
Videoshow has a panel which in turn consists of 2 components : 1]a textarea( to show the contents of a page) and 2] a mediaclip(to show the video).
Now I have an application "MediaApplication"(to show the videoclip) which extends Frame (Code from Java 2 Unleashed, Chap 21). I want to show this MediaApplication in Component 2 of the above panel. But when I do this, I only see the MediaApplication frame instead of the whole SlideShow.
I want to do something likethis.
VideoShow :
|---------------------------------|-------------------|
| |
| (Comp 1) | (Comp 2)
| TEXTAREA | Video Clip
| |(MediaApp entends Frame)
|---------------------------------|-------------------|
What is the best way to achieve this ? Also which component can I use to show the videoclip ?im not familiar with the code you mention from Java 2 Unleashed, but your best bet is to read up on Swing a bit - so you get an idea of how Swing containers and components work - then im sure you'll find a solution to your problems. Then if you encounter any difficulties whilst your attempting to do that, post your code in the Swing forum and im sure someone will help you.
-
SOLVED: How can I use or call a function that returns %ROWTYPE?
Hi
edit: you can probably skip all this guff and go straight to the bottom...In the end this is probably just a question of how to use a function that returns a %rowtype. Thanks.
Currently reading Feuerstein's tome, 5th ed. I've downloaded and run the file genaa.sp, which is a code generator. Specifically, you feed it a table name and it generates code (package header and package body) that will create a cache of the specified table's contents.
So, I ran:
HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\OPP5.WEB.CODE\OPP5.WEB.CODE\genaa.sp"
749 /
Procedure created.
HR@XE> exec genaa('EMPLOYEES');which generated a nice bunch of code, viz:
create or replace package EMPLOYEES_cache is
function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE) return HR.EMPLOYEES%ROWTYPE;
function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE) return HR.EMPLOYEES%ROWTYPE;
procedure test;
end EMPLOYEES_cache;
create or replace package body EMPLOYEES_cache is
TYPE EMPLOYEES_aat IS TABLE OF HR.EMPLOYEES%ROWTYPE INDEX BY PLS_INTEGER;
EMP_EMP_ID_PK_aa EMPLOYEES_aat;
TYPE EMP_EMAIL_UK_aat IS TABLE OF HR.EMPLOYEES.EMPLOYEE_ID%TYPE INDEX BY HR.EMPLOYEES.EMAIL%TYPE;
EMP_EMAIL_UK_aa EMP_EMAIL_UK_aat;
function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE)
return HR.EMPLOYEES%ROWTYPE is
begin
return EMP_EMP_ID_PK_aa (EMPLOYEE_ID_in);
end;
function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE)
return HR.EMPLOYEES%ROWTYPE is
begin
return EMP_EMP_ID_PK_aa (EMP_EMAIL_UK_aa (EMAIL_in));
end;
procedure load_arrays is
begin
FOR rec IN (SELECT * FROM HR.EMPLOYEES)
LOOP
EMP_EMP_ID_PK_aa(rec.EMPLOYEE_ID) := rec;
EMP_EMAIL_UK_aa(rec.EMAIL) := rec.EMPLOYEE_ID;
end loop;
END load_arrays;
procedure test is
pky_rec HR.EMPLOYEES%ROWTYPE;
EMP_EMAIL_UK_aa_rec HR.EMPLOYEES%ROWTYPE;
begin
for rec in (select * from HR.EMPLOYEES) loop
pky_rec := onerow (rec.EMPLOYEE_ID);
EMP_EMAIL_UK_aa_rec := onerow_by_EMP_EMAIL_UK (rec.EMAIL);
if rec.EMPLOYEE_ID = EMP_EMAIL_UK_aa_rec.EMPLOYEE_ID then
dbms_output.put_line ('EMP_EMAIL_UK lookup OK');
else
dbms_output.put_line ('EMP_EMAIL_UK lookup NOT OK');
end if;
end loop;
end test;
BEGIN
load_arrays;
end EMPLOYEES_cache;
/which I have run successfully:
HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\EMPLOYEES_CACHE.sql"
Package created.
Package body created.I am now trying to use the functionality within the package.
I have figured out that the section
BEGIN
load_arrays;
end EMPLOYEES_cache;
/is the initialization section, and my understanding is that this is supposed to run when any of the package variables or functions are referenced. Is that correct?
With that in mind, I'm trying to call the onerow() function, but it's not working:
HR@XE> select onerow(100) from dual;
select onerow(100) from dual
ERROR at line 1:
ORA-00904: "ONEROW": invalid identifier
HR@XE> select employees_cache.onerow(100) from dual;
select employees_cache.onerow(100) from dual
ERROR at line 1:
ORA-06553: PLS-801: internal error [55018]
HR@XE> select table(employees_cache.onerow(100)) from dual;
select table(employees_cache.onerow(100)) from dual
ERROR at line 1:
ORA-00936: missing expressionHe provides the code genaa.sp, and a very brief description of what it does, but doesn't tell us how to run the generated code!
Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
So I try wrapping the call in an exec:
HR@XE> exec select employees_cache.onerow(100) from dual;
BEGIN select employees_cache.onerow(100) from dual; END;
ERROR at line 1:
ORA-06550: line 1, column 30:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PLS-00428: an INTO clause is expected in this SELECT statement
HR@XE> exec select table(employees_cache.onerow(100)) from dual;
BEGIN select table(employees_cache.onerow(100)) from dual; END;
ERROR at line 1:
ORA-06550: line 1, column 14:
PL/SQL: ORA-00936: missing expression
ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored
HR@XE> exec employees_cache.onerow(100)
BEGIN employees_cache.onerow(100); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'ONEROW' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredNo joy.
Of course, now that I'm looking at it again, it seems that the way to go is indicated by the first error:
PLS-00428: an INTO clause is expected in this SELECT statement
So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
I've had a stab at this, but still, no joy:
create or replace procedure testcache is
emp employees%rowtype;
begin
select employees_cache.onerow(100) from dual into emp;
dbms_output.put_line('Emp id: ' || emp.employee_id);
end testcache;
show errors
HR@XE> @testcache.sql
Warning: Procedure created with compilation errors.
Errors for PROCEDURE TESTCACHE:
LINE/COL ERROR
4/9 PL/SQL: SQL Statement ignored
4/54 PL/SQL: ORA-00933: SQL command not properly ended
HR@XE>Have a feeling this should be really easy. Can anybody help?
Many thanks in advance.
Jason
Edited by: 942375 on 08-Feb-2013 11:45>
Ha, figured it out
>
Hopefully you also figured out that the example is just that: a technical example of how to use certain Oracle functionality. Unfortunately it is also an example of what you should NOT do in an actual application.
That code isn't scaleable, uses expensive PGA memory, has no limit on the amount of memory that might be used and, contrary to your belief will result in EVERY SESSION HAVING ITS OWN CACHE of exactly the same data if the session even touches that package.
Mr. Feuerstein is an expert in SQL and PL/SQL and his books cover virtually all of the functionality available. He also does an excellent job of providing examples to illustrate how that functionality can be combined and used. But the bulk of those examples are intended solely to illustrate the 'technical' aspects of the technology. They do not necessarily reflect best practices and they often do not address performance or other issues that need to be considered when actually using those techniques in a particular application. The examples show WHAT can be done but not necessarily WHEN or even IF a given technique should be used.
It is up to the reader to learn the advantages and disadvantages of each technicalogical piece and determine when and how to use them.
>
Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
>
That is correct. To be used by SQL you would need to create SQL types using the CREATE TYPE syntax. Currently that syntax does not support anything similar to %ROWTYPE.
>
So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
>
NO! That is a common misconception. Each session has its own set of package variables. Any session that touches that package will cause the entire EMPLOYEES table to be queried and stored in a new associative array specifically for that session.
That duplicates the cache for each session using the package. So while there might be some marginal benefit for a single session to cache data like that the benefit usually disappears if multiple sessions are involved.
The main use case that I am aware of where such caching has benefit is during ETL processing of staged data when the processing of each record is too complex to be done in SQL and the records need to be BULK loaded and the data manipulated in a loop. Then using an associative array as a lookup table to quickly get a small amount of data can be effective. And if the ETL procedure is being processed in parallel (meaning different sessions) then for a small lookup array the additional memory use is tolerable.
Mitigating against that is the fact that:
1. Such frequently used data that you might store in the array is likely to be cached by Oracle in the buffer cache anyway
2. Newer versions of Oracle now have more than one cache
3. The SQL query needed to get the data from the table will use a bind variable that eliminates repeated hard parsing.
4. The cursor and the buffer caches ARE SHARED by multiple sessions globally.
So the short story is that there would rarely be a use case where ARRAYs like that would be preferred over accessing the data from the table. -
How to call a Function that will return me boolean value
Hi all ,
I am try to call a function that is included in my ApplictionModule the following is my method code
public boolean callUpdateDepartmentNameFunction(int deptNo,String newName)
boolean result=false;
System.out.println("first");
CallableStatement plsqlBlock =null;
System.out.println("sec");
String statement="BEGIN :3 = update_dname_func(:1,:2); END;";
System.out.println("third");
plsqlBlock=getDBTransaction().createCallableStatement(statement,0);
try{
System.out.println("forth");
plsqlBlock.registerOutParameter(3,OracleTypes.BOOLEAN);
plsqlBlock.setInt(1,deptNo);
plsqlBlock.setString(2,newName);
plsqlBlock.execute();
result=plsqlBlock.getBoolean(0);
catch(SQLException sqlException)
throw new SQLStmtException(CSMessageBundle.class,CSMessageBundle.EXC_SQL_EXECUTE_COMMAND,statement,sqlException);
finally
try{
plsqlBlock.close();
catch(SQLException e)
e.printStackTrace();
} return result;
while am runing my page is am getting error like
Error
1. JBO-29000: Unexpected exception caught: oracle.jbo.SQLStmtException, msg=JBO-27121: SQL error during statement execution. Statement: BEGIN :3 = update_dname_func(:1,:2); END;
2. JBO-27121: SQL error during statement execution. Statement: BEGIN :3 = update_dname_func(:1,:2); END;
3. Invalid column type
callUpdateDepartmentNameFunction_deptNO
callUpdateDepartmentNameFunction_newName
callUpdateDepartmentNameFunction
regards,
Prabeethsoy PHi,
http://download-uk.oracle.com/docs/html/B25947_01/bcadvgen005.htm#sm0297
has an example of how to call a stored procedure with out parameters. Please correct your code accordingly
Frank -
Calling a method that returns values in a map - using JSTL
Hi I have a method within an object that returns a List for a particular category
public List<String> getFieldsInCategory(String categoryName){
return _categoryFieldsMap.get(categoryName); //This is a map that returns a list
}Trying to call the above function in jsp, the object is available as "document",
how do i pass a key to the above function to return a List.
<c:forEach items="${document.fieldsInCategory('ABSTRACT')}" var="temp">How do i get the list by passing a string key to my method,
please let me know how to go about this.
ThanksJSTL can not directly call methods that take parameters.
All it can do is access javabean properties - ie via the revealed get/set methods.
You can fudge it by having a seperate variable to set:
Map _categoryFieldsMap;
String category = null;
public void setCategory(String category){
this.category = category;
public String getCategory(String category){
return category;
public List<String> getFieldsInCategory(){
return _categoryFieldsMap.get(categoryName); //This is a map that returns a list
}You would then do it like this in your JSP:
<c:set target="document.category" value="ABSTRACT"/>
<c:forEach items="${document.fieldsInCategory}" var="temp">
...The other alternative is to return the entire map to the page.
EL accesses maps quite handily.
so given a method that returns the map:
public Map getCategoryFieldsMap(){
return _categoryFieldsMap;
then the expression: ${document.categoryFieldsMap.ABSTRACT} returns what you are after.
Hope this helps,
evnafets -
Calling a dll that returns a handle
I am using the LV Call Library Function to call a reflective memory
board interface dll on a Windows 2000 system. The first call is to OPEN
with an argument of a pointer to a string containing the name of the
device. This opens the driver and returns a handle that is used in the
calls to all the other calls. Unfortunately, the return value in the
Call Library Function can't be set to handle.
If I set the return value to U32 (unsigned 32 bit int) it seems to work
since it returns the same value each time and it returns 0 (the error
value) if I give it the wrong device name. The problem is that when I
try to cast the returned value as a handle, all the other calls return 0
or error.
The board came with a command line in
terface program that allows me to
exercise the board so I know that everything is working except my
interface to the dll.
Ed BogartHow are you "casting" this U32 value to dll handle?
Which are the settings in configuration of dll call dialog like "calling conventions" and how the called dll function prototype looks like?
Is your dll thread-safe?
How you calling the second call library functio node? (may be sample diagram or picture)
Sergey -
Calling a procedure that returns a cursor inside a procedure
Hi,
I have two stored procedures. They both return a cursor as output variables. On the other hand I have another stored procedure that calls these procedures and return their results again an output variable. I know that this seems quite odd to be wanting to do something like this but how can I do that?You can make the hack generic. Make it execute any SQL as that schema that creates the ref cursor. E.g.
// as schema BILLY, open a huge security hole and grant access to USER1
SQL> create or replace procedure GetTableData( tableName varchar2, refCur out sys_refcursor ) authid definer is
2 dynamicSQL varchar2(32767);
3 begin
4 dynamicSQL := 'select * from '||tableName;
5 open refCur for dynamicSQL;
6 end;
7 /
Procedure created.
SQL>
SQL>
SQL> grant execute on GetTableData to USER1;
Grant succeeded.As USER1, you can now execute SQL (and even PL/SQL) as BILLY:
SQL> create or replace type TStrings is table of varchar2(4000);
2 /
Type created.
SQL> grant execute on TStrings to BILLY;
Grant succeeded.
SQL> --// execute this as the caller (which will be BILLY.GetTableData)
SQL> create or replace procedure ExecSQL( hackSQL varchar2 ) authid current_user is
2 pragma autonomous_transaction;
3 begin
4 execute immediate hackSQL;
5 commit;
6 end;
7 /
Procedure created.
SQL> --// wrap the above into something that BILLY.GetData can execute as a ref cursor
SQL> --// and return a meaningful message as to how successful the hack was
SQL> create or replace function PipeLineHack( hackSQL varchar2 ) return TStrings authid current_user pipelined is
2 begin
3 ExecSQL( hackSQL );
4 pipe row( 'SQL hack successful' );
5 exception when OTHERS then
6 pipe row( 'SQL hack faled with '||SQLERRM(SQLCODE) );
7 end;
8 /
Function created.
SQL>
SQL> grant execute on PipeLineHack to BILLY;
Grant succeeded.
SQL>
SQL> var c refcursor
SQL> --// expected used of the GetTableData() interface
SQL> --// we select from table BILLY.EMP
SQL> exec BILLY.GetTableData( 'EMP', :c );
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 1980/12/17 00:00:00 800 0 20
7499 ALLEN SALESMAN 7698 1981/02/20 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 1981/02/22 00:00:00 1250 500 30
7566 JONES MANAGER 7839 1981/04/02 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 1981/09/28 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 1981/05/01 00:00:00 2850 30
7782 CLARK MANAGER 7839 1981/06/09 00:00:00 2450 10
7788 SCOTT ANALYST 7566 1987/04/19 00:00:00 3000 20
7839 KING PRESIDENT 1981/11/17 00:00:00 5000 10
7844 TURNER SALESMAN 7698 1981/09/08 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 1987/05/23 00:00:00 1100 20
7900 JAMES CLERK 7698 1981/12/03 00:00:00 950 30
7902 FORD ANALYST 7566 1981/12/03 00:00:00 3000 20
7934 MILLER CLERK 7782 1982/01/23 00:00:00 1300 10
14 rows selected.
SQL>
SQL> --// getting that interface to run unexpected code - we
SQL> --// rename BILLY.EMP table to something else
SQL> exec BILLY.GetTableData( 'TABLE(USER1.PipeLineHack( ''alter table emp rename to emp_has_been_hacked''))', :c );
PL/SQL procedure successfully completed.
SQL> print c
COLUMN_VALUE
SQL hack successful
SQL>
Maybe you are looking for
-
What I don't understand is when I first purchased and connected there was no problem, only after a reset (because I thought I was going to sell the device) did I have this problem. AND the iPod Touch asks if I trust this computer to which I say yes,
-
Can I repair a Snow Leopard disk from a Tiger machine?
I had the hard drive go down on a MacPro with an Intel processor running OS 10.6.4. When I try to boot, it gets to the Apple screen and shuts down. Running the disk utility from the installation disk gives me the error: Checking HFS Plus Volume Inv
-
Sample java code for web service calling
Hello, I need to call the web services for adding/updating records on Oracle On Demand Entities. In particular i need a sample code in java language that explain how to append the sessionid to the SOAP request when calling the web service. thanks in
-
Most efficient way to handle Strings?
I've heard that Strings are immutable, so you should use StringBuffers. For example, lets say you have an array of Strings called testArray... String matchMe = ""; for (int i = 0 ; i < testArray.length ; i++) matchMe = resultOfSomeExpression;
-
Configuring Airptort Extreme for Optimum Speed and security 802.11n
Hello, I am running a Airport Extreme 802.11n with a Macbook Pro Core 2Duo, I would like to configure the Airport Extreme to run in the fastest and most secure mode. Since I plan on only running .N devices I do not need backwards compatibility with o