I want to ask how to pass the '30','31','32' to SQL WHERE IN clause For example

EXEC SQL DECLARE abcd CURSOR FOR SELECT Consignment FROM Transaction WHERE order_type IN (:dest)

where dest will hold the value '30','31','32'.

I have tried as above example but it is not working SQL did not return any result.

.I also would like to tell you,here dest is C string like, char dest[20]={"'30','31','32'."}, which i am passing as order_type IN (:dest). – pri 19 secs ago edit

Recommended Answers

All 3 Replies

I think your use of a double-quoted string is the problem. IE, the order_type in (:dest), should be order_type in ('30','31','32'). The double quotes are likely the cause of your issue. Your string "dest[20]" can't be used this way. Try using this: dest[3][3] = {"30","31","32"}. Also, how are you binding the data to the placeholder :dest?

Thanks for your reply,it works fine. As i need to form double dimension array by copying individual string like 30,31,32 ( here char* token=30 and so on) so in this case can i use char * dest[3], but it seems to be it doesn't work. Please suggest.

if we initialize the array like,dest[3][3] = {"30","31","32"} then there is no issue and it works fine but while creating the array as shown in below snippet we can't pass the same by :dest as it will require index to access the individual string.
char dest[3][3]={0,};
strcpy(dest[0],"31");
strcpy(dest[1],"32");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.