DreamCoder lost stored-procedure or function code indentation
  • MarcusMarcus May 2011

    Hi,


    I'm Italian, so sorry for my english.


    I've a little problem as describe in the object.


    Using DreamCoder for MySQL version 6.0 in Window Vista Basic Edition SP1


    I use to indent the the stored-procedure or function code to make it more readable. Once I compile the code, I close the procedure building window. If I need to review the same stored-procedure or function, I re-open it by double-clicking on the related label. DreamCoder open the procedure building window with the code in it, but the code has lost the indentation.


    Is this beahviour by design or is it an issue?


    Thanks in advance for any your reply.

  • ptesoneptesone May 2011
    Hi Marcus,

    We need to research this case because normally the database store the code like you have before you execute, this is the same for Oracle and work fine in DreamCoder for Oracle.

    Regards,
    Peter
  • MarcusMarcus May 2011
    OK Peter, I'll waiting for some reply about this issue.
    For the moment I have to copy/paste the stored-procedure (or function) code into a text file to preserve the indentation, but you can understand by yourself that is not the right way, nor the useful way to work!

    Thank you for your support

    Regards
  • ptesoneptesone May 2011
    Hi Marcus,

    You have right, also you can have a stored version of the sp saved from the DreamCoder in your local drive.

    You can send us the MySQL Server version and some code example of your sp.

    Regards,
    Peter
  • MarcusMarcus May 2011
    The MySQL Engine version is 5.1 Community Edition

    This is the function code before compiling (function or stored-procecure have equivalent behaviour) select all, copy 'n' paste from notepad, file DBF_GET_PARAMETER_NUMERIC.sql

    CREATE DEFINER=`root`@`localhost` FUNCTION `DBF_GET_PARAMETER_NUMERIC`(iDataSessionID INT, sParamName varchar(254)) RETURNS double
    BEGIN
    /***********************************************************
     *
     *  Nome:   DBF_GET_PARAMETER_NUMERIC
     *
     *  Scopo:  Estrae un parametro il cui identificativo deve
     *          essere specificato nel parametro sParamName
     * 
     *  Parametri 
     *     sParamName
     *          Identificativo del parametro di cui si desidera
     *          ottenere il valore
     *                                            
     *  La funzione restituice un valore numerico che e'
     *    associato all'identificativo del parametro
     *
     *  Data di prima stesura:  13-mag-2010
     *  Autore:                 Marco PODDA
     *
     *  NOTE
     *  -   La funzione controlla che il parametro sia
     *      effettivamente numero, ossia che sia costituito da
     *        sole cifre da 0 a 9 (estremi incusi) e che
     *        l'eventuale segno compaia una sola volta. Il
     *        separatore fra la parte intera e quella non intera,
     *        se presente, puo' comparire una sola volta e deve
     *        essere il '.' (punto). Vi deve essere almeno una
     *        cifra e il segno deve trovarsi in prima posizione
     *        (ossia prima della prima cifra o punto decimale).
     *        Se questi controlli non vengono superati la funzione
     *        restituisce un valore NULL 
     *    -    Puo' generare errori di esecuzione intercettabili
     *
     *  Revisioni successive
     *  ========================================================
     *  Data:           gg-mmm-aaaa
     *  Autore:         Nome COGNOME
     *  Descrizione:    [Testo libero]
     *  ========================================================
     *
     ***********************************************************/
    DECLARE sParamValue         varchar(254);
    DECLARE iPosIndex           int;
    DECLARE iValueLength        int;
    DECLARE iDecimalPointCount  int;
    DECLARE iDigitCount         int;
    DECLARE iSignCount          int;
    DECLARE cChar               char(1);
    DECLARE iExit               int;
    DECLARE iDone               int;
    DECLARE dReturnValue        double;

    SET dReturnValue = NULL;
    SET sParamValue = NULL;
        SELECT
            VALUE
        INTO
            sParamValue
        FROM
            D_PARAMETERS
        WHERE
            NAME = sParamName;
        IF FOUND_ROWS() > 0 THEN
            SET sParamValue = RTRIM(LTRIM(sParamValue));
            SET iValueLength = CHAR_LENGTH(sParamValue);
            SET iExit = 0;
            SET iPosIndex = 1;
            SET iDecimalPointCount = 0;
            SET iSignCount = 0;
            SET iDigitCount = 0;
            WHILE iPosIndex <= iValueLength AND iExit = 0 DO
                SET cChar = SUBSTRING(sParamValue, iPosIndex, 1);
                SET iDone = 0;
                IF iDone = 0 THEN
                    IF cChar = '.' THEN
                        SET iDone = 1;
                        SET iDecimalPointCount = iDecimalPointCount + 1;
                        IF iDecimalPointCount > 1 THEN
                            SET iExit = 1;
                        END IF;
                    END IF;
                END IF;
                IF iDone = 0 THEN
                    IF cChar = '+' OR cChar = '-' THEN
                        SET iDone = 1;
                        IF iPosIndex > 1 THEN
                            SET iExit = 1;
                        ELSE
                            SET iSignCount = iSignCount + 1;
                            IF iSignCount > 1 THEN
                                SET iExit = 1;
                            END IF;
                        END iF;
                    END IF;
                END IF;
                IF iDone = 0 THEN
                    IF cChar >= '0' AND cChar <= '9' THEN
                        SET iDone = 1;
                        SET iDigitCount = iDigitCount + 1;
                    END IF;
                END IF;
                IF iDone = 0 THEN
                    SET iExit = 1;
                END IF;
                IF iExit = 0 THEN
                    SET iPosIndex = iPosIndex + 1;
                END IF;
            END WHILE;
            IF iExit = 0 AND iDigitCount > 0 THEN
                SET dReturnValue = sParamValue;
            ELSE 
                CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 11, CONCAT('sParamName=',sParamName));
            END IF;
        ELSE
            CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 12, CONCAT('sParamName=',sParamName));
        END IF;
        RETURN dReturnValue;
    END

    and this is the code I find when re-open the function (select all, copy 'n' paste from the DreamCoder for MySQL procedure building dialog box)

    CREATE DEFINER=`root`@`localhost` FUNCTION `DBF_GET_PARAMETER_NUMERIC`(iDataSessionID INT, sParamName varchar(254)) RETURNS double
    BEGIN
    /***********************************************************
     *
     *  Nome:   DBF_GET_PARAMETER_NUMERIC
     *
     *  Scopo:  Estrae un parametro il cui identificativo deve
     *          essere specificato nel parametro sParamName
     * 
     *  Parametri 
     *     sParamName
     *          Identificativo del parametro di cui si desidera
     *          ottenere il valore
     *                                            
     *  La funzione restituice un valore numerico che e'
     *    associato all'identificativo del parametro
     *
     *  Data di prima stesura:  13-mag-2010
     *  Autore:                 Marco PODDA
     *
     *  NOTE
     *  -   La funzione controlla che il parametro sia
     *      effettivamente numero, ossia che sia costituito da
     *        sole cifre da 0 a 9 (estremi incusi) e che
     *        l'eventuale segno compaia una sola volta. Il
     *        separatore fra la parte intera e quella non intera,
     *        se presente, puo' comparire una sola volta e deve
     *        essere il '.' (punto). Vi deve essere almeno una
     *        cifra e il segno deve trovarsi in prima posizione
     *        (ossia prima della prima cifra o punto decimale).
     *        Se questi controlli non vengono superati la funzione
     *        restituisce un valore NULL 
     *    -    Puo' generare errori di esecuzione intercettabili
     *
     *  Revisioni successive
     *  ========================================================
     *  Data:           gg-mmm-aaaa
     *  Autore:         Nome COGNOME
     *  Descrizione:    [Testo libero]
     *  ========================================================
     *
     ***********************************************************/
    DECLARE sParamValue         varchar(254);
    DECLARE iPosIndex           int;
    DECLARE iValueLength        int;
    DECLARE iDecimalPointCount  int;
    DECLARE iDigitCount         int;
    DECLARE iSignCount          int;
    DECLARE cChar               char(1);
    DECLARE iExit               int;
    DECLARE iDone               int;
    DECLARE dReturnValue        double;
    SET dReturnValue = NULL;
    SET sParamValue = NULL;
    SELECT
            VALUE
        INTO
            sParamValue
        FROM
            D_PARAMETERS
        WHERE
            NAME = sParamName;
    IF FOUND_ROWS() > 0 THEN
            SET sParamValue = RTRIM(LTRIM(sParamValue));
    SET iValueLength = CHAR_LENGTH(sParamValue);
    SET iExit = 0;
    SET iPosIndex = 1;
    SET iDecimalPointCount = 0;
    SET iSignCount = 0;
    SET iDigitCount = 0;
    WHILE iPosIndex <= iValueLength AND iExit = 0 DO
                SET cChar = SUBSTRING(sParamValue, iPosIndex, 1);
    SET iDone = 0;
    IF iDone = 0 THEN
                    IF cChar = '.' THEN
                        SET iDone = 1;
    SET iDecimalPointCount = iDecimalPointCount + 1;
    IF iDecimalPointCount > 1 THEN
                            SET iExit = 1;
    END IF;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    IF cChar = '+' OR cChar = '-' THEN
                        SET iDone = 1;
    IF iPosIndex > 1 THEN
                            SET iExit = 1;
    ELSE
                            SET iSignCount = iSignCount + 1;
    IF iSignCount > 1 THEN
                                SET iExit = 1;
    END IF;
    END iF;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    IF cChar >= '0' AND cChar <= '9' THEN
                        SET iDone = 1;
    SET iDigitCount = iDigitCount + 1;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    SET iExit = 1;
    END IF;
    IF iExit = 0 THEN
                    SET iPosIndex = iPosIndex + 1;
    END IF;
    END WHILE;
    IF iExit = 0 AND iDigitCount > 0 THEN
                SET dReturnValue = sParamValue;
    ELSE 
                CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 11, CONCAT('sParamName=',sParamName));
    END IF;
    ELSE
            CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 12, CONCAT('sParamName=',sParamName));
    END IF;
    RETURN dReturnValue;
    END


    I hope this example may be significan to replicate the issue.
  • MarcusMarcus May 2011
    Hi

    waiting for any reply, I do some "experiment"...

    The issue is not in MySQL engine, but in the way Dream Coder for MySQL pass the command to MySQL. Below, I report the message output

    [SQL 20.41.50 ] CREATE DEFINER=`root`@`localhost` FUNCTION `DBF_GET_PARAMETER_NUMERIC`(iDataSessionID INT, sParamName varchar(254)) RETURNS double
    BEGIN
    /***********************************************************
     *
     *  Nome:   DBF_GET_PARAMETER_NUMERIC
     *
     *  Scopo:  Estrae un parametro il cui identificativo deve
     *          essere specificato nel parametro sParamName
     * 
     *  Parametri 
     *     sParamName
     *          Identificativo del parametro di cui si desidera
     *          ottenere il valore
     *                                            
     *  La funzione restituice un valore numerico che e'
     *    associato all'identificativo del parametro
     *
     *  Data di prima stesura:  13-mag-2010
     *  Autore:                 Marco PODDA
     *
     *  NOTE
     *  -   La funzione controlla che il parametro sia
     *      effettivamente numero, ossia che sia costituito da
     *        sole cifre da 0 a 9 (estremi incusi) e che
     *        l'eventuale segno compaia una sola volta. Il
     *        separatore fra la parte intera e quella non intera,
     *        se presente, puo' comparire una sola volta e deve
     *        essere il '.' (punto). Vi deve essere almeno una
     *        cifra e il segno deve trovarsi in prima posizione
     *        (ossia prima della prima cifra o punto decimale).
     *        Se questi controlli non vengono superati la funzione
     *        restituisce un valore NULL 
     *    -    Puo' generare errori di esecuzione intercettabili
     *
     *  Revisioni successive
     *  ========================================================
     *  Data:           gg-mmm-aaaa
     *  Autore:         Nome COGNOME
     *  Descrizione:    [Testo libero]
     *  ========================================================
     *
     ***********************************************************/
    DECLARE sParamValue         varchar(254);
    DECLARE iPosIndex           int;
    DECLARE iValueLength        int;
    DECLARE iDecimalPointCount  int;
    DECLARE iDigitCount         int;
    DECLARE iSignCount          int;
    DECLARE cChar               char(1);
    DECLARE iExit               int;
    DECLARE iDone               int;
    DECLARE dReturnValue        double;
    SET dReturnValue = NULL;
    SET sParamValue = NULL;
    SELECT
            VALUE
        INTO
            sParamValue
        FROM
            D_PARAMETERS
        WHERE
            NAME = sParamName;
    IF FOUND_ROWS() > 0 THEN
            SET sParamValue = RTRIM(LTRIM(sParamValue));
    SET iValueLength = CHAR_LENGTH(sParamValue);
    SET iExit = 0;
    SET iPosIndex = 1;
    SET iDecimalPointCount = 0;
    SET iSignCount = 0;
    SET iDigitCount = 0;
    WHILE iPosIndex <= iValueLength AND iExit = 0 DO
                SET cChar = SUBSTRING(sParamValue, iPosIndex, 1);
    SET iDone = 0;
    IF iDone = 0 THEN
                    IF cChar = '.' THEN
                        SET iDone = 1;
    SET iDecimalPointCount = iDecimalPointCount + 1;
    IF iDecimalPointCount > 1 THEN
                            SET iExit = 1;
    END IF;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    IF cChar = '+' OR cChar = '-' THEN
                        SET iDone = 1;
    IF iPosIndex > 1 THEN
                            SET iExit = 1;
    ELSE
                            SET iSignCount = iSignCount + 1;
    IF iSignCount > 1 THEN
                                SET iExit = 1;
    END IF;
    END iF;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    IF cChar >= '0' AND cChar <= '9' THEN
                        SET iDone = 1;
    SET iDigitCount = iDigitCount + 1;
    END IF;
    END IF;
    IF iDone = 0 THEN
                    SET iExit = 1;
    END IF;
    IF iExit = 0 THEN
                    SET iPosIndex = iPosIndex + 1;
    END IF;
    END WHILE;
    IF iExit = 0 AND iDigitCount > 0 THEN
                SET dReturnValue = sParamValue;
    ELSE 
                CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 11, CONCAT('sParamName=',sParamName));
    END IF;
    ELSE
            CALL DBP_WRITE_EXCEPTION_INFO(iDataSessionID, 'DBF_GET_PARAMETER_NUMERIC', 12, CONCAT('sParamName=',sParamName));
    END IF;
    RETURN dReturnValue;
    END
    [SQL 20.41.50 ] drop function if exists DBF_GET_PARAMETER_NUMERIC


    obviously, the last line (drop function if exists...) has been executed first.

    As you can see, the indetation is immediately lost when Dream Coder for MySQL pass the CREATE command to MySQL engine.
    I also note that the identation is lost each time a line is semicolon terminated. For example, the first SELECT clausole after SET sParamValue = NULL; is aligned to the left instead of be indented by 1 tab as in origin. When a line is not semicolon terminated the next line is well indent as in origin.

    Can this issue fixed?

    Thankyou in advance

    Best regards


Why do a donation?
The development of such an applications requires an important amount of time and resources. Your continued donations will allow us to continue the development and maintenance.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Tagged