Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2014
    Posts
    6

    Unanswered: Error Alter Size Integer

    Hi,

    I tried to change the Integer size and appears this:

    Code:
    ERROR:  syntax error at or near "("
    LINE 1: ...jgovce_jevents_vevent" ALTER COLUMN "ev_id" TYPE integer(12)
                                                                       ^
    
    No bloco:
    ALTER TABLE "public"."jgovce_jevents_vevent" ALTER COLUMN "ev_id" TYPE integer(12)
    PostgreSQL 9.1.11
    Linux Ubuntu
    Last edited by eiro; 01-08-14 at 15:33.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    What makes you think that the integer data type has a parameter?

    Integers (and bigint) don't have a "size".

    Please read the manual for details: http://www.postgresql.org/docs/curre...l#DATATYPE-INT
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Jan 2014
    Posts
    6
    Well, I'm trying to use a plugin in Joomla! worked in MySQL, I migrated to PostgreSQL and this error appeared.

    So just in PostgreSQL can not set a size for the integer?

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by eiro View Post
    So just in PostgreSQL can not set a size for the integer?
    Correct.

    Btw: integers in MySQL do not have a "size" either. The parameter to the integer datatype does not constrain the values in any way. It is merely a hint for client application on how the column should be displayed. It does not impose a constraint on the values.

    If you want to constrain the value put into the column, you need to use a check constraint.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  5. #5
    Join Date
    Jan 2014
    Posts
    6
    You mean you do not need to set a size, right? But accept set a size.

    So, for the integer receive a maximum of 12 numbers I have to do an IF?

  6. #6
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by eiro View Post
    You mean you do not need to set a size, right? But accept set a size.

    So, for the integer receive a maximum of 12 numbers I have to do an IF?
    No, you have to add a check constraint.

    Code:
    alter table public.jgovce_jevents_vevent
      add constraint check_value
      check (ev_id < 999999999999);
    Again: The definition of int(12) did NOT impose such a limit in MySQL. You could still store larger numbers in MySQL.

    So I don't see the point applying the check constraint in Postgres if MySQL didn't limit the values either.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  7. #7
    Join Date
    Jan 2014
    Posts
    6
    Okay, so this plugin will not work with postgresql

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if the extension needs at least 12 digits then you may need to alter the columns datatype to bigint
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by eiro View Post
    Okay, so this plugin will not work with postgresql
    Why?
    Is that code to change the data type hardwired?

    The column with an integer datatype will behave no differently compared to a column defined as int(12) in MySQL.

    Quote Originally Posted by healdem View Post
    if the extension needs at least 12 digits then you may need to alter the columns datatype to bigint
    MySQL's int(12) does NOT impose any restrictions on the length of the values that can be stored there. If the application works fine with int(12) in MySQL it will work just as fine in Postgres using integer
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  10. #10
    Join Date
    Jan 2014
    Posts
    6
    Not that needs at least 12 digits. is to allow a maximum of 12 digits.

    But I had tried with bigint, the error is the same, the problem is in the syntax that the plugin does and I do not know to change it.

  11. #11
    Join Date
    Jan 2014
    Posts
    6
    I do not know that simply means "hardwired"

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what did you try to alter the datatype to bigint and what as the error message
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •