use session: cursor is released

Fernando Ortiz <[email protected]>
Newsgroups gmane.comp.lang.4gl.aubit.general
Message-ID <CAKK5tB3KPFomxox1C2v+2148s7a66LTRz+FrQTwK9z6A2qV0mw@mail.gmail.com>
Hi,

I want to insert some data  in a 'remote' database, I normally use
'session' for this, but when there is a open cursor it's released.

I 'remember' there is a 'default' session,  can I use it to avoid this?

Or maybe the session identifier be passed as parameter between modules?


[ortiz@adela tmp]$ ./sess1.4ae
Err:Program ./sess1.4ae stopped at 'sess1.4gl', line number 26.
Error status number -1.
cursor "sess1_c_t1" does not exist.

4gl function call stack :
    MAIN

{ environment}
A4GL_LEXDIALECT=INFORMIX
A4GL_LEXTYPE=C
A4GL_SQLTYPE=pg8

A4GL_ALWAYS_CAST=N
A4GL_COMPILE_ALONE=Y
A4GL_DATEASLONG=Y

{ sess1.4gl }
database test1

main
define lv_id int
define lv_desc char(3)

{ setup tables .... }
database test1
whenever error continue
drop table test1
whenever error stop
create table test1 (iden integer, descript char(3))
    insert into test1 values (1,'aaa')
    insert into test1 values (2,'bbb')
    insert into test1 values (3,'ccc')
database test2
whenever error continue
drop table test2
whenever error stop
create table test2 (iden integer, descript char(3))
database test1
{ end of set up   }

    set session to default
declare c_t1 cursor for select iden from test1
foreach c_t1 into lv_id
    call copy_id(lv_id)
end foreach

{ check info is there }
database test2
declare c_t2 cursor for select iden, descript from test2
foreach c_t2 into lv_id, lv_desc
    display lv_desc
end foreach
{ end check }
end main

{ for test in same module, the solution should work in another module }
function copy_id(p_id)
    define p_id int
    define lv_desc char(3)

    open session remote to database "test2"
    open session here to database "test1"
    use session here for
       select descript into lv_desc from test1 where iden = p_id
    use session remote for
       insert into test2 values (p_id, lv_desc)
end function

Regards

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.