PL/SQL equivalent of Select 0, Select 1 etc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shay1975
    New Member
    • May 2007
    • 7

    PL/SQL equivalent of Select 0, Select 1 etc

    What is the equivalent of say...

    select @somevariable or select 3 in pl/sql?

    I am re-writing some existing sprocs in Oracle from SQL server and I need to return the value of a variable in a cursor

    OPEN IO_CURSOR FOR
    SELECT somevariable

    But this is not correct. Does anyone know the correct syntax?

    Thanks
  • frozenmist
    Recognized Expert New Member
    • May 2007
    • 179

    #2
    Hi,

    Try
    Select 3 from dual
    I hope I understood your problem
    Cheers

    Comment

    • Shay1975
      New Member
      • May 2007
      • 7

      #3
      I don't understand...es sentially I am trying to write the following in PL?SQL

      Declare @somevariable int

      SET @somevariable = 1

      SELECT @somevariable

      This will return the value 1 as a recordset

      How do you return the value of a variable in PL/SQL?

      Thanks

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Dear Shay

        Do u want to return some value through a procedure using PL/SQL



        Then write a procedure with out parameters.

        Comment

        • soumya1011
          New Member
          • May 2007
          • 3

          #5
          The equivalent for DECLARE @somevariable int would be
          somevariable number;

          to initialize it
          somevariable:=1 ;

          and you can select its value as
          SELECT somevariable FROM dual;

          If you want to select some value which is in a table then you can use this
          SELECT column_name
          INTO somevariable
          FROM table_name;

          Comment

          Working...