Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Create a Procedure or Function

3 posts in General Discussion Last posting was on 2007-07-19 17:04:04.0Z
Geoffrey Chambers Posted on 2007-07-17 21:22:01.0Z
Sender: 1f72.46755333.1804289383@sybase.com
From: Geoffrey Chambers
Newsgroups: ianywhere.public.general
Subject: Create a Procedure or Function
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <469d32f9.3fe3.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 17 Jul 2007 14:22:01 -0700
X-Trace: forums-1-dub 1184707321 10.22.241.41 (17 Jul 2007 14:22:01 -0700)
X-Original-Trace: 17 Jul 2007 14:22:01 -0700, 10.22.241.41
Lines: 14
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6134
Article PK: 2582

I was hoping to get some guidance here. I have a table with
several fields, some which are numeric. One field contains
the employees base rate and several fields contain cost for
various fringes. I want to create a procedure that would
take these fields and return a total. I know I could do this
by just adding up the fields. The problem comes in where I
have a bit field that returns true or false which tells me
if this particular employee get 1.5 * baserate for overtime.
There are also bit fields that say wether or not I have to
pay additional fringes on overtime. some is on all of them
others maybe on some of them. I really need to run a select
statement within my procedure to pull the information then
do some if else logic on that information. I really don't
know where to start, to write this function/procedure.


Breck Carter [Team iAnywhere] Posted on 2007-07-18 09:23:07.0Z
From: "Breck Carter [Team iAnywhere]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: Create a Procedure or Function
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <38mr93pfi2ved935ti6facfdeejk4ndj4d@4ax.com>
References: <469d32f9.3fe3.1681692777@sybase.com>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 208.253.124.99
X-Original-NNTP-Posting-Host: 208.253.124.99
Date: 18 Jul 2007 02:23:07 -0700
X-Trace: forums-1-dub 1184750587 208.253.124.99 (18 Jul 2007 02:23:07 -0700)
X-Original-Trace: 18 Jul 2007 02:23:07 -0700, 208.253.124.99
Lines: 74
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6135
Article PK: 2586

Some examples from my book...

3.10.1 IF and CASE Expressions

-----------------------------------------------------------------------------------
SELECT product.id,
product.quantity,
IF product.quantity < 20
THEN 'Understocked'
ELSE IF product.quantity > 50
THEN 'Overstocked'
ELSE ''
ENDIF
ENDIF AS level
FROM product
ORDER BY product.quantity;
-----------------------------------------------------------------------------------
SELECT CASE region
WHEN 'Western' THEN 1
WHEN 'Central' THEN 2
WHEN 'Eastern' THEN 3
ELSE 0
END AS sort_order,
region,
COUNT(*) AS orders
FROM sales_order
WHERE sort_order > 0
GROUP BY region
ORDER BY sort_order;
-----------------------------------------------------------------------------------
SELECT CASE
WHEN sales_rep = 129
AND region = 'Western'
THEN 1
WHEN region = 'Western'
THEN 2
WHEN region IN ( 'Eastern', 'Central' )
THEN 3
ELSE 0
END AS sort_order,
CASE sort_order
WHEN 1 THEN 'Western 129'
WHEN 2 THEN 'Other Western'
WHEN 3 THEN 'Eastern and Central'
END AS breakdown,
COUNT(*) AS orders
FROM sales_order
WHERE sort_order > 0
GROUP BY sort_order
ORDER BY sort_order;

On 17 Jul 2007 14:22:01 -0700, Geoffrey Chambers wrote:

>I was hoping to get some guidance here. I have a table with
>several fields, some which are numeric. One field contains
>the employees base rate and several fields contain cost for
>various fringes. I want to create a procedure that would
>take these fields and return a total. I know I could do this
>by just adding up the fields. The problem comes in where I
>have a bit field that returns true or false which tells me
>if this particular employee get 1.5 * baserate for overtime.
>There are also bit fields that say wether or not I have to
>pay additional fringes on overtime. some is on all of them
>others maybe on some of them. I really need to run a select
>statement within my procedure to pull the information then
>do some if else logic on that information. I really don't
>know where to start, to write this function/procedure.

