Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. PL SQL INTO Horror

PL SQL INTO Horror

Scheduled Pinned Locked Moved The Weird and The Wonderful
database
13 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Andres Martin

    That is valid, but is not necesary to create a SELECT stmt by each field, just creating SELECT field1, field2, field3 INTO var1, var2, va3... can get the values in one line.

    A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #4

    It looks like each table being inserted into is different. That cannot be done with one line. There might be a good reason for that.

    [Forum Guidelines]

    R 1 Reply Last reply
    0
    • A Andres Martin

      SELECT VALADMREC INTO vVALADMREC FROM CUSTOMERS WHERE IDTYPE =linea; SELECT PF INTO vPF FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TDP INTO vTDP FROM CUSTOMERS WHERE IDTYPE =linea; SELECT DP INTO vDPA FROM CUSTOMERS WHERE IDTYPE =linea; SELECT DPR INTO vDPR FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TIPODESRES INTO vTIPODESRES FROM CUSTOMERS WHERE IDTYPE =linea; SELECT PAGOPREV INTO vPAGOPREV FROM CUSTOMERS WHERE IDTYPE =linea; SELECT Prima INTO vPORCPRIMA FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TIPO_TERCERO INTO vTIPOTERCERO FROM CUSTOMERS WHERE IDTYPE =linea;

      J Offline
      J Offline
      Jeroen De Dauw
      wrote on last edited by
      #5

      Hey! Where did you get my code?!! o_O

      Jeroen De Dauw
      Blog ; Wiki

      1 Reply Last reply
      0
      • A AspDotNetDev

        It looks like each table being inserted into is different. That cannot be done with one line. There might be a good reason for that.

        [Forum Guidelines]

        R Offline
        R Offline
        Robert Rohde
        wrote on last edited by
        #6

        I think those vXXXXX thingies are (local) variables in the procedure and no tables.

        R S A 3 Replies Last reply
        0
        • R Robert Rohde

          I think those vXXXXX thingies are (local) variables in the procedure and no tables.

          R Offline
          R Offline
          Richard Jones
          wrote on last edited by
          #7

          You are correct sir :)

          I need an app that will automatically deliver a new BBBBBBBBaBB (beautiful blonde bimbo brandishing bountiful bobbing bare breasts and bodacious butt) every day. John Simmons / outlaw programmer

          1 Reply Last reply
          0
          • R Robert Rohde

            I think those vXXXXX thingies are (local) variables in the procedure and no tables.

            S Offline
            S Offline
            SomeGuyThatIsMe
            wrote on last edited by
            #8

            In SqlServer unless those were declared somewhere it would create a table vXXXXX for each statement, if you wanted an assignment it would just be SELECT vXXXX = XXXX from table. You can string as many of those together in one statement as you like afaik.

            Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

            1 Reply Last reply
            0
            • R Robert Rohde

              I think those vXXXXX thingies are (local) variables in the procedure and no tables.

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #9

              No, variables have "@" in front of them. For example:

              DECLARE @SomeVariable int
              SELECT @SomeVariable

              A SELECT INTO statement copies one set of values into a new table (it creates the new table).

              [Forum Guidelines]

              D 1 Reply Last reply
              0
              • A AspDotNetDev

                No, variables have "@" in front of them. For example:

                DECLARE @SomeVariable int
                SELECT @SomeVariable

                A SELECT INTO statement copies one set of values into a new table (it creates the new table).

                [Forum Guidelines]

                D Offline
                D Offline
                David Skelly
                wrote on last edited by
                #10

                This is PL/SQL, not T-SQL. (Oracle, not SQL Server)

                A 1 Reply Last reply
                0
                • D David Skelly

                  This is PL/SQL, not T-SQL. (Oracle, not SQL Server)

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #11

                  Ah, I see.

                  [Forum Guidelines]

                  1 Reply Last reply
                  0
                  • A Andres Martin

                    SELECT VALADMREC INTO vVALADMREC FROM CUSTOMERS WHERE IDTYPE =linea; SELECT PF INTO vPF FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TDP INTO vTDP FROM CUSTOMERS WHERE IDTYPE =linea; SELECT DP INTO vDPA FROM CUSTOMERS WHERE IDTYPE =linea; SELECT DPR INTO vDPR FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TIPODESRES INTO vTIPODESRES FROM CUSTOMERS WHERE IDTYPE =linea; SELECT PAGOPREV INTO vPAGOPREV FROM CUSTOMERS WHERE IDTYPE =linea; SELECT Prima INTO vPORCPRIMA FROM CUSTOMERS WHERE IDTYPE =linea; SELECT TIPO_TERCERO INTO vTIPOTERCERO FROM CUSTOMERS WHERE IDTYPE =linea;

                    M Offline
                    M Offline
                    Mycroft Holmes
                    wrote on last edited by
                    #12

                    I know where this may actually be valid. If the customer table is a monster and you need to do multiple complex joins and filtering then dropping them into table vars may be valid, 9 of them does seem somewhat excessive. It would depend on the downstream requirement.

                    Never underestimate the power of human stupidity RAH

                    D 1 Reply Last reply
                    0
                    • M Mycroft Holmes

                      I know where this may actually be valid. If the customer table is a monster and you need to do multiple complex joins and filtering then dropping them into table vars may be valid, 9 of them does seem somewhat excessive. It would depend on the downstream requirement.

                      Never underestimate the power of human stupidity RAH

                      D Offline
                      D Offline
                      David Skelly
                      wrote on last edited by
                      #13

                      Yes, but even if there are 9 variables, you don't need 9 different queries to populate them. I think that's the point of the OP. Instead of:

                      SELECT X INTO vX FROM CUSTOMERS WHERE IDTYPE =linea;
                      SELECT Y INTO vY FROM CUSTOMERS WHERE IDTYPE =linea;
                      SELECT Z INTO vZ FROM CUSTOMERS WHERE IDTYPE =linea;

                      you can do:

                      SELECT X, Y, Z INTO vX, vY, vZ FROM CUSTOMERS WHERE IDTYPE =linea;

                      The selection criteria in this case are identical for all 9 variables, so you can fetch them all in one hit.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups