0

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

2
Contributors
3
Replies
28
Views
2 Years
Discussion Span
Last Post by can-mohan
1

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?

0

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.

0

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");

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.