cancel
Showing results for 
Search instead for 
Did you mean: 

SQLA always add double quotation marks (")

Former Member
3,599

I really have problem in my SQL Anywhere. I'm using SQL Anywhere 16.

when i write something like this example :

declare var_x int;
declare var_y int;
select dateformat ( current date, 'dd-mm-yyyy' ) as tgl , substr ('123456', 1, 3) as col2;

when it save and then i look again, it being like this

declare "var_x" int;
declare "var_y" int
select "dateformat" ( current date, 'dd-mm-yyyy' ) as tgl , "substr" ('123456', 1, 3) as col2;

SQL Anywhere always add double quotation marks (").

where is the setting which requires that marks or to remove the marks?

I hope from this forum i will find the answer.

Accepted Solutions (0)

Answers (1)

Answers (1)

Breck_Carter
Participant

SQL Anywhere saves stored procedure source code in one or two formats: it always saves a slightly mangled version in SYSPROCEDURE.proc_defn (which is what you are seeing), and optionally saves the original version in SYSPROCEDURE.source.

Here is a demonstration...

CREATE PROCEDURE p() BEGIN
declare var_x int;

declare var_y int;

select dateformat ( current date, 'dd-mm-yyyy' ) as tgl , substr ('123456', 1, 3) as col2;
END;

SELECT proc_defn, source FROM SYSPROCEDURE WHERE proc_name = 'p';

create procedure "DBA"."p"() begin
  declare "var_x" integer;
  declare "var_y" integer;
  select "dateformat"(current date,'dd-mm-yyyy') as "tgl","substr"('123456',1,3) as "col2"
end

create PROCEDURE p() BEGIN
declare var_x int;

declare var_y int;

select dateformat ( current date, 'dd-mm-yyyy' ) as tgl , substr ('123456', 1, 3) as col2;
END

This PRESERVE_SOURCE_FORMAT controls whether or not SYSPROCEDURE.source will be filled. To see your current setting:

SELECT CONNECTION_PROPERTY ( 'PRESERVE_SOURCE_FORMAT' );

CONNECTION_PROPERTY('PRESERVE_SOURCE_FORMAT')
'On'

To set the option...

SET OPTION PUBLIC.PRESERVE_SOURCE_FORMAT = 'ON';
Former Member
0 Kudos

Thank you Mr. Carter for the advice, but we still have problems. we have 2 servers and we use the same settings. The PRESERVE_SOURCE_FORMAT we set "OFF". Then results in the first server on "proc_defn" give the same results without the double quotes. while the second server with the same settings give results with the addition of double quotation. hope you can help further. Thank you.

Breck_Carter
Participant

I don't know (and I don't care) what proc_defn contains... it is not what you want.

If you want to preserve the source code formatting in the future, you MUST set PRESERVE_SOURCE_FORMAT to ON.

Then, if you want to fix the procedures that already exist, you will have to re-CREATE or ALTER them to store the properly-formatted source code. There is no magic way to recreate the original format.

I strongly suggest to keep the original source code for all procedures and triggers in text files outside the database, just like you do for all other forms of source code. Then you can exercise control over your source code.

Former Member
0 Kudos

Thank you very much for the answer

My point is, there are two servers with the same settings but produces a different syntax.

Here's an example of what I do

server1:

dbms = sap sqlanywhere 16

PRESERVE_SOURCE_FORMAT = 'Off'

server2:

dbms = sap sqlanywhere 16

PRESERVE_SOURCE_FORMAT = 'Off'

source:

CREATE PROCEDURE p ()

BEGIN

var_x declare int;

var_y declare int;

select dateformat (current date, 'dd-mm-yyyy') as of date, substr ('123456', 1, 3) as col2;

END;

The results (fill in the fields proc_defn):

server1:

CREATE PROCEDURE p ()

BEGIN

var_x declare int;

var_y declare int;

select dateformat (current date, 'dd-mm-yyyy') as of date, substr ('123456', 1, 3) as col2;

END;

server2:

CREATE PROCEDURE p ()

BEGIN

declare "var_x" int;

declare "var_y" int;

select "dateformat" (current date, 'dd-mm-yyyy') as of date, "substr" ('123456', 1, 3) as col2;

END;

That is what I see when I save and reopen it. In this case I use is the central Sybase 6.