Recent

Author Topic: SQLQuery: How to assign a NULL value to a param?  (Read 4532 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
SQLQuery: How to assign a NULL value to a param?
« on: June 03, 2021, 04:05:41 am »
How to do it?

Code: Pascal  [Select][+][-]
  1. SQLQuery1.ParamByName('my_field').AsFloat := NULL;
  2.  

bpranoto

  • Full Member
  • ***
  • Posts: 103
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #1 on: June 03, 2021, 05:21:13 am »
Code: Pascal  [Select][+][-]
  1. SQLQuery1.ParamByName('my_field').Clear

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #2 on: June 03, 2021, 05:55:19 am »
I need the database field to have a null value.

egsuh

  • Hero Member
  • *****
  • Posts: 782
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #3 on: June 03, 2021, 06:25:23 am »
Try following --- I found this but haven't tried myself... please let us know the result  :D

SQLQuery1.ParamByName('my_field').Value := null;

bpranoto

  • Full Member
  • ***
  • Posts: 103
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #4 on: June 03, 2021, 06:48:31 am »
I need the database field to have a null value.

Have you tried what I posted before?

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #5 on: June 03, 2021, 06:59:23 am »
It works, thanks.

bum_bum

  • Newbie
  • Posts: 3
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #6 on: June 07, 2021, 10:20:44 pm »
Try following --- I found this but haven't tried myself... please let us know the result  :D

SQLQuery1.ParamByName('my_field').Value := null;
Perhaps it will be more correct
SQLQuery1.ParamByName('my_field').IsNull := True;

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 952
    • Lebeau Software
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #7 on: June 07, 2021, 11:18:23 pm »
Perhaps it will be more correct
SQLQuery1.ParamByName('my_field').IsNull := True;

TParam.IsNull is read-only.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

egsuh

  • Hero Member
  • *****
  • Posts: 782
Re: SQLQuery: How to assign a NULL value to a param?
« Reply #8 on: June 08, 2021, 03:11:56 am »
I confirmed

Qr.params[ l ].value := null;

works.

 

TinyPortal © 2005-2018