Precompilers, OCI & OCCI :: Passing Array Of Structure To Oracle Procedure And Returning Back?

Apr 29, 2010

I created a table and some type definitions in oracle 10.2.0.3 DB as follows. There is also a procedure that I defined and is shown below.

SQL> create table test_proc
(
test_name varchar2(10),
test_ver number (3,3),
active_flag number(2)
);

Table created.

SQL> select * from test_proc;
TEST_NAME TEST_VER ACTIVE_FLAG
---------- ---------- -----------
AFP 1.5 2
PSA 11.89 0
EHIV 99.5 3
aHAVM 1.45 9

[code]....

Now from Pro*C function I want to pass a similar array of structure to this procedure and return it via the out parameter of the procedure back to Pro*C. How do I do it?

I am using the attached program but its giving me compiler error as follows..

Error at line 31, column 1 in file sample.pc
proc_modify_tdefs (:in_tdefs,:out_tdefs);
1
PLS-S-00306, wrong number or types of arguments in call to 'PROC_MODIFY_TDEFS'
Error at line 31, column 1 in file sample.pc
proc_modify_tdefs (:in_tdefs,:out_tdefs);

[code]....

View 2 Replies


ADVERTISEMENT

Precompilers, OCI & OCCI :: Receiving Records Of Table In Array Of Structure

Mar 12, 2009

sample code in OCI in C for receiving records of table in array of structure? Or dynamically storing the result-set in an array..using array of pointers to structure..

View 6 Replies View Related

Precompilers, OCI & OCCI :: Using Pointer To Structure For Selecting Multiple Rows From Table

May 11, 2010

I am working on Pro*C and i have a requirement where i need to select all the rows from a table into a c - structure variable. Since i get to know the no of rows in the table which is getting selected only at run time, i need to create a pointer variable to the structure and i'll allocate the size to it based on the count of rows in the table using malloc or calloc.I tried allocating memory using calloc and it does not show any error. But when i when the exec select statement run it shows an error.

Statements i have used:
struct common *comp;
struct common_ind *comp_i;

comp = (struct common*) calloc(rowcount, sizeof(struct common));
comp_i = (struct common_ind*) calloc(rowcount, sizeof(struct common_ind));

exec sql at db1 select * into :comp indicator :comp_i from tab1;

Error i get :

Stop Error: -2112
Stop Error: -1012
Stop Error: -1012

View 2 Replies View Related

Precompilers, OCI & OCCI :: Insert Multiple Rows Using Array Bind Feature?

Aug 18, 2010

I am trying to insert multiple rows using array bind feature.

The following is working fine & inserting rows as expected.

char values[3][2] = { "1", "2", "3" };
ub2 lenp[3];
lenp[0] = lenp[1] = lenp[2] = 2;

[Code]...

OCIStmtExecute() is failing with the following error

Error - ORA-01480: trailing null missing from STR bind value

View 1 Replies View Related

Precompilers, OCI & OCCI :: How To Pass Array Of Strings To And Return Table Set From Proc

Jan 24, 2011

I have to write a PL/SQL procedure, which is supposed to take an array of strings as input. This array will have simple strings as elements, like

'000887S','000780S'.

Now I have a query in the procedure, which will return a row, for each of the array elements. For example:

SELECT
su.EMPLOYEE_ID,su.FIRST_NAME,
su.LAST_NAME
FROM
USERS su,
[code]......

In the place of the '?' in the above query, the array elements have to be passed. So we will get one row from the above query for each array element.

Now we either have to loop through the array elements to fetch the result set for the above query for each array element, or we can use some other method too. Our objective is to collect all the rows of the above query for each array element as a table data and this procedure has to return this table set.

what will be the best way to pass such a set of data to the proc and best way for the proc to return this result set. Like we can use arrays, table type data,ref cursors, etc.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Passing Parameters In A Dynamic Query

Jul 31, 2009

I have a Pro*C program, which uses a dynamic query. The dynamic query is opened using result of another static cursor( 5 fields say , :a, :b , :c, :c, :d).

I am modifying the dynamic query and adding UNION for some requirement , which makes this dynamic query exactly double in size. ( means 2 set of prev. queries are joined by UNION, with one extra condition though).

The question is , Do I need to pass 2 set of variable to open the dynamic query now?

Like earlier , program was passed with (:a, :b , :c, :c, :d)
so now i should pass (:a, :b , :c, :c, :d , :a, :b , :c, :c, :d)?

View 9 Replies View Related

PL/SQL :: Execute Procedure By Passing Number Array

Oct 26, 2012

Oracle 11.2.0.1
Windows

create type np_type is varray(3) of number
/

create type cn_type is varray(3) of number;
/

create type cxn_type is varray(3) of varchar2(2000)
/

I created TEST table by below pl/sql block :

declare
execstr varchar2(2000) :='create table test(';
begin
for i in 1..80 loop

[Code]....

*ERROR at line 5: ORA-06550: line 5, column 8: PLS-00103: Encountered the symbol "MYPROC1" when expecting one of the following: := . ( @ % ;

The symbol ":=" was substituted for "MYPROC1" to continue.

SQL>The above procedure will insert the supplied numbered string into the test table which split the numbered string based upon supplied splitids of sp_table.

View 7 Replies View Related

Precompilers, OCI & OCCI :: Pro*C - Cursor Leak With Cursor Array

Sep 7, 2007

I'm dealing with an ORA-1000 error in a Pro*C application where all the cursors are correctly closed (or so it seems to me).

Here is the code for a simple program which reproduces the problem:

Each cursor is opened in a PL/SQL package:

CREATE OR REPLACE PACKAGE emp_demo_pkg AS
TYPE emp_cur_type IS REF CURSOR;
PROCEDURE open_cur(curs IN OUT emp_cur_type, dept_num IN NUMBER);
END emp_demo_pkg;

[Code]....

While testing the initialization parameter open_cursors is set to 50.

It's my understanding that Oracle doesn't close the cursors until it needs the space for another cursor, which in my test case seems to happen when I enter a value of 50 or bigger for "number of loops". To see how oracle is reusing the cursors, while the test program is running I run SQL*Plus and query v$sesstat for the session that's running the test with the following sentence:

select name, value
from v$sesstat s, v$statname n
where s.statistic# = n.statistic#
and sid = 7
and name like '%cursor%';

Even before I enter a value for number of loops I can see that the session opened 4 cursors and closed 2 of them:

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 4
opened cursors current 2

Entering a value of 5 for number of loops yields

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 11 <----- 7+
opened cursors current 8 <----- 6+

With a value of 30

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 36 <----- 25+ (apparently, Oracle reused at least 5 cursors)
opened cursors current 33 <----- 25+

With a value of 47

NAME VALUE
---------------------------------------------------------------- ----------
opened cursors cumulative 53 <----- 17+
opened cursors current 50 <----- 17+

Now I reached the upper limit set by the initialization parameter open_cursors.

Entering a value of 48, I get the ORA-1000 error.

ORA-01000: maximum open cursors exceeded
ORA-06512: at "SCOTT.EMP_DEMO

Since I open and close the cursor in the same loop iteration, I expect to find in every iterarion 1 explicit cursor and a number of implicit cursors (the PL/SQL call along with the so-called recursive cursors), but I don't expect the sum of all of them to be greater than 50. If my understanding is correct Oracle should be reusing the 50 cursors previously marked as "closeable", not raising the ORA-1000 error.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Calling Procedure From PRO C?

Nov 26, 2012

I am trying to call procedure from PRO C Procedure has many parameters and I do not need to put all of them when I call procedure. Is there way to make the same way as in PL/SQL

like this

my_procedure( q=>a1 , b=>'abc )

View 1 Replies View Related

Precompilers, OCI & OCCI :: Bulk Insert To Stored Procedure?

May 12, 2009

I have an array of C structs say

struct S
{
int a, long b, double c;
};
S s[100];

Further suppose I have an Oracle table T like this:

create table T
(
a number(10),
b number(10),
c float
);

I want to bulk insert all 100 instances of S from a client application into T. I've seen code that does this for *one* field or column. The code defines a stored procedure which accepts a single argument which is a TABLE and then does a FORALL ... insert. The client application passes in the array of data.

What I need is N columns. In my example above struct S has N=3 fields which conform to the N=3 columns in T. In reality my N will be 50+. I am trying to avoid creating stored procedures which will take the 50 or so arguments it will eventually need.

So does my stored procedure need to accept N TABLE arguments? Or can I cajole OCI/OTL/ODBC and PL/SQL so that the stored procedure can take an array of rows which the type of row conforms to T by defining a record or something? That is, do I need:

Option 1: // declares one type and one argument each for N cols
create or replace procedure insert_S(
a_array IN A_TABLE, -- type A_TABLE is TABLE of number;
b_array IN B_TABLE, -- type B_TABLE is TABLE of number;
c_array IN C_TABLE) -- type C_TABLE is ...
begin ... end

Option 2: // this somehow accepts an array compatible with T
// if I could get a OCI/OCCI/OTL/ODBC application
// to send this data, this procedure would have
// only one argument
create or replace procedure insert_S(
row_array IN ?????????? type -- some sort of array of rows
)
begin ... end

Or should I pass the whole memory chunk of data in as an image or varchar array -- basically an opaque block of data -- and then internally decypher/decode the memory block inside the stored procedure as discussed on [URL].

best way to pass an array of N C-structs of M fields to a stored procedure for insertion into a table with M compatible columns? One TABLE per column? with an array of a custom type compatible with a row in T? As glob of data? Another option is to populate some host variables ... but, again, I'd need N host variables.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Calling Stored Procedure From C Program

Mar 19, 2010

I need to call a PL/SQL stored procedure from a C program. Something like this sample program provided by Oracle -

main()
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
/* Define type for null-terminated strings. */
EXEC SQL TYPE asciz IS STRING(20);
asciz username[20];
asciz password[20];
[code].......

The question is - how is the Stored procedure get_employees declared ? Or more specifically, how is the salary parameter declared in get_employees ?

View 4 Replies View Related

Precompilers, OCI & OCCI :: PLS-00306 / Wrong Number Or Types Of Arguments In Call To Existing Stored Procedure

Feb 1, 2010

I'm using an existing stored procedure in my C code. The stored procedure in question has been compiled and is proven to work without any errors. However, when I use the same in my C code, its failing with the above error.

The Store procedure definition looks like :

CREATE OR REPLACE FUNCTION SP(
srq_id integer ,
unid IN SPkg.arr_parmid,
parm_typ IN SPkg.arr_parm_typ,

[code].....

Type definitions

TYPE arr_parm_typ IS TABLE OF char INDEX BY BINARY_INTEGER;
TYPE arr_parmid IS TABLE OF tbl_parm.UNID%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_lbl IS TABLE OF tbl_parm.PARM_LBL%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_vlu IS TABLE OF tbl_parm.PARM_VLU%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_vlu_hint IS TABLE OF tbl_parm.VLU_HINT%TYPE INDEX BY BINARY_INTEGER;

My C code looks like :

typedef struct param
{
char lbl[30][81];
char vlu[30][256];
char typ[30];
ub8 seq_no[30];

[code].....

The way I invoke the stored procedure:

char command[250] = "begin
:retval := SSP_srq_parm_all(:srq_id,:unid,:parm_typ,:parm_lbl,:parm_vlu,:commit_flag,:vlu_hint,:create_flag);
end;";
OCIStmtPrepare2((OCISvcCtx *)svchp, (OCIStmt **)&(stmthp),
(OCIError *)errhp, (OraText *)command,

[code].....

OCIStmtExecute() fails with the above error.

View 3 Replies View Related

Precompilers, OCI & OCCI :: Connectivity Between C And Oracle?

Aug 12, 2008

Is it possible to connect with Oracle using C?

View 2 Replies View Related

Precompilers, OCI & OCCI :: How To Report Oracle Bug

Jan 30, 2009

How to report an Oracle bug? Is there webpage or email?

View 4 Replies View Related

Precompilers, OCI & OCCI :: How To Connect C++ And Oracle

Sep 17, 2008

My OS is Linux and I installed Oracle 10.2. Everything is fine.I can use sqlplus, exp, imp etc with no problem.Now I have created another linux user test in /home/test. I unzipped basic-10.2xxxxxx.zip (/home/test/instantclient_10_2) and exported LD_LIBRARY_PATH.I guess I have installed instant client in this way.

My testOra.cpp:

#include <occi.h>
int main()
{
return 0;
}

This test.cpp would not compile. It cannot find occi.

View 8 Replies View Related

Precompilers, OCI & OCCI :: Oracle Connection Not Getting Closed

Apr 26, 2010

I have Multi-threaded application using pro*c to connect to oracle.

I am using the following piece of code to create a connection to oracle database and preserver the context of created connection.

struct sqlca * tempSqlca = new sqlca;
struct sqlca & sqlca = * tempSqlca;
EXEC SQL BEGIN DECLARE SECTION;
SQL_CONTEXT localContext;

[code].....

I am using the following piece of code to close the connection to the oracle database, I am using the context created in the previous step and passing it to the below code(connection.context)to release the connection.

if (connection.context == 0 || connection.ca == 0)
return true;
// Multithreading: get the communication area of the context
struct sqlca & sqlca = *(connection.ca);
EXEC SQL BEGIN DECLARE SECTION;

[code].....

When the above code is executed there is no exception thrown but the connection is not getting close. I am using the V$SESSION system views to monitor the connection created.

I there anything I am missing in my code for the connection closing to fail.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Oracle 10i - Precompiler For Fortran?

Apr 28, 2010

I looked for a Precompiler for Fortran, could not find one. Does a precompiler for Fortran exist for Oracle 10i ? If no, would the precompiler for prior versions of Oracle work with Version 10i ?

View 2 Replies View Related

Precompilers, OCI & OCCI :: Keep Connected To Oracle Or It's Better Reconnect After Work?

Feb 27, 2012

I'm a beginner in the PRO*C and I have this issue/I have to maintain a multithreaded C++ PRO*C application and has the following structure

1) Application runs waiting for requirements
2) When detects a requirement it creates a Thread to work
3) The thread connects to Oracle with a EXEC SQL CONNECT :uid IDENTIFIED BY :pwd; instruction
4) Calls some anonymous calls to execute a stored procedure

EXEC SQL EXECUTE
BEGIN
commit;
:Status:=stored_procedure(:param1, :param2);
commit;
END;
END-EXEC;

5) If anything went wrong then issues a EXEC SQL ROLLBACK WORK RELEASE; then reconnects and the thread die
6) If everything was OK then the thread dies, but never called a EXEC SQL COMMIT WORK RELEASE; to disconnect from Oracle

I don't know why never the application disconnects from Oracle, maybe is for performance. Sometimes the application crashes and I believe that maybe the error is for never freeing the connections, the PROC compile line is this

proc parse=full sqlcheck=full user=system/manager cpp_suffix=cpp iname=source.pc include="..Hdr" include="C:ORACLEORA81ociinclude" include="C:ORACLEORA81precomppublic"

Which is the way to implement the connections?, connect and disconnect when done? or just keep the connection alive? Which way has better performance, connect and disconnect or just keep the opened connection?

View 1 Replies View Related

Precompilers, OCI & OCCI :: Recompile Required When Upgrading From Oracle 9i To 11g

Dec 14, 2011

We are considering upgrading our current system from Oracle 9i to 11g. The current operating system is SUSE Enterprise 9.

The 11g requirements say an update to SUSE Enterprise 10 is required to support the Oracle 11g installation.

Will I need to recompile my existing application programs which use pro C precompiler to create code that accesses the Oracle database when I upgrade the operating system and database?

View 1 Replies View Related

Precompilers, OCI & OCCI :: Oracle 8i Environment - Segmentation Fault?

Jul 15, 2008

I am running a job that is using Pro C code. I am running it on an Oracle 10g database with an Oracle 9 client on a UNIX platform. The code compiled fine. The job runs fine sometimes but other times it fails with a Segmentation Fault error.

