count(*) non funziona...
Ciao a tutti. Ho creato una stored procedure come segue:
CREATE DEFINER=`root`@`localhost` PROCEDURE [procedure_name](
idaccount int,
data NVARCHAR(10)
)
BEGIN
IF idaccount IS NULL THEN
SELECT count(*) INTO @counter FROM [table_sample]
WHERE DATE_FORMAT(STR_TO_DATE(DataInizio, '%d/%m/%Y'), '%d/%m/%Y') >= DATE_FORMAT(STR_TO_DATE(data, '%d/%m/%Y'), '%d/%m/%Y') ORDER BY DataInizio DESC;
ELSE
SELECT count(*) INTO @counter FROM [table_sample]
WHERE IDAccount = idaccount AND DATE_FORMAT(STR_TO_DATE(DataInizio, '%d/%m/%Y'), '%d/%m/%Y') >= DATE_FORMAT(STR_TO_DATE(data, '%d/%m/%Y'), '%d/%m/%Y') ORDER BY DataInizio DESC;
END IF;
SELECT @counter;
...
Mi dite perché @counter è sempre 0, quando dovrebbe restituire 6, dato che nella tabella [table_sample] ci sono 6 records?
Anche se metto [schema].[table_sample] il risultato è sempre 0. Perché? Cosa sbaglio?
Grazie!
Subject
Views
Written By
Posted
count(*) non funziona...
603
December 01, 2021 10:02AM
382
December 02, 2021 02:05AM
378
December 03, 2021 05:20AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.