I created the following procedure in IQ

create procedure stage.test_proc
as
begin
declare @sql nvarchar(1000)
select @sql = 'select top 10 * into #temp from systable' execute(@sql)
select * from #temp
end

But I go the following error when I execute sp in interactive sql. what did I do wrong

Cursor not open SQLCODE=-180, ODBC 3 State="34000"

asked 08 Aug '14, 11:25

IQGeek's gravatar image

IQGeek
0336
accept rate: 50%

This is not the Sybase IQ forum (http://scn.sap.com/community/iq)

(09 Aug '14, 03:13) Vlad

Sybase IQ is SAP IQ.

permanent link

answered 13 Aug '14, 09:29

IQGeek's gravatar image

IQGeek
0336
accept rate: 50%

Yes - but this forum is concerned with SAP SQL Anywhere - a different product. There are some similarities in some of the tools but you are more likely to get help on a forum where people use the product you are asking about.

The problem could be with your

select @sql='select...'

statement. You could try using

SET @SQL='select....'

In Watcom-SQL syntax (rather than T-SQL that you seem to be using) this works (on SQL Anywhere v11.0.1):

alter procedure test_proc()
RESULT ( table_id unsigned int ,file_id smallint ,count unsigned bigint ,first_page smallint ,last_page int ,primary_root int ,creator unsigned int ,first_ext_page smallint ,last_ext_page smallint ,table_page_count int ,ext_page_count int ,object_id unsigned bigint ,table_name char(128) ,table_type char(8) ,view_def long varchar ,remarks long varchar ,"replicate" char(1) ,existing_obj char(1) ,remote_location long varchar ,remote_objtype char(1) ,srvid unsigned int ,server_type char(7) ,primary_hash_limit smallint ,page_map_start smallint ,source long varchar ,"encrypted" char(1)  ) 
begin 
declare @sql nvarchar(1000); 
set @sql = 'select top 10 * into #temp from systable';
execute immediate @sql; 
select * from #temp 
end

(13 Aug '14, 12:40) Justin Willey
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: 08 Aug '14, 11:25

question was seen: 1,223 times

last updated: 13 Aug '14, 12:45