Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012

    Unanswered: how to get the quantity from output of sql query command

    I want to know how to get the quantity from output of sql query command

    for example, I could get the container name by below command

    select container_name from sysibmadm.snapcontainer

    get the container number by


    now I want to get the container number by below command output result
    select container_name from sysibmadm.snapcontainer
    so what more command should I add on above command, I mean I want to get the container number by container name from the output of above command, not by 'join'.
    Thank you in advance.

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    post CREATE TABLE statements for both SNAPCONTAINER & SNAPTBSP_PART tables
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Why "not by join"? Joins are designed for such purposes.

    Anyway: you might create a function which will pass container number and return container name. For example (as you didn't provide test case, this one is based on Scott's schema - a function returns department name).

    This is how I'd normally return department name - using a join:
    SQL> select e.ename, e.job, e.sal, d.dname
      2  from emp e, dept d
      3  where e.deptno = d.deptno
      4    and e.ename = 'ADAMS';
    ENAME      JOB              SAL DNAME
    ---------- --------- ---------- --------------
    ADAMS      CLERK           1100 RESEARCH
    Now, create a function:
    SQL> create or replace function fun_dname (par_deptno in number)
      2    return varchar2
      3  is
      4    retval dept.dname%type;
      5  begin
      6    select dname
      7      into retval
      8      from dept
      9      where deptno = par_deptno;
     11    return (retval);
     13  exception
     14    when no_data_found then
     15      return (null);
     16  end;
     17  /
    Function created.
    Use it!
    SQL> col d_name format a15
    SQL> select ename, job, sal, fun_dname(deptno) d_name
      2  from emp
      3  where ename = 'ADAMS';
    ENAME      JOB              SAL D_NAME
    ---------- --------- ---------- ---------------
    ADAMS      CLERK           1100 RESEARCH
    Is this what you are looking for?

Posting Permissions

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