I don't know how do I refer to predefined HTML files from SA16. Right now, in Stored Procedure, I LOAD HTML, into Table. Define cursor, read line by line and concatenate it select concatenated_var

Using webservice by RAW, refer to the STORED PROCEDURE to display to web.

SA16 webserver, how I am able to refer to SO CALLED HOME directory to display HTML ?

asked 25 Sep '13, 21:54

Ukraine's gravatar image

Ukraine
76336
accept rate: 0%


If you would like to host regular binary files from SQL Anywhere, you can create a raw web service (for example an 'assets' or 'static' service) that reads a binary file from the disk and sends it to back to the HTTP client. The service should take one parameter for the entire URL and use this to locate the appropriate file server side.

The one trick is sending the proper 'Content-Type' header so the browser knows how to interpret the results. This can be done by importing the apache file mime-types (which contains a mapping of file extensions to 'Content-Type' headers) into a table.

This handy guide walks through the proccess using the 'Directory Access Remote Server' feature although xp_file_read works as well.

Once you have created this service, you can place any style sheets or images in this folder and reference them at /static/ (where static is the name of the web service you created)

permanent link

answered 26 Sep '13, 08:03

Mikel%20Rychliski's gravatar image

Mikel Rychliski
2.1k1641
accept rate: 30%

edited 26 Sep '13, 08:18

using the 'Directory Access Remote Server' feature ...

With v16, you might use the new directory and file system functions, as well, such as sp_list_directory().

(26 Sep '13, 08:25) Volker Barth

SQL Anywhere's builtin HTTP server is based on services, not files or directories, so there is no "home directory". Even simple things like images have to be stored in the database and rendered by URLS that point to a service that returns the image.

When specifying URLs in the HTML code created by your SQL Anywhere web services, you can refer to other services in the same database, or to full file specifications on the hard drive where the SQL Anywhere engine is running... or (of course) any URL out there on the internet.

Please show use the exact HTML code you would use with an ordinary web server, and someone might suggest how to code it for use inside SQL Anywhere.

permanent link

answered 26 Sep '13, 07:36

Breck%20Carter's gravatar image

Breck Carter
27.0k444614889
accept rate: 21%

Note, when using SA 16, you can use the new "Disk Sandboxing" feature to allow file access only within the according directory structure - relative to your database file. Possibly that is comparable to your requirement of a "home directory".

(26 Sep '13, 07:43) Volker Barth

I am sorry I don't know how to reply. (this is not Answer)

Thank you very much two of you to provide me solution, it is very helpful and convince myself not to look for methods which might not be supported.

I have 2 environments, SQLAny12 in office due to connecting Oracle 10g, Oracle 11g and SQL Azure Server using Remote Server and Proxy tables because I am not able to use SQLAny16 to connect Oracle. Only SQLAny12.01 build 3475 can do it. I can't apply update to SQLAny12. (it might be required to post the issue but I satisfy SQLAny12 and also no idea SQLAny16 supported new Functions are applicable to my development) At home, SQLAny16/Ubuntsu 13.10 daily updated, office is Windows 7 enterprise(64bit) SPK1, i5 2500 3.3GHz 4GB mem

I just used to make web for management reports on Accounting, Sales/Purchase,Warehouse by Customer and/or Date, so result is Table or CrossTab. No decoration was made before such as Calendar to select date. Now JQuery, JQuery UI, Node, RactiveJS.... so many useful tools are available so I have tested it whether I can still catch up with those.

Please kindly advise me to lead correct way. (I am thinking to put unique No. column to each html file to reuse it) Stored Procedure (z.html can be either DATA{remove comment} or html file)

ALTER PROCEDURE "DBA"."test1"()
BEGIN
  DECLARE ref VARCHAR(10000);
  DECLARE buf varchar(200);
  declare doc_no cursor for select ref from out_buffer;

LOAD TABLE out_buffer FROM 'C:UsersE2481Documentshtml5dataz.html' delimited by '`'; //set ref='<html><head></head><body>

';

open doc_no; fetch next doc_no into buf; lp:LOOP if sqlcode <> 0 then leave lp; end if;

//set ref=ref+'<tr><td>'+buf+'</td></tr>';
set ref=ref+buf;
fetch next doc_no into buf;

end loop;

//set ref=ref+'

</body></html>'; CALL sa_set_http_header('Content-Type','text/html');

select ref; END

WebService(Service type Raw) select * from test1()

Z.html file(loading into Table: out_buffer)


<html lang="en-GB">

<head>

<meta charset="utf-8">

<title>Clock</title>

<link rel="stylesheet" href="http://10.99.7.192/styles/min.css">

<link rel="stylesheet" href="http://10.99.7.192/styles/styles.css">

</head>

<body>

clock

<script id="myTemplate" type="text/ractive">
<button proxy-click="zoom-in">Zoom IN</button> <button proxy-click="zoom-out">Zoom OUT</button>

Today is {{days[date.getDay()]}} the {{addSuffix(date.getDate())}} of {{months[date.getMonth()]}}. The time is:

{{pad(date.getHours())}}:{{pad(date.getMinutes())}}: {{pad(date.getSeconds())}}
<svg viewbox="0 0 100 100"> <g transform="translate(50,50) scale({{zoom}})"> <circle class="clock-face" r="48"/> {{#minor:i}}<line class="minor" y1="42" y2="45" transform="rotate({{360*i /minor.length}})"/>{{/minor}} {{#major:i}}<line class="major" y1="35" y2="45" transform="rotate({{360* i/ major.length}})"/>{{/major}} <line class="hour" y1="2" y2="-20" transform="rotate({{30*date.getHours()+date.getMinutes()/2}})"/> <line class="minute" y1="4" y2="-30" transform="rotate({{6*date.getMinutes()+date.getSeconds()/10}})"/> <g transform="rotate({{6*date.getSeconds()}})"><line class="second" y1="10" y2="-38"/><line class="second-counterweight" y1="10" y2="2"/></g> </g> <g font-family="sans-serif" font-size="10"> <text x="44" y="11" opacity="0.5">00</text> <text x="66" y="17" opacity="0.5" fill="red">01</text> <text x="78" y="34" opacity="0.5">02</text> <text x="86" y="54" opacity="0.5" fill="red">03</text> <text x="80" y="75" opacity="0.5">04</text> <text x="66" y="91" opacity="0.5">05</text> <text x="44" y="97" opacity="0.5">06</text> <text x="22" y="91" opacity="0.5">07</text> <text x="07" y="75" opacity="0.5">08</text> <text x="03" y="54" opacity="0.5">09</text> <text x="07" y="33" opacity="0.5">10</text> <text x="23" y="18" opacity="0.5">11</text> </g> </svg>
</script> <script src="http://10.99.7.192/js/Ractive.js"></script> <script> var ractive=new Ractive({ el: 'container', template: '#myTemplate', data:{ zoom:1.0, date:new Date(), days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], months:['January','February','March','April','May','June','July','August','September','October','November','December'], addSuffix:function(num){ if(num % 100 >= 10 && num % 100 <= 19){return num + 'th';} switch(num % 10){ case 1: return num+'st'; case 2: return num+'nd'; case 3: return num+'rd'; } return num + 'th'; }, pad: function(num ){return(num < 10 ? '0' + num : num); }, major: new Array(12), minor: new Array(60) } }); setInterval(function(){ractive.set('date',new Date());},1000); ractive.on('zoom-in',function(event){ractive.set( 'zoom',ractive.get('zoom' )+0.05);}); ractive.on('zoom-out',function(event){ractive.set( 'zoom',ractive.get('zoom' )-0.05);}); </script> </body> </html>
permanent link
This answer is marked "community wiki".

answered 26 Sep '13, 21:49

Ukraine's gravatar image

Ukraine
76336
accept rate: 0%

edited 27 Sep '13, 07:34

Breck%20Carter's gravatar image

Breck Carter
27.0k444614889

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×34

question asked: 25 Sep '13, 21:54

question was seen: 1,197 times

last updated: 27 Sep '13, 07:34