pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Keith Worthington <keithw@narrowpathinc.com>
To: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: "CASE" is not a variable
Date: Wed, 28 Jun 2006 12:00:20 -0400
Message-ID: <20060628154728.M33440@narrowpathinc.com> (raw)

Hi All,

The following is a section of code inside an SQL function.   When I attempt to
run it I get the error message '"CASE" is not a variable'.  If I split this into
two queries (one for each variable) it works fine.  Obviously I have a work
around but I would like to understand what I am doing wrong.  TIA

SELECT tbl_item_bom.so_subline INTO v_so_subline,
       CASE WHEN tbl_mesh.mesh_type = 'square' THEN
                 ( CASE WHEN tbl_mesh.unit_of_measure = 'in' THEN          
tbl_mesh.mesh_size
                        WHEN tbl_mesh.unit_of_measure = 'ft' THEN 12.0    *
tbl_mesh.mesh_size
                        WHEN tbl_mesh.unit_of_measure = 'mm' THEN 25.4    *
tbl_mesh.mesh_size
                        WHEN tbl_mesh.unit_of_measure = 'cm' THEN  2.54   *
tbl_mesh.mesh_size
                        WHEN tbl_mesh.unit_of_measure = 'm'  THEN  0.0254 *
tbl_mesh.mesh_size
                        ELSE 0
                   END
                 )
       WHEN tbl_mesh.mesh_type = 'diamond' THEN
                 ( CASE WHEN tbl_mesh.unit_of_measure = 'in' THEN          
tbl_mesh.mesh_size / 2.0
                        WHEN tbl_mesh.unit_of_measure = 'ft' THEN 12.0    *
tbl_mesh.mesh_size / 2.0
                        WHEN tbl_mesh.unit_of_measure = 'mm' THEN 25.4    *
tbl_mesh.mesh_size / 2.0
                        WHEN tbl_mesh.unit_of_measure = 'cm' THEN  2.54   *
tbl_mesh.mesh_size / 2.0
                        WHEN tbl_mesh.unit_of_measure = 'm'  THEN  0.0254 *
tbl_mesh.mesh_size / 2.0
                        ELSE 0
                   END
                 )
       ELSE 0
       END INTO v_mesh_size
  FROM sales_order.tbl_item_bom
  LEFT JOIN peachtree.tbl_mesh
    ON tbl_item_bom.item_id = tbl_mesh.item_id
 WHERE tbl_item_bom.so_number = rcrd_line.so_number
   AND tbl_item_bom.so_line = rcrd_line.so_line
   AND tbl_item_bom.component_type = 'net';

Kind Regards,
Keith



view thread (6+ messages)  latest in thread

Message-ID: <20060628154728.M33440@narrowpathinc.com>
Permalink:  ../20060628154728.M33440@narrowpathinc.com/
Also on:    postgresql.org/message-id/20060628154728.M33440@narrowpathinc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: keithw@narrowpathinc.com
  Subject: Re: "CASE" is not a variable
  In-Reply-To: <20060628154728.M33440@narrowpathinc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox