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.

Set Options from a variable

2 posts in General Discussion Last posting was on 2005-03-31 12:40:36.0Z
Mike Allen mike Posted on 2005-03-31 02:22:50.0Z
Sender: 62c0.424b5c5f.846930886@sybase.com
From: Mike Allen mike@colorcentriccorp.com
Newsgroups: ianywhere.public.general
Subject: Set Options from a variable
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <424b5efa.62e2.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 30 Mar 2005 18:22:50 -0800
X-Trace: forums-1-dub 1112235770 10.22.241.41 (30 Mar 2005 18:22:50 -0800)
X-Original-Trace: 30 Mar 2005 18:22:50 -0800, 10.22.241.41
Lines: 10
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4323
Article PK: 8140

I am trying to set an option using a variable (within a
procedure)
Like:
declare myvar char(20)
set myvar = (....select option value from user...... )
set temporary option timestamp_format = myvar

The documentation states that a string or host variable is
ok however the result is that timestamp_format = 'myvar'
(literally)


Breck Carter [TeamSybase] Posted on 2005-03-31 12:40:36.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: Set Options from a variable
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <gkrn419d150jbon1fi6hi7b77j5t7hdk65@4ax.com>
References: <424b5efa.62e2.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
X-Original-NNTP-Posting-Host: bcarter.sentex.ca
X-Original-Trace: 31 Mar 2005 04:40:31 -0800, bcarter.sentex.ca
Lines: 60
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 31 Mar 2005 04:40:32 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 31 Mar 2005 04:40:36 -0800
X-Trace: forums-1-dub 1112272836 10.22.108.75 (31 Mar 2005 04:40:36 -0800)
X-Original-Trace: 31 Mar 2005 04:40:36 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4325
Article PK: 8141

The short answer: Use EXECUTE IMMEDIATE to specify a variable value.

The long answer...

The SET OPTION statement is a strange animal, a kind executable
directive. It interprets the option value differently from, say, a
value that might be coded in a SET assignment statement. In
particular, it does not *evaluate* the value but stores it as a
string, as-is.

Here is the full syntax (from my book):

<set_option> ::= <set_public_default_option>

| <set_user_default_local_option>

| <set_temporary_local_option>

<set_public_default_option>
::= SET [ EXISTING ] OPTION
PUBLIC "." <option_name> "=" [ <option_value> ]

<option_name> ::= <identifier> -- usually the
name of an existing option

<option_value> ::= string literal to be stored as the option value
| numeric literal to be stored as a string value
| <identifier> to be stored, as is, as a string value
| ON -- stored as 'ON'
| OFF -- stored as 'OFF'
| NULL -- to delete the entry at this level

<set_user_default_local_option>
::= SET OPTION <user_id> "." <option_name> "=" [ <option_value> ]

<user_id> ::= <identifier>

<set_temporary_local_option>
::= SET TEMPORARY OPTION <option_name> "=" [ <option_value> ]

Breck

On 30 Mar 2005 18:22:50 -0800, Mike Allen mike@colorcentriccorp.com
wrote:

>I am trying to set an option using a variable (within a
>procedure)
>Like:
>declare myvar char(20)
>set myvar = (....select option value from user...... )
>set temporary option timestamp_format = myvar
>
>The documentation states that a string or host variable is
>ok however the result is that timestamp_format = 'myvar'
>(literally)

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com