Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 3 of 3 total |
How to insert a NULL value in a parameterized query? |
Tue, Feb 2 2010 12:34 PM | Permanent Link |
Dave | This has me stumped. One or more of the values for my Insert statement may be NULL. But
how can I get DBISAM 4 to accept it? I thought I could in this example clear QueryId parameter and that would store a NULL value for QueryId. But it gives me an error "quTMp: Field 'QueryId' is of an unknown type". So without modifying SQLStr for each set of parameters, how can I insert a NULL value when using parameters? TIA Dave SqlStr := 'Insert into Log '+ '(User_Id, Elapsed_Time, Query_Id, Msg_Type, Oper, Msg_Short, Msg_Long) '+ 'Values (:UserId,:ElapsedTime,:QueryId,:MsgType,:Oper,:MsgShort,:MsgLong)'; with quTmp do begin Sql.Text := SqlStr; ParamByName('UserId').AsInteger := aUserId; ParamByName('ElapsedTime').AsFloat := aElapsedTime; ParamByName('QueryId').Clear; //ParamByName('QueryId').AsInteger := aQueryId; ParamByName('MsgType').AsString := aMsgType; ParamByName('Oper').AsString := aOper; ParamByName('MsgShort').AsString := aMsgShort; ParamByName('MsgLong').AsString := aMsgLong; Prepare; end; quTmp.ExecSql; |
Tue, Feb 2 2010 12:45 PM | Permanent Link |
Dave | Ok, I found a solution to a prior post that Tim responded to.
I have to do: ParamByName('QueryId').DataType := ftInteger; ParamByName('QueryId').Clear; ParamByName('QueryId').Bound := true; which solves the problem. It would have been nice if this was in the manual. Dave Dave wrote: This has me stumped. One or more of the values for my Insert statement may be NULL. But how can I get DBISAM 4 to accept it? I thought I could in this example clear QueryId parameter and that would store a NULL value for QueryId. But it gives me an error "quTMp: Field 'QueryId' is of an unknown type". So without modifying SQLStr for each set of parameters, how can I insert a NULL value when using parameters? TIA Dave SqlStr := 'Insert into Log '+ '(User_Id, Elapsed_Time, Query_Id, Msg_Type, Oper, Msg_Short, Msg_Long) '+ 'Values (:UserId,:ElapsedTime,:QueryId,:MsgType,:Oper,:MsgShort,:MsgLong)'; with quTmp do begin Sql.Text := SqlStr; ParamByName('UserId').AsInteger := aUserId; ParamByName('ElapsedTime').AsFloat := aElapsedTime; ParamByName('QueryId').Clear; //ParamByName('QueryId').AsInteger := aQueryId; ParamByName('MsgType').AsString := aMsgType; ParamByName('Oper').AsString := aOper; ParamByName('MsgShort').AsString := aMsgShort; ParamByName('MsgLong').AsString := aMsgLong; Prepare; end; quTmp.ExecSql; |
Wed, Feb 3 2010 10:34 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Dave,
<< which solves the problem. It would have been nice if this was in the manual.>> I'll make a note to add this for the next DBISAM build. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |