Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in August and this forum will be retired.

I'm attempting to load the result set from the sa_disk_free_space system stored procedure so that I can manipulate it and present it in MB. Below is what I have so far.

BEGIN 
    DECLARE LOCAL TEMPORARY TABLE varMoveToSQL 
        (mydbspace_name nvarchar(20), myfree_space int, mytotal_space int);

    WITH Dataset (dbspace_name,free_space,total_space) AS (
                EXEC  sa_disk_free_space
                )

    INSERT INTO varMoveToSQL SELECT * FROM Dataset;

    SELECT * FROM varMoveToSQL;
END

asked 01 Mar '19, 14:37

dangris's gravatar image

dangris
69226
accept rate: 0%

edited 06 Mar '19, 03:12

Mark%20Culp's gravatar image

Mark Culp
25.0k10142298


It is way easier with SQL Anywhere. You can simply use a stored procedure in the FROM clause of a SELECT or INSERT, no need to store the procedure's result set in a temporary table.

Just something like "select * from my_proc(params) sp where..."

permanent link

answered 01 Mar '19, 15:09

Volker%20Barth's gravatar image

Volker Barth
40.4k365554826
accept rate: 34%

edited 01 Mar '19, 15:09

...for example:

SELECT *
  FROM sa_disk_free_space();

dbspace_name,free_space,total_space 'system',331786121216,979443380224 'translog',331786121216,979443380224 'temporary',331786121216,979443380224

If you really want a separate local temporary table...

SELECT *
  INTO #varMoveToSQL
  FROM sa_disk_free_space();

SELECT * FROM #varMoveToSQL;

dbspace_name,free_space,total_space 'system',331776749568,979443380224 'translog',331776749568,979443380224 'temporary',331776749568,979443380224

(02 Mar '19, 09:03) Breck Carter

Thanks for the quick response. That's exactly what I needed.

(04 Mar '19, 09:26) dangris
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:

×248

question asked: 01 Mar '19, 14:37

question was seen: 894 times

last updated: 06 Mar '19, 03:12