Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2013
    Posts
    6

    Question Unanswered: Column datatype in Sybase

    I am new in Sybase programming.

    Is there any way to declare a variable of type, same as the type of a column in a particular table?

    Commonly in Oracle we can declare a variable as

    DECLARE
    empId EMP.emp_no%type := 28646;

    Is there anything similar in Sybase?

  2. #2
    Join Date
    Dec 2013
    Posts
    14
    NOTE: I'm assuming you're talking about the Sybase ASE (Adaptive Server Enterprise) product. If you're talking about the Sybase SQLAnywhere, Sybase IQ or Sybase Advantage database products ... *shrug* ... you'll need to explicitly state which product you're using so that someone else can jump in here with comments. Back to ASE ...

    ASE does not provide the same sort of declare-by-referencing-a-column ability that you list. It is up to the developer to declare the @variable with the same datatype as the column in question.

    So for example, if you created your table with 'create table mytab (col1 int, col2 datetime, ...)' then your variable declarations would look like:

    declare @var1 int, -- to match mytab.col1
    @var2 datetime -- to match mytab.col2

    Also, ASE does not provide for declaring a variable and assigning a value in a single command, ie, the declaration and assignment require 2 separate commands.

  3. #3
    Join Date
    Dec 2013
    Posts
    6
    Thanks for your reply. I am using Sybase Advantage here.

Posting Permissions

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