--
Breck Carter [Team iAnywhere]
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
The book: http://www.risingroad.com/SQL_Anywhere_Studio_9_Developers_Guide.html
breck.carter@risingroad.com


Geoffrey Chambers Posted on 2007-07-19 17:04:04.0Z
Sender: 1f72.46755333.1804289383@sybase.com
From: Geoffrey Chambers
Newsgroups: ianywhere.public.general
Subject: Re: Create a Procedure or Function
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <469f9984.b1d.1681692777@sybase.com>
References: <38mr93pfi2ved935ti6facfdeejk4ndj4d@4ax.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 19 Jul 2007 10:04:04 -0700
X-Trace: forums-1-dub 1184864644 10.22.241.41 (19 Jul 2007 10:04:04 -0700)
X-Original-Trace: 19 Jul 2007 10:04:04 -0700, 10.22.241.41
Lines: 85
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6142
Article PK: 2591


> Some examples from my book...
>
> 3.10.1 IF and CASE Expressions
>
> ----------------------------------------------------------
> ------------------------- SELECT product.id,
> product.quantity,
> IF product.quantity < 20
> THEN 'Understocked'
> ELSE IF product.quantity > 50
> THEN 'Overstocked'
> ELSE ''
> ENDIF
> ENDIF AS level
> FROM product
> ORDER BY product.quantity;
> ----------------------------------------------------------
> ------------------------- SELECT CASE region
> WHEN 'Western' THEN 1
> WHEN 'Central' THEN 2
> WHEN 'Eastern' THEN 3
> ELSE 0
> END AS sort_order,
> region,
> COUNT(*) AS orders
> FROM sales_order
> WHERE sort_order > 0
> GROUP BY region
> ORDER BY sort_order;
> ----------------------------------------------------------
> ------------------------- SELECT CASE
> WHEN sales_rep = 129
> AND region = 'Western'
> THEN 1
> WHEN region = 'Western'
> THEN 2
> WHEN region IN ( 'Eastern', 'Central' )
> THEN 3
> ELSE 0
> END AS sort_order,
> CASE sort_order
> WHEN 1 THEN 'Western 129'
> WHEN 2 THEN 'Other Western'
> WHEN 3 THEN 'Eastern and Central'
> END AS breakdown,
> COUNT(*) AS orders
> FROM sales_order
> WHERE sort_order > 0
> GROUP BY sort_order
> ORDER BY sort_order;
>
> On 17 Jul 2007 14:22:01 -0700, Geoffrey Chambers wrote:
>
> >I was hoping to get some guidance here. I have a table
> with >several fields, some which are numeric. One field
> contains >the employees base rate and several fields
> contain cost for >various fringes. I want to create a
> procedure that would >take these fields and return a
> total. I know I could do this >by just adding up the
> fields. The problem comes in where I >have a bit field
> that returns true or false which tells me >if this
> particular employee get 1.5 * baserate for overtime.
> >There are also bit fields that say wether or not I have
> to >pay additional fringes on overtime. some is on all of
> them >others maybe on some of them. I really need to run a
> select >statement within my procedure to pull the
> information then >do some if else logic on that
> information. I really don't >know where to start, to write
> this function/procedure.
>
> --
> Breck Carter [Team iAnywhere]
> RisingRoad SQL Anywhere and MobiLink Professional Services
> www.risingroad.com
> The book:
>
http://www.risingroad.com/SQL_Anywhere_Studio_9_Developers_Guide.html
> breck.carter@risingroad.com

I actually have the book, I wasn't sure if what I wanted to
do should be placed in a seperate procedure or in the
original select. I think I know what to do now. I pull the
book out and review it.

Thanks