Parameters in PRO*C functions

From: Tommy Wareing <p0070621_at_oxford-brookes.ac.uk>
Date: 8 Mar 1994 10:40:17 -0600
Message-ID: <CMCqDy.4Bw_at_uk.ac.brookes>


Is it safe to use function parameters directly as bind variables in Oracle code?
eg.

	void find_kiddies(emp_name)
	EXEC SQL BEGIN DECLARE SECTION;
	char *emp_name;
	EXEC SQL END DECLARE SECTION;

{
EXEC SQL DECLARE kiddies CURSOR FOR SELECT children FROM emp WHERE emp.name=:emp_name; ... or must the variable be copied into local storage first? void find_kiddies(e) char *e;
{
EXEC SQL BEGIN DECLARE SECTION char emp_name[15]; EXEC SQL VAR emp_name IS STRING; EXEC SQL END DECLARE SECTION EXEC SQL DECLARE kiddies CURSOR FOR SELECT children FROM emp WHERE emp.name=:emp_name; strcpy(emp_name, e); ...

As far as I'm concerned these should be functionally identical, and the first seems cleaner. But, as far as I can tell, the cursor is never rebound should emp_name (the pointer, not the string it points to) change.

Anyone else met this sort of thing?

--
 _______________ ________________________ _____________
< Tommy Wareing X p0070621_at_brookes.ac.uk X 0865-483389 >
 =============== ======================== =============
/ If it's something I want, then it's something I need.\
| I wasn't built for comfort, I was built for speed!    |
\    -- Jim Steinman, Bad for Good                     /
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Tue Mar 08 1994 - 17:40:17 CET

Original text of this message