I have the same job running in an Oracle 8i environment with no problems.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Find C Struct That Oracle Uses To Create A LogFile

Oct 15, 2010

I was asked to find the C struct that Oracle uses to create a logFile, or at least the C struct of a reg in that file,I've read a lot of material from many "know-at-all" who don't know anything.

View 9 Replies View Related

Precompilers, OCI & OCCI :: Write A Program Using Oci To Login Into Oracle Database?

Mar 28, 2006

I want write a program using oci to login into oracle database.Advance security option for the oracle server is set to kerberos authentication. Is it possible to login to the oracle database through olog() function.

Initial ticket is required in kerberos authentication. So is it also needed durinfg the login from my programme.

View 1 Replies View Related

Precompilers, OCI & OCCI :: Unable To Compile Pro C Code With Oracle 11g In Windows Env

Jul 15, 2010

I am trying to compile a .pc file. I am working with Oracle 11gR1 and windows env. I am able to create .c file from .pc file. I am able to produce .o file from .obj file. But i am not able to link it and produce .exe. My installation does not contain / precomp /demo folder.

View 7 Replies View Related

Precompilers, OCI & OCCI :: Connecting To Oracle Database With Instant Client 11.01.06

Mar 19, 2009

connecting to an oracle db with the instant client 11.01.06. I can connect to the db via other tools like sqldbx or SqlTools 1.5 which are also using oci. So now I tried it with c++ using Visual Studio 2005 SP1.

First I tried this

Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
con=env->createConnection("user","pwd","//servername:ip/mydb");
}

and got following error: "the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255".

So I tried:

Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
con=env->createConnection("user","pwd","tnsservice-name");
}

where tnsservice-name is the name I specified in the tnsnams.ora, and which I used with the other tools working fine -> same error.My username is only 4 long, so I thought it might have something to do with the string. So I tried:

Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
string user="user";
string passwd="pwd";
string db="tnsservice-name";
try{
con=env->createConnection(user,passwd,db);
AfxMessageBox("sucess");
}

now it returned the error "TNS:connect descriptor too long". Can't have anything to do with the .ora file, since it worked fine for the other tools. Plus it didn't matter if I renamed the .ora file or removed it from the TNS_ADMIN directory..So I searched a little more for a solution and so an example, where the the last argument is missing. So I tried

string user="user";
string pwd="pwd";
Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
con=env->createConnection(user,pwd);
}

It returns: "TNS: protocol Adapter error" which I somehow can understand, since the adapter doesn't know to wich db to connect.I also tried to use some frameworks like soci or otl but was never able to compile them... (link errors, unknown data types etc...).

View 1 Replies View Related

Precompilers, OCI & OCCI :: Multithread Program Hangs In Oracle Library On Itanium

May 13, 2005

my Multithread-Program hangs in an oracle library while passing a prepare statement (also if i try an EXEC SQL SELECT statement...). Something seems to be wrong in the Program, but i cant's find the Error.The Program is build with:

proc parse=none code=cpp mode=oracle hold_cursor=yes maxopencursors=20 THREADS=YES sqlcheck=full iname=Precomp_all.pc oname=Precomp_all.h

problem: a first thread creates the connection to oracle with one global context (type sql_context) in the connection object:

connect()
{
EXEC SQL WHENEVER SQLERROR DO ORASQL_ERROR();
EXEC SQL WHENEVER SQLWARNING DO ORASQL_WARNING();
EXEC SQL WHENEVER NOTFOUND DO ORASQL_NOP();
[code]....

View 3 Replies View Related

Precompilers, OCI & OCCI :: C++ Migrated From 32 Bit To 64 Bit / Getting Unrelated Sqlcode While Dealing With Oracle Database

Feb 22, 2013

Previously we had 32 bit C++. Now, we have migrated it to 64 bit. And our C++ programs interact with Oracle 10g DB.Our C++ program was working fine with 32 bit. But once after we migrate to 64 bit we are facing problem with one program which does FETCH(EXEC SQL FETCH SUBP1 INTO :new TabRec;) from Oracle DB. ie, We exit from a for loop in the C++ program when we get NOT FOUND(sqlca.sqlcode=1403) on executing the FETCH statement.

The sqlcode generated for NOT FOUND scenario is 1403. But, once after moving to 64 bit C++, we do not see the sqlcode 1403 instead we are seeing a different code 7124089117159473.

As the sqlcode is not 1403, our program does not exit from the for loop and goes on an infinite loop.Am I missing anything that makes me to not get the exact sqlcode?

View 9 Replies View Related

SQL & PL/SQL :: Regexp_SUBSTR On Array Returning No Value

Oct 1, 2013

I'm trying to query an array where we will have mathnames that have the follow format: variablemathname[00000]

have been digging around for a few days to try and simplify my existing query. As of right now i'm hacking it together to bring back the bracketed array value by using INSTR and SUBSTR. This works and gets me the correct results but I want to clean the code up by using regexp_SUBSTR.

In my reading up on regular expression I've tried to create my pattern by using [.] which I believe to be [any character]. I want it to start at the beginning of the string so I've used [^ and I only want the one occurrence so I've ended my expression with ]

I tried using the escape before my pattern as I know that [ is a metacharacter but I receive the same results.i'm trying to use to get the expression correct.

SELECT REGEXP_SUBSTR('variablemathname[00000]', '[.],[^,],') RESULT
FROM DUAL;

My expectation is it will bring back the following [00000] but the way it is written now is bringing back nothing.

View 10 Replies View Related

SQL & PL/SQL :: Function Returning Table Of Dynamic Structure

Apr 24, 2013

I have a requirement to be coded like this:

A function to return pl/sql table(cant use ref cursor) whose columns varies every time it runs i.e,

means
type pl_tab_type is object(col1 varchar2(1000), col2 varchar2(1000))
type pl_tab is table of pl_tab_type

func f return pl_tab
as
...
end;

note : pl_tab_type will vary for each run of function f

i.e.,for example, pl_tab_type can be changed to as follows:

type pl_tab_type is object(col1 varchar2(1000), col2 varchar2(1000),col3 varchar2(1000))

how to return pl/sql table of dynamic type from func,

View 12 Replies View Related

Pass Array To Oracle Stored Procedure?

Oct 3, 2010

I am passing a string from vb.net through oracle store procedure. String consists of varchar values for eg '123456;I|N,2424424;O|A'. But how can i call these string values into array using oracle stored procedure? After getting these values into array , i wanted to loop through these values.

View 1 Replies View Related

Forms :: Call Associative Array In Oracle Procedure?

Apr 25, 2013

I've one package in which one record is created. associative array is craeted on that record.create procedure on associative array.using forms 6i i want to call this procedue.(package_name.procedure_name(paramerters)). but my problem is what paramerter shuld i provide to excute the procedure?like PK_EXCEL_TO_DB.PR_DO_INSERT(LIST_ROUTE); but i am getting error while doing this.

CREATE OR REPLACE PACKAGE PK_EXCEL_TO_DB IS
TYPE ROUTE IS RECORD (COL_ROUTE VARCHAR2(255), VAL_ROUTE VARCHAR2(4000));
TYPE LIST_ROUTE IS TABLE OF ROUTE;
PROCEDURE PR_DO_INSERT(i_lData IN LIST_ROUTE);

[code]...

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved