Error 1582 incorrect parameter count in the call to native function round

Error 1582 incorrect parameter count in the call to native function round public function search(Request $request) ‘max:191|min:4’,n ‘city’ => »,n ‘lat’ => »,n ‘lang’ => »,n ‘price_from’=> ‘numeric’,n ‘price_to’ => ‘numeric’,n ‘area_from’ => ‘numeric’,n ‘area_to’ => ‘numeric’,n ‘num_of_person_from’=> ‘numeric’,n ‘num_of_person_to’ => ‘numeric’,n n ];nn $validator = Validator::make($request->all(), […]

Содержание

  1. Error 1582 incorrect parameter count in the call to native function round
  2. Error 1582 incorrect parameter count in the call to native function round
  3. Error occurs when saving a point — «Incorrect parameter count in the call to native function ‘ST_GeomFromText’» #138
  4. Comments
  5. Error 1582 incorrect parameter count in the call to native function round

Error 1582 incorrect parameter count in the call to native function round

public function search(Request $request) < n

$rules = [n ‘name’ => ‘max:191|min:4’,n ‘city’ => »,n ‘lat’ => »,n ‘lang’ => »,n ‘price_from’=> ‘numeric’,n ‘price_to’ => ‘numeric’,n ‘area_from’ => ‘numeric’,n ‘area_to’ => ‘numeric’,n ‘num_of_person_from’=> ‘numeric’,n ‘num_of_person_to’ => ‘numeric’,n n ];nn $validator = Validator::make($request->all(), $rules);nn if ($validator->fails())n return ApiController::respondWithError(validateRules($validator->errors(), $rules));n $gr_circle_radius = 6371;n $max_distance = 2;n $lat = $request->lat;n $lng = $request->lang;n n $data = Hole::select(DB::raw(‘*, ( 6367 * acos( cos( radians(‘.$lat.’) ) * cos( radians( lat ) ) * cos( radians( lang ) — radians(‘.$lng.’) ) + sin( radians(‘.$lat.’) )* sin( radians( lat ) ) ) ) AS distance’))n ->having(‘distance’, ‘ orderBy(‘distance’)->with(‘photos’)n ->orwhere(‘city’, $request->city)n ->orwhere(‘name’, $request->name)n ->orWhereBetween(‘price’, [$request->price_from, $request->price_to])n ->orWhereBetween(‘area’, [$request->area_from, $request->area_to])n ->orWhereBetween(‘person_count’, [$request->num_of_person_from, $request->num_of_person_to])n ->get();n n n >);nn return ApiController::respondWithSuccess($data);nn>n n

Are you sure your form input name is «lang» and not «long» for longitude? If it’s wrong, then $lng is null. n

Several places you’re using lat instead of $lat? n

Источник

Error 1582 incorrect parameter count in the call to native function round

MySQL 5.1 Manual
DATEDIFF(expr1,expr2)

DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

Вы не обратили внимание, там написано (Transact-SQL)
Знаете, что это означает? Что данный код допустим в Transact-SQL.
А Transact-SQL — это диалект SQL, используемый в Microsoft SQL Server.

я вообще не понимаю, зачем Вы смотрите в msdn описание команд MS SQL server, если Вы им не пользуетесь.
MS SQL это совсем не тоже самое, что MySQL!

И, надеюсь, для Вас уже не секрет, что в разный СУБД (MS SQL, Oracle, MySQL, PostrgeSQL, Firebird) используются РАЗНЫЕ диалекты SQL.
Особенно это касается работы с полями DATE, TIME, обработкой строк и т.д. и т.п.
Поэтому SQL код для Oracle может не работать на MySQL, или, код от MS SQL может не работать на MySQL (как в вашем случае).

Источник

Error occurs when saving a point — «Incorrect parameter count in the call to native function ‘ST_GeomFromText’» #138

Hi! I decided to try your package in PHPUnit:

an error occurs when running the test:

SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function ‘ST_GeomFromText’ (SQL: insert into points ( point ) values (ST_GeomFromText(POINT(-73.9878441 40.7484404), 0, ‘axis-order=long-lat’))

but if you delete the line «, ‘axis-order=long-lat’ « in the file SpatialExpression.php then saving will work fine, see screenshot:

I also tried running the raw query leaving the string «, ‘axis-order=long-lat’ « and it worked without an error:

The text was updated successfully, but these errors were encountered:

What version of MySQL are you using? axis-order was added in MySQL 8.

Also, note that the query reported in the error is different than the one you tested (notice the quotes inside ST_GeomFromText() )

@grimzy
Thanks for the answer!

What version of MySQL are you using?

The problem was using MariaDb (delivered by default in XAMPP)
Changing to MYSQL 8 solved the problem

It would be good to add mariadb compatibility 🙂

@slave2anubis , also same version of MariaDB?

I’d love to add better MariaDB compatibility. Did you have any issues with the migrations?

For now, if this is blocking you, I believe that «upgrading» to your database engine to MySQL 8 or downgrading the package to the v2.x branch could fix your issue.

Sorry but i removed Mariadb and added Mysql server. The version was 10.4.xx i am running on a linux machine with default mariadb packages.

I’m on MySQL 5.7 — what is the max supported version of this package for that version of MySQL?

I’m running MariaDB 10.3.12 (via WAMP 3.1.7) and i have the same issue. Migration runs just fine for me. The previous version of your package works just fine.

@mwargan , for MySQL 5.7, please use v2.x.x of grimzy/laravel-mysql-spatial .

For now I recommend MariaDB users to also stick to v2.x.x of this package.

For now I recommend MariaDB users to also stick to v2.x.x of this package.

It solved my issue (can’t install MySQL on my shared hosting. )

I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

And the src/Eloquent/SpatialExpression.php file:

However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

Yes! It’s also quite difficult to maintain at the moment. Any suggestions on how to implement this?
I was thinking maybe we could have Traits for each database engine (mysql 5.6, 5.7, 8, Maria DB. ). What do you think?

I was thinking maybe we could have Traits for each database engine (mysql 5.6, 5.7, 8, Maria DB. ). What do you think?

That makes sense…I think. Are you talking about a trait for the EloquentSpatialExpression class to use? or the ElquentSpatialTrait for end users to place on their models?

As a user of the package, it would be great for the package to auto-detect the database engine and use the appropriate class internally, so I don’t have to choose a MySQL vs. MariaDB model trait.

If auto-detecting the engine is too troublesome, maybe a database engine config key/value would work?

I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

And the src/Eloquent/SpatialExpression.php file:

However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

In my case, I had to override the SpatialTrait.php as well.

Had the same problem with Mariadb 10.3 and Laravel 8 . The solution from @andrewminion-luminfire fixes the problem. But what I did is made another trait AppHelpersSpatialSpatialTrait and override performInsert method that uses my own SpatialExpression instead of the one from this package. This way, I have more control over everything and I can override anything that I might need to in the future.

Version 5.0.0 of this library ( composer require grimzy/laravel-mysql-spatial:^5.0 ) works for me using Laravel 8 and MariaDB 10.5.

@jasonmm worked for me as well, thank you! (and i’m just extremely glad i didn’t have to go down some of these other rabbit holes)

I Had the same problem with HedeiSql and Laravel 8 ??
«errors»: «SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function ‘ST_GeomFromText’ «

Version 5.0.0 of this library ( composer require grimzy/laravel-mysql-spatial:^5.0 ) works for me using Laravel 8 and MariaDB 10.5.

That solved the issue for me as well, Laravel 8, on 10.3.29-MariaDB and PHP 7.4.20

I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

And the src/Eloquent/SpatialExpression.php file:

However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

Источник

Error 1582 incorrect parameter count in the call to native function round

    • johnbow
      Newbie

    • InsiteFX
      Super Moderator

  • As @ Narf said you should update to the newest version of CodeIgniter for Security Reasons.

      Narf
      Me

  • (01-24-2018, 01:14 PM) php_rocs Wrote: @ Narf , I agree but I figured that if you are going to be running an old version at least have the last old version.

    That doesn’t make any difference, especially 2+ years after EOL. Even if they listen, so what? They’ll just falsely think it’s all ok now .

    (01-24-2018, 01:14 PM) php_rocs Wrote: Also, I’m guessing that maybe he is working on an old system so upgrading may not be in the immediated future (hopefully the forseable future).

      php_rocs
      Administrator

  • I agree with you but every developer may not be in a position where they can come in and make drastic changes (unlike you and me =) ). Sometimes it has to be baby steps. I’m quite sure both of us has many stories we could tell where it was so obvious that an upgrade was needed but management was being a pain and didn’t fully understand the impact (I even worked on a project where I was more experienced then the Team lead and had to indirectly lead the team and upgrade the code). In those scenarios you have to do what you can until you can get to the point where the software can be made current. That is why sometimes it worth saying hey do this at least until you can do that.

      Narf
      Me

  • I agree with you but every developer may not be in a position where they can come in and make drastic changes (unlike you and me =) ). Sometimes it has to be baby steps. I’m quite sure both of us has many stories we could tell where it was so obvious that an upgrade was needed but management was being a pain and didn’t fully understand the impact (I even worked on a project where I was more experienced then the Team lead and had to indirectly lead the team and upgrade the code). In those scenarios you have to do what you can until you can get to the point where the software can be made current. That is why sometimes it worth saying hey do this at least until you can do that.

    It’s an update, not a rewrite — there’s nothing drastic about it and management shouldn’t even be asked about this. The only reason management becomes a PITA with this is because when you ask them how to do your own job, they assume it’s a big deal with meaningful impact on business operations (oh have I got many stories about that, indeed).

    Let me tell you about the last time I updated CI for a company . Granted, knowing CI inside out, this should be like a walk in the park for me, but even if you double the time it takes, it’s no big deal for anybody.

    They were running 2.0.something, with a bulk of custom patches on top of it (some of those, they claimed was for specific stuff that CI couldn’t do, which was false — they had shot themselves in their collective foot for nothing). That wasn’t one small-to-medium size project, but 3 separate ones, each having at least 100 controllers. Copy-pasta all over the place. And I don’t use IDEs, so I couldn’t do my colleagues favorite «global search and replace» — every single change, done by hand, not even auto-complete.

    I spent 2 days extracting those custom patches into extensions, and completely reverting the parts that were no longer necessary, then the upgrade itself took 3 hours.

    Seriosly, it takes more time to QA than to actually do it. There’s no excuses .

    Источник

  • 1. Описание ошибки

    1 queries executed, 0 success, 1 errors, 0 warnings
    
    Запрос: выберите t.`name`, date_format (str_to_date ('2015'), '%Y') as statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS ...
    
     код ошибки:  1582
    Incorrect parameter count in the call to native function 'str_to_date'
    
     Время выполнить: 0 sec
     Время передачи: 0 sec
     Общее время: 0 sec
    

    2. Причина ошибки

    SELECT 
      t.`name`,
      DATE_FORMAT(STR_TO_DATE('2015'), '%Y') AS statisDate,
      ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
    FROM
      t_stu_info t 
    WHERE 1 = 1 
      AND DATE_FORMAT(t.statisDate, '%Y') = '2015' 
    UNION
    ALL 
    SELECT 
      t.`name`,
      DATE_FORMAT(STR_TO_DATE('2014'), '%Y') AS statisDate,
      ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
    FROM
      t_stu_info t 
    WHERE 1 = 1 
      AND DATE_FORMAT(t.statisDate, '%Y') = '2014'

    Формат MySQL, встроенный -ин функция str_to_date: str_to_date (строка, формат даты);
    в этом запросе SQL IS str_to_date (String), что вызывает ошибку сообщать об ошибке

    3. Решение

    Измените оператор SQL запроса SQL

    SELECT 
      t.`name`,
      DATE_FORMAT(STR_TO_DATE('2015','%Y'), '%Y') AS statisDate,
      ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
    FROM
      t_stu_info t 
    WHERE 1 = 1 
      AND DATE_FORMAT(t.statisDate, '%Y') = '2015' 
    UNION
    ALL 
    SELECT 
      t.`name`,
      DATE_FORMAT(STR_TO_DATE('2014','%Y'), '%Y') AS statisDate,
      ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
    FROM
      t_stu_info t 
    WHERE 1 = 1 
      AND DATE_FORMAT(t.statisDate, '%Y') = '2014'

    <script type=»text/javascript»> $(function () { $(‘pre.prettyprint code’).each(function () { var lines = $(this).text().split(‘n’).length; var $numbering = $(‘<ul/>’).addClass(‘pre-numbering’).hide(); $(this).addClass(‘has-numbering’).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘<li/>’).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

    Error 1582 incorrect parameter count in the call to native function datediff

    MySQL 5.1 Manual
    DATEDIFF(expr1,expr2)

    DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

    Вы не обратили внимание, там написано (Transact-SQL)
    Знаете, что это означает? Что данный код допустим в Transact-SQL.
    А Transact-SQL — это диалект SQL, используемый в Microsoft SQL Server.

    я вообще не понимаю, зачем Вы смотрите в msdn описание команд MS SQL server, если Вы им не пользуетесь.
    MS SQL это совсем не тоже самое, что MySQL!

    И, надеюсь, для Вас уже не секрет, что в разный СУБД (MS SQL, Oracle, MySQL, PostrgeSQL, Firebird) используются РАЗНЫЕ диалекты SQL.
    Особенно это касается работы с полями DATE, TIME, обработкой строк и т.д. и т.п.
    Поэтому SQL код для Oracle может не работать на MySQL, или, код от MS SQL может не работать на MySQL (как в вашем случае).

    Источник

    Error occurs when saving a point — «Incorrect parameter count in the call to native function ‘ST_GeomFromText’» #138

    Comments

    Art-Mas commented Apr 25, 2020

    Hi! I decided to try your package in PHPUnit:

    an error occurs when running the test:

    SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function ‘ST_GeomFromText’ (SQL: insert into points ( point ) values (ST_GeomFromText(POINT(-73.9878441 40.7484404), 0, ‘axis-order=long-lat’))

    but if you delete the line «, ‘axis-order=long-lat’ « in the file SpatialExpression.php then saving will work fine, see screenshot:

    I also tried running the raw query leaving the string «, ‘axis-order=long-lat’ « and it worked without an error:

    The text was updated successfully, but these errors were encountered:

    grimzy commented Apr 25, 2020

    What version of MySQL are you using? axis-order was added in MySQL 8.

    Also, note that the query reported in the error is different than the one you tested (notice the quotes inside ST_GeomFromText() )

    Art-Mas commented Apr 26, 2020 •

    @grimzy
    Thanks for the answer!

    What version of MySQL are you using?

    The problem was using MariaDb (delivered by default in XAMPP)
    Changing to MYSQL 8 solved the problem

    It would be good to add mariadb compatibility 🙂

    dacianb commented Apr 26, 2020

    grimzy commented Apr 26, 2020

    @slave2anubis , also same version of MariaDB?

    I’d love to add better MariaDB compatibility. Did you have any issues with the migrations?

    For now, if this is blocking you, I believe that «upgrading» to your database engine to MySQL 8 or downgrading the package to the v2.x branch could fix your issue.

    dacianb commented Apr 26, 2020

    Sorry but i removed Mariadb and added Mysql server. The version was 10.4.xx i am running on a linux machine with default mariadb packages.

    mwargan commented May 2, 2020

    I’m on MySQL 5.7 — what is the max supported version of this package for that version of MySQL?

    blindpenguin commented May 2, 2020

    I’m running MariaDB 10.3.12 (via WAMP 3.1.7) and i have the same issue. Migration runs just fine for me. The previous version of your package works just fine.

    grimzy commented May 2, 2020

    @mwargan , for MySQL 5.7, please use v2.x.x of grimzy/laravel-mysql-spatial .

    grimzy commented May 2, 2020

    For now I recommend MariaDB users to also stick to v2.x.x of this package.

    RomainMazB commented Aug 28, 2020

    For now I recommend MariaDB users to also stick to v2.x.x of this package.

    It solved my issue (can’t install MySQL on my shared hosting. )

    andrewminion-luminfire commented Sep 21, 2020

    I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

    And the src/Eloquent/SpatialExpression.php file:

    However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

    grimzy commented Sep 21, 2020

    However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

    Yes! It’s also quite difficult to maintain at the moment. Any suggestions on how to implement this?
    I was thinking maybe we could have Traits for each database engine (mysql 5.6, 5.7, 8, Maria DB. ). What do you think?

    andrewminion-luminfire commented Sep 28, 2020

    I was thinking maybe we could have Traits for each database engine (mysql 5.6, 5.7, 8, Maria DB. ). What do you think?

    That makes sense…I think. Are you talking about a trait for the EloquentSpatialExpression class to use? or the ElquentSpatialTrait for end users to place on their models?

    As a user of the package, it would be great for the package to auto-detect the database engine and use the appropriate class internally, so I don’t have to choose a MySQL vs. MariaDB model trait.

    If auto-detecting the engine is too troublesome, maybe a database engine config key/value would work?

    Sonicelo commented Oct 20, 2020

    I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

    And the src/Eloquent/SpatialExpression.php file:

    However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

    In my case, I had to override the SpatialTrait.php as well.

    nazmulpcc commented Apr 16, 2021

    Had the same problem with Mariadb 10.3 and Laravel 8 . The solution from @andrewminion-luminfire fixes the problem. But what I did is made another trait AppHelpersSpatialSpatialTrait and override performInsert method that uses my own SpatialExpression instead of the one from this package. This way, I have more control over everything and I can override anything that I might need to in the future.

    jasonmm commented Apr 19, 2021

    Version 5.0.0 of this library ( composer require grimzy/laravel-mysql-spatial:^5.0 ) works for me using Laravel 8 and MariaDB 10.5.

    tonsoflaz2 commented May 23, 2021

    @jasonmm worked for me as well, thank you! (and i’m just extremely glad i didn’t have to go down some of these other rabbit holes)

    AmineDevF commented Jun 10, 2021

    I Had the same problem with HedeiSql and Laravel 8 ??
    «errors»: «SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function ‘ST_GeomFromText’ «

    lanz1 commented Jul 19, 2021

    Version 5.0.0 of this library ( composer require grimzy/laravel-mysql-spatial:^5.0 ) works for me using Laravel 8 and MariaDB 10.5.

    That solved the issue for me as well, Laravel 8, on 10.3.29-MariaDB and PHP 7.4.20

    asdrubalp9 commented Apr 16, 2022

    I’m using v4.0 for Laravel 8 compatibility, and override just the one file to fix MariaDB compatibility:

    And the src/Eloquent/SpatialExpression.php file:

    However, it would be great to have separate MySQL vs. MariaDB files, or conditionally return the spatial query based on the actual database engine.

    Источник

    Используйте функцию DATEDIFF с mySQL

    Просто попробуйте использовать встроенную функцию DATEDIFF в SQL с моим следующим запросом:

    Сообщение об ошибке:
    #1582 — Incorrect parameter count in the call to native function ‘DATEDIFF’ .

    Что мне не хватает?

    Отметьте свою версию MySQL.

    Ошибка не требует пояснений

    Похоже, вы знакомы с функцией DATEDIFF в SQL Server, которая принимает три аргумента. MySQL DATEDIFF принимает только два аргумента. Избавьтесь от ‘DAY’, , и все будет хорошо. Удачи.

    Bob Jarvis — Reinstate Monica

    Из документов MySQL:

    РАЗНДАТ () возвращает expr1 — expr2, выраженное как значение в дней от одной даты до другой. expr1 и expr2 — это выражения даты или даты и времени. В расчетах используются только части значений даты.

    • РАЗНДАТ (выражение1; выражение2)

    У меня вот эта ошибка: Subquery returns more than 1 row . См. sqlfiddle.com/#!9/6d3c4c/1.

    @rony dateiff должен вернуть одну запись. sqlfiddle.com/#!9/6d3c4c/12

    Какую функцию мне следует использовать, если мне нужно просуммировать все возвращенные даты?

    Я имею в виду, вы не можете использовать скалярный подзапрос, который возвращает более одной строки, в противном случае вы должны присоединиться к нему

    Я не могу использовать что-то подобное SUM(DISTINCT DATEDIFF(. )) ?

    Источник

    Error 1582 incorrect parameter count in the call to native function datediff

    public function search(Request $request) < n

    $rules = [n ‘name’ => ‘max:191|min:4’,n ‘city’ => »,n ‘lat’ => »,n ‘lang’ => »,n ‘price_from’=> ‘numeric’,n ‘price_to’ => ‘numeric’,n ‘area_from’ => ‘numeric’,n ‘area_to’ => ‘numeric’,n ‘num_of_person_from’=> ‘numeric’,n ‘num_of_person_to’ => ‘numeric’,n n ];nn $validator = Validator::make($request->all(), $rules);nn if ($validator->fails())n return ApiController::respondWithError(validateRules($validator->errors(), $rules));n $gr_circle_radius = 6371;n $max_distance = 2;n $lat = $request->lat;n $lng = $request->lang;n n $data = Hole::select(DB::raw(‘*, ( 6367 * acos( cos( radians(‘.$lat.’) ) * cos( radians( lat ) ) * cos( radians( lang ) — radians(‘.$lng.’) ) + sin( radians(‘.$lat.’) )* sin( radians( lat ) ) ) ) AS distance’))n ->having(‘distance’, ‘ orderBy(‘distance’)->with(‘photos’)n ->orwhere(‘city’, $request->city)n ->orwhere(‘name’, $request->name)n ->orWhereBetween(‘price’, [$request->price_from, $request->price_to])n ->orWhereBetween(‘area’, [$request->area_from, $request->area_to])n ->orWhereBetween(‘person_count’, [$request->num_of_person_from, $request->num_of_person_to])n ->get();n n n >);nn return ApiController::respondWithSuccess($data);nn>n n

    Are you sure your form input name is «lang» and not «long» for longitude? If it’s wrong, then $lng is null. n

    Several places you’re using lat instead of $lat? n

    Источник

    Error 1582 incorrect parameter count in the call to native function datediff

    MySQL 5.1 Manual
    DATEDIFF(expr1,expr2)

    DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

    Вы не обратили внимание, там написано (Transact-SQL)
    Знаете, что это означает? Что данный код допустим в Transact-SQL.
    А Transact-SQL — это диалект SQL, используемый в Microsoft SQL Server.

    я вообще не понимаю, зачем Вы смотрите в msdn описание команд MS SQL server, если Вы им не пользуетесь.
    MS SQL это совсем не тоже самое, что MySQL!

    И, надеюсь, для Вас уже не секрет, что в разный СУБД (MS SQL, Oracle, MySQL, PostrgeSQL, Firebird) используются РАЗНЫЕ диалекты SQL.
    Особенно это касается работы с полями DATE, TIME, обработкой строк и т.д. и т.п.
    Поэтому SQL код для Oracle может не работать на MySQL, или, код от MS SQL может не работать на MySQL (как в вашем случае).

    Источник

    Когда я пытаюсь преобразовать метку времени в следующий запрос, используя bash

    docker exec compose_TSOwncloudMySQL_1 mysql -h localhost -udockerdev -pdocker owc -e "
    SELECT DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%Y%m%d timestamp%h:%i:%s') AS 'date_formatted',
        oc_ldap_user_mapping.ldap_dn,
        oc_activity.subject,
        oc_activity.file,
        oc_activity.subjectparams
    FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name 
    ORDER BY oc_activity.timestamp;"> /home/dockerdmz/tsowncloud/log_owc/owc_$DATE.log`
    

    У меня есть эта ошибка:

    ERROR 1582 (42000) at line 2: Incorrect parameter count in the call to native function 'FROM_UNIXTIME'
    

    Когда я запускаю этот запрос на странице администрирования MySQL, он работает хорошо.

    SELECT DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%Y%m%d %h:%i:%s') AS 'date_formatted',
    oc_ldap_user_mapping.ldap_dn,
    oc_activity.subject, 
    oc_activity.file, 
    oc_activity.subjectparams
    FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name
    ORDER BY oc_activity.timestamp;
    

    Когда я запускаю этот bash код (без преобразования временной метки), он хорошо работает

    Docker exec compose_TSOwncloudMySQL_1 mysql -h localhost -udockerdev -pdocker owc -e "
    SELECT oc_activity.timestamp,
        oc_ldap_user_mapping.ldap_dn,
        oc_activity.subject,
        oc_activity.file,
        oc_activity.subjectparams
    FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name
    ORDER BY oc_activity.timestamp;"> /home/dockerdmz/tsowncloud/log_owc/owc_$DATE.log
    

    Last Update:2015-07-08
    Source: Internet

    Author: User

    Error code: 1582 Incorrect parameter count in the call to native function ‘str _ to_date’
    1. Error description

    1 queries executed, 0 success, 1 errors, 0 warnings query: SELECT t. 'name', DATE_FORMAT (str_to_date ('20140901'), '% y') as statisDate, ROUND (IFNULL (SUM (t. 'amount '), 0), 3)... error code: 1582 Incorrect parameter count in the call to native function 'str _ to_date 'execution time: 0 sec Transfer Time: 0 sec total time consumed: 0 sec

    2. Cause of error

    SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2015'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2015' UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2014'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2014'

    The format of the MySQL built-in function str_to_date is: str_to_date (string, date format );
    In this query SQL, It is str_to_date (string), resulting in an error

    3. Solution

    Modify query SQL statements

    SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2015','%Y'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2015' UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('2014','%Y'), '%Y') AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '%Y') = '2014'

    Понравилась статья? Поделить с друзьями:

    Читайте также:

  • Error 1513 unity
  • Error 15100 sql
  • Error 1500 java
  • Error 150 sql
  • Error 150 foreign key constraint is incorrectly formed

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии