Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Values to Null via a Program

Status
Not open for further replies.

paulnnosh

MIS
Mar 25, 2004
32
Hi Guys,

I have been given these two questions in a test prior to an interview. I'm not a DB2 DBA but a programmer so I don't know why these questions are in there! Can anyone help with the answers please?

Other than using SET NULL, how would you place the NULL values in table columns from a program?



Where would you find fields containing SQL return code, number of rows affected etc after execution of a DB2 update in a program?
 
Hi Paul,
Not wishing to quibble (which always means someone's is going to quibble) but you say that you've been given these two questions - and there's only one question!

Anyway, on to the question.... SET NULL is one way, the other is to set the associated null indicator to reflect the fact that the value is indeed null. I'm not sure how this is done in other languages but from a SQL point of view, you supply the field value (blank) followed by a small integer which contains a value of -1.

I could go into further detail, but would imagine that if it is an interview question, then saying that you would set the null indicator to minus 1 would suffice.

I add the warning that my DB2 experience is heavily mainframe based (although I've done a bit with Access and UDB2) so would welcome advice from my colleagues here, if this is not pertinent to other platforms and languages.

Regards,

Marc
 
Paul,

as regards your first question, the way mark describes by the use of nul indicators being set to -1, is how I would do it. Mullins has something on it here


In answer to your second question, I believe it to be the SQLCA, which they are referring. More info here.


Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top