ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

quick command to run a query in iseries through the command line?

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

  • quick command to run a query in iseries through the command line?

    Hi, im looking for the best way to run a query through only using the command line in our iseries, without using the wrkqry command.

    I tried to use the STRQMQRY command;
    STRQMQRY QMQRY(MYLIB/QUERY) OUTPUT(*OUTFILE) OUTFILE(*CURLIB/TEMP)
    but this didnt work for some reason..

    While feeling a bit stupid I realised that i could use the runqry command(I usally use it for running querys against files and never against stored querys...)
    RUNQRY QRY(MYLIB/QUERY)
    which seemed to work fine.

    So my question is, is there some other/better way to do it? And any noticable reason that the STRQMQRY command would fail?

    Thanks for a very interesting forum.

  • #2
    Re: quick command to run a query in iseries through the command line?

    Hi Shazbot:
    didnt work for some reason
    "GO CMDQM" on a cmmand line...you will see qmqry's are quite different than wrkqry.
    Unless you want to get into sql......runqry from a command line is probably the best way to go for this.

    By the way...
    RUNQRY QRYFILE(MYFILE) works without having to do the qry definition.

    Welcome to CODE400

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: quick command to run a query in iseries through the command line?

      Welcome to code400....
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: quick command to run a query in iseries through the command line?

        RUNQRY QRYFILE((CRMCUS)) RCDSLT(*YES)

        I'd go with SQL though.
        Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

        Comment


        • #5
          Re: quick command to run a query in iseries through the command line?

          Originally posted by shazbot
          And any noticable reason that the STRQMQRY command would fail?
          For that question, it's because STRQMQRY runs *QMQRY objects. You were trying to use it to run *QRYDFN objects. Wrong kind of query.

          You might investigate QM queries to see how you can get away from using the older *QRYDFN queries. Much more can be done with QM queries. And if you have the SQL Dev Kit product and you aren't using them, you've already paid for QM queries without getting their benefits.
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #6
            Re: quick command to run a query in iseries through the command line?

            Originally posted by GLS400 View Post
            Hi Shazbot:

            "GO CMDQM" on a cmmand line...you will see qmqry's are quite different than wrkqry.
            Unless you want to get into sql......runqry from a command line is probably the best way to go for this.

            By the way...
            RUNQRY QRYFILE(MYFILE) works without having to do the qry definition.

            Welcome to CODE400

            Best of Luck
            GLS
            Ah, now I see. As I said, never used qmqry before and Im pretty sure no one else in the office does


            Originally posted by tomliotta View Post
            For that question, it's because STRQMQRY runs *QMQRY objects. You were trying to use it to run *QRYDFN objects. Wrong kind of query.

            You might investigate QM queries to see how you can get away from using the older *QRYDFN queries. Much more can be done with QM queries. And if you have the SQL Dev Kit product and you aren't using them, you've already paid for QM queries without getting their benefits.
            Thanks for the clarifications. As it is pretty obvious, Im pretty green on the iseries as a whole. But the runqry command will do the trick. The point of all this was to make a executable which runs the command for the query and updates a file in the iseries, which my collegue then run some queries against in ms access. I usally run this when he asks me but since now he can run it by using the executable. There is the easy solution to show him how to run it in the iseries but that seems a bit too.. easy.

            Thanks guys

            Comment


            • #7
              Re: quick command to run a query in iseries through the command line?

              Im pretty green on the iseries as a whole.
              Are you familiar with different kinds of queries on other systems?
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment


              • #8
                Re: quick command to run a query in iseries through the command line?

                Originally posted by tomliotta View Post
                Are you familiar with different kinds of queries on other systems?
                No, not really. Well, besides SQL that is.

                Comment


                • #9
                  Re: quick command to run a query in iseries through the command line?

                  If you're familiar with SQL, then QM queries should be almost natural to you.

                  There are two "modes" to QM queries: Prompt and SQL. The 'Prompt' mode has a lot of similarities to how queries are created through the other Query for iSeries product that's used in your organization. That can make it easier for others to ease into QM queries. (You might always work in 'SQL' mode.)

                  Once a query is initially described in 'Prompt' mode, it can be changed to 'SQL' mode. This is a one-way conversion, and it's optional. A given query can be kept in 'Prompt' mode throughout its life.

                  Note that a 'SQL' query can consist of any dynamic SQL statement. Most of them might be SELECT statements; but UPDATE, INSERT and DELETE are just as possible. Also, QM queries allow parameters to be passed in through the STRQMQRY command. Clauses of the SQL statement can be modified or completely replaced by parameter values. That's one of the biggest advantages of QM queries once you learn how those work.

                  A secondary part of QM is the report writer part, the 'forms'. After a query is defined, a form can also be defined to control printed output if you want it. A default form is always available, but far more complex forms can be defined. Further, queries and forms can be paired up in different ways. A single query can be run with three (or more) different forms, or three (or more) different queries can run with the same form. The STRQMQRY command has parms to specify both query and form, or just leave the form as the default.

                  I suggest that you learn QM. You might never get anyone else to use it, but you'll be able to get much more done than with the older product.
                  Tom

                  There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                  Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                  Comment


                  • #10
                    Re: quick command to run a query in iseries through the command line?

                    Originally posted by tomliotta View Post
                    If you're familiar with SQL, then QM queries should be almost natural to you.

                    There are two "modes" to QM queries: Prompt and SQL. The 'Prompt' mode has a lot of similarities to how queries are created through the other Query for iSeries product that's used in your organization. That can make it easier for others to ease into QM queries. (You might always work in 'SQL' mode.)

                    Once a query is initially described in 'Prompt' mode, it can be changed to 'SQL' mode. This is a one-way conversion, and it's optional. A given query can be kept in 'Prompt' mode throughout its life.

                    Note that a 'SQL' query can consist of any dynamic SQL statement. Most of them might be SELECT statements; but UPDATE, INSERT and DELETE are just as possible. Also, QM queries allow parameters to be passed in through the STRQMQRY command. Clauses of the SQL statement can be modified or completely replaced by parameter values. That's one of the biggest advantages of QM queries once you learn how those work.

                    A secondary part of QM is the report writer part, the 'forms'. After a query is defined, a form can also be defined to control printed output if you want it. A default form is always available, but far more complex forms can be defined. Further, queries and forms can be paired up in different ways. A single query can be run with three (or more) different forms, or three (or more) different queries can run with the same form. The STRQMQRY command has parms to specify both query and form, or just leave the form as the default.

                    I suggest that you learn QM. You might never get anyone else to use it, but you'll be able to get much more done than with the older product.
                    oh, this is great. Thanks! Yeah, i doubt i will get anyone else to use it since it seems im the only one intrested in learning and using new things through our iseries. But that is a whole other problem for the enterprise

                    Comment


                    • #11
                      Re: quick command to run a query in iseries through the command line?

                      Shazbot,

                      don't let others deter your desire to try and learn new things. I've been there. If you look on DB2 for i blogspt Mike Cain says
                      In a perfect world, one would embark on this path via a "master and apprentice" relationship. In my opinion, this is the best way to really get it. Having a competent and caring teacher - someone who really knows the craft - is priceless.
                      but this isn't normally the case. The best thing is practice, practice, practice. Personally, I've probably run close to a million sql statements. (1,000 a week, 52K year * 20 years)

                      Jim

                      Comment


                      • #12
                        Re: quick command to run a query in iseries through the command line?

                        Originally posted by Jim_IT View Post
                        Shazbot,

                        don't let others deter your desire to try and learn new things. I've been there. If you look on DB2 for i blogspt Mike Cain says but this isn't normally the case. The best thing is practice, practice, practice. Personally, I've probably run close to a million sql statements. (1,000 a week, 52K year * 20 years)

                        Jim
                        words to live by, honestly. I have a collegue that has been around since they implented the iseries back in 98 or someting, I guess it was called the as400 then, which I try to learn and pick up stuff as much as I can from.. The only troublesome fact is that iseries/as400 is not that common here in sweden in work places. Which kinda sucks.

                        Comment

                        Working...
                        X