strings in embedded pl/sql
Date: Fri, 28 Jan 2000 10:17:21 -0800
Message-ID: <19395994.49ccae90_at_usw-ex0107-056.remarq.com>
Here is a function in my Pro*c program. The string size is passed in from the calling function.
################################################int id_len = 9;
EXEC SQL BEGIN DECLARE SECTION;
char *my_string = (char *) malloc(id_len * string_size + 1); EXEC SQL END DECLARE SECTION; memset(my_string, ' ', id_len * string_size+1);
EXEC SQL EXECUTE
BEGIN
test_pkg.func_fill_string(:my_string);
END;
END-EXEC;
....
free(my_string);
#####################################
Here is my problem: I call this function and pass is a particular string_size (say like 15). Now I can continually call this function as much as I like, as long as I pass in 15. As soon as I pass in a different string_size (like 8), the program cores when it call the free statement.
So my question is: Do I have to somehow "UNDECLARE" my string first before I free the memory? Is there some other pl/sql call I need to make first? Or is dynamically creating and deleting memory using Oracle's Pro*C even "syntatically" allowed? (the compiler doesn't complain...)
Any help/comments/ideas/web links would be greatly appreciated.
NivekD
- Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free!
