IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Native SQL - Parameter Style General With Nulls


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Thu Mar 01, 2012 9:19 pm
Reply with quote

Hi,

I am writing a Native SQL Stored Procedure for both Insert and Update.

In my program, I have two input variables 1) New User Name and 2) Old User NAme. If I get the Values in both the fields then my SP would update the DB2 Table with New User Name. If there are no values in the Old User Name then an Insertion would happen.

I hope we can use PARAMETER STYLE GENERAL WITH NULLS in Native SQL. But I am not sure where we declare the Parameter Null indicators for the INput values. In COBOL we have the Parameter NULL indicators in Linkage Section using which, we can validate for nulls.

Could you please let me know how to check the NULL indicators in Native SQL.

EG:-
CREATE PROCEDURE EMP.NATIVE_SQL (
NEW_EMP_NAME IN CHAR(50)
, OLD_EMP_NAME IN CHAR(50)
)
LANGUAGE SQL
WLM ENVIRONMENT PRODWLM
MODIFIES SQL DATA
PARAMETER STYLE GENERAL WITH NULLS

Start: ...............

>> Checking for NEW_EMP_NAME for NULL would be suffice here. Please advise.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 07, 2012 7:20 am
Reply with quote

Hello,

I believe one of us is confused. . .

If you want to check some value in the program (field n a file or working-storage etc) for "NULL", i know of no way to do this - there is no NULL value in the ebcdic value table. Every value from x'00' to x'FF' is valie and is NOT a null value.

If you want to insert a null value, you would set the null-indicator to -1 which tells sql this value is numm (contains no value at all).

Possibly i misunderstand?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 07, 2012 4:23 pm
Reply with quote

how about :

IF NEW_EMP_NAME is NULL then SIGNAL ...;

IF OLD_EMP_NAME is NULL then
insert ...
ELSE
update ...
;
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using the Jobname parameter in a Qual... ABENDS & Debugging 1
No new posts Demand with DEADLINE TIME parameter CA Products 4
No new posts Option DYNALLOC second parameter. DFSORT/ICETOOL 11
No new posts Writing the output file name from a p... JCL & VSAM 7
No new posts Reference for COND parameter. JCL & VSAM 1
Search our Forums:

Back to Top