Announcement

Collapse
No announcement yet.

variable in sql

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • variable in sql

    hi,
    how can I use variables inside a query

    example:

    select m.codpdv,
    sum(if( m.idiniz_ana='$XXX',qta,0) ) as qta_articoli
    from iniz_movfid as m
    where m.idiniz_ana='57'
    group by m.codpdv, m.codart

  • #2
    Just like you did it.
    However, depending on where the query is fired, it might be necessary to use a global variable.
    So the $XXX variable needs to be replaced with [XXX].

    jsb

    Comment


    • #3
      Originally posted by jsbinca View Post
      Just like you did it.
      However, depending on where the query is fired, it might be necessary to use a global variable.
      So the $XXX variable needs to be replaced with [XXX].

      jsb
      If you are saying so what will that global variable will be (in ou out)!!!! ohoh is that not a bad idea that scriptcase offers?

      Comment


      • #4
        That's totally up to you.
        You are the programmer and you have to take care of it, not scriptcase.
        SC just gives you the tools you need.

        jsb

        Comment


        • #5
          i try with

          select m.codpdv,
          sum(if( m.idiniz_ana='[xxx]',qta,0) ) as qta_articoli
          from iniz_movfid as m
          where m.idiniz_ana='57'
          group by m.codpdv, m.codart

          but don't work, work only if the variabile is in a where condition ex:


          select m.codpdv,
          sum(if( m.idiniz_ana='51',qta,0) ) as qta_articoli
          from iniz_movfid as m
          where m.idiniz_ana='[xxx]'
          group by m.codpdv, m.codart

          Comment


          • #6
            Is this in a grid or form? If it's in a form it wouldn't work as they need to be update aware. But in a grid it should work afaik.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment

            Working...
            X