0

I have this query:

 SELECT * FROM table_1 WHERE (`update_column` = (DATE_SUB(curdate(), INTERVAL 10 DAY)))

It works normally, I want to change 10 day to parameter and pass value of it through adapter, I'm using query builder, with query in adapter:

FillBy_sub_date

Which i want to be like:

 SELECT * FROM table_1 WHERE (`update_column` = (DATE_SUB(curdate(), INTERVAL @_days DAY)))

And i want to pass day value with the following method:

  Me.table_1Adapter.FillBy_sub_date(Me.dataset.table_1, 5) 

5 is the number of day which i wont to pass to query

Problem: when i change number 10 to @_days mysql error showing

Error in list of function arguments: '_days' not recognized. Unable to parse query text.

image

Amessihel
  • 5,891
  • 3
  • 16
  • 40
abbas
  • 33
  • 4
  • Remove backticks from `INTERVAL` keyword. – Dark Knight Sep 15 '19 at 21:16
  • same error still appear , the problem with parameter not with INTERVAL , because when set ( INTERVAL 10 day ) it work normally , Error in list of function arguments: 'dd' not recognized. Unable to parse query text. where dd is @dd that passing to query instead of 10 day – abbas Sep 16 '19 at 08:35

1 Answers1

0

there is more then one way , first create procedure in your mysql database with parameter let call it "return_after_some_days" your query is correct so put it inside procedure

  1. create procedure

    CREATE PROCEDURE return_after_some_day (in param1 INT)
    BEGIN
    SELECT * FROM `table` where `update_column` = (DATE_SUB(curdate(), INTERVAL param1 day  ));
    

    end;

  2. then go to your builder wizard and add query to table adapter

  3. select use existing stored procedure
  4. from list select your procedure name which is (return_after_some_days)
  5. select tabular date and set name of fill method
  6. go inside your code and call your method name from data adapter like

Me.table_1Adapter.name_of_method_that_call_procedure(Me.dataset.table_1, 5)

number 5 will be pass to proceuder

Abbas Mohammed
  • 65
  • 1
  • 12