문제

Is it safe to use same host variable for both input and output in an embedded SQL query ? I'm using C and DB2 static embedded SQL.

Example:

EXEC SQL 
     SELECT someCol 
     INTO :someHostVar 
     FROM SomeTable 
     WHERE :someHostVar = someOtherCol;
도움이 되었습니까?

해결책

Yes, you can do that. The value of someHostVar will be overwirtten and contain whatever the value of someCol is for this particular predicate - unless the value of someCol happens to be NULL at which point it the host variable remains unchanged.

Even though you can do this, I would suggest to you that this is not a good practice because someHostVar may end up containing values for different columns of the same table - too easy to screw up.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top