473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need Help on Pro-C

Hello Friends.. I am working on some Pro-C program using Dynamic SQL. I am fetching a set of values and storing those in an host variable array of datatype long. The fetching into the array is working fine. But when I use the in correlated subquery having "NOT IN" and "IN" clause, it behaves differently. For "IN" clasue, the array works fine, but for "NOT IN" clause, it does not work. For example, I have created the following small piece of code.

I have long array MyNum[3]. The Table TEST_LOC has 6 records, 3 records have SerialNum same as those given in MyNum array. When I use "IN" clause, 3 records are inserted in TEST_LOC1 Table. But when I use "NOT IN" clause, it inserts 15 records with duplicate values. I am unable to solve it till now.

Can someone please help me on this? Thanks a lot..
--Sain

--------------------------------------- Sample Pro-C Code -----------------------------
/* This program uses dynamic SQL Method 2 to insert rows into second table from first table. */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

EXEC SQL INCLUDE "sqlca.h";
EXEC SQL INCLUDE "oraca.h";
EXEC ORACLE OPTION (ORACA=YES);

VARCHAR dynstmt[80];

void main()
{
EXEC SQL BEGIN DECLARE SECTION;
char connStr[101]="";
char TName[20] = "TEST_LOC1";
long MyNum[3] = {18, 21, 12};
EXEC SQL END DECLARE SECTION;

oraca.orastxtf = ORASTFERR;
strcpy(connStr, "psoproj/psoproj@epsnsdev");

EXEC SQL CONNECT :connStr;
if(sqlca.sqlcode != 0)
{ printf("ERROR: Unable to connect to oracle SQLCODE: %d", sqlca.sqlcode);
exit(1);
}
puts("\nConnected to Oracle.\n");

sprintf((char *)dynstmt.arr, "INSERT INTO %s select * from TEST_LOC a1
WHERE a1.SERIALNUM IN (:v1)", TName);

// sprintf((char *)dynstmt.arr, "INSERT INTO %s select * from TEST_LOC a1
// WHERE a1.SERIALNUM NOT IN (:v1)", TName);

dynstmt.len = (unsigned short)strlen((char *)dynstmt.arr);
puts((char *) dynstmt.arr);

EXEC SQL PREPARE S FROM :dynstmt;
EXEC SQL EXECUTE S USING :MyNum ;

printf("\n Value of sqlcode:%d \n", sqlca.sqlcode);

EXEC SQL COMMIT WORK RELEASE;
puts((char *)"\nHave a good day!\n");
exit(0);
}
------------------------- End of Sample Code ------------------------

The Tables TEST_LOC and TEST_LOC1 have same table structure:
CREATE TABLE TEST_LOC
( NAME VARCHAR2(30 BYTE) NOT NULL,
SERIALNUM NUMBER NOT NULL,
ADDDT DATE DEFAULT SYSDATE NOT NULL
);
Apr 4 '07 #1
0 1896

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Mary Ellen Curtin | last post by:
arrgh. Because I can't afford a new system right now, I'm running a hamster-powered Pentium 166, 64 M RAM, Win 95. I've been using Dreamweaver3, but I've now reached my limit. *rends DW3 with teeth...
4
by: newgenre | last post by:
My system was updated by a shop now out of business. They installed Windows XP-Pro on it but there is no IIS. I am trying to add Visual Basic.Net to my system. Is there a way to DL IIS for my...
6
by: darrel | last post by:
(Sincere apologies for crossposting. I posted it in vs.net ide, but then realized that group gets little to no traffic these days. I was hoping to get some insight on this before the weekend.) I...
13
by: Howard Kaikow | last post by:
I just visited the MSFT web site and saw the comparison/pricing of the different VS 2005 versions. I was looking for a statement of the system requirements for VS Pro and VSTO, could not find. ...
5
by: HotRod | last post by:
I am new to this so please go easy. We currently have some students doing some work on some web based tracking documents for us. They are currently using VB .net to develop what we requested....
0
by: kumar77 | last post by:
I have some doubts in Pro*C: 1)after precompiling a pro*C program how will be the output will be displayed i.e. how the SELECT statements are replaced by C stmts? 2)How to debug the Pro*C...
26
by: empriser | last post by:
#define XLOG( ... ) \ do{ \ sprintf( SysBuf, " ", curtime(), __FILE__ , __LINE__ , __FUNCTION__ ); \ sprintf( SysBuf + strlen( SysBuf ), __VA_ARGS__ ); \ xlog( SysBuf ); \ }while(0) I...
1
by: DR | last post by:
What ports do i need to unblock on client and server (running msvsmon.exe) to debug remotely from my client box with visual studio 2005 pro? When I attach to remote process a connection shows up...
8
by: Mr. R | last post by:
Hi I need to set up a server that supports ASP.NET. I will have it in my home and run on and off for demo projects. The problem is that I don't have then money to by Windows Server 2003 or...
1
by: vfpgood | last post by:
Hello,guy! My work is to design labels. Can anyone introduce a simple, easy and professional system for bar code label design . Set design drawings, generate bar code generation and batch...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.