Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:16:02+00:00 2026-06-04T06:16:02+00:00

Simple example using oratcl: Create Table and simple package CREATE TABLE test (id INTEGER,val

  • 0

Simple example using oratcl:

Create Table and simple package

CREATE TABLE test (id INTEGER,val INTEGER);
INSERT INTO test (id,val) values (1,10);
INSERT INTO test (id,val) values (2,20);
INSERT INTO test (id,val) values (3,30);
INSERT INTO test (id,val) values (4,40);


CREATE OR REPLACE PACKAGE  tst is
  FUNCTION get_test RETURN sys_refcursor;
END; 
/

CREATE OR REPLACE  PACKAGE BODY tst is
  FUNCTION get_test  RETURN sys_refcursor
IS
   retval sys_refcursor;
BEGIN
    OPEN retval FOR SELECT * FROM test ORDER BY id;
 RETURN retval;
END;
END;
/

Tcl functions are below:

package require Oratcl

proc getLoginStr {} {
   set userName  "xxx"
   set password  "xxxx"
   set db        "xxx"
   append retval  $userName "/" $password "@" $db
}

set _lda ""
set _sqlH ""

proc init {} {
  global _lda
  global _sqlH
 set _lda [oralogon [getLoginStr]]
 set _sqlH [oraopen $_lda]
}

proc prepare {} {
  global _sqlH
  set Sql {
         begin
             :retval := tst.get_test();
         end;                   
 }

 ::db_ora::parseSql $_sqlH $Sql 
}

proc go {} {
  global _lda
  global _sqlH

  set curH [oraopen $_lda]
  set pv_lst [list :retval $curH] 

  orabind $_sqlH  :retval $curH
  oraexec $_sqlH

  set retval ""

  while {[orafetch $curH -datavariable row] == 0} {
    puts "row : $row" 
    lappend retval  $row
  }
return $retval
}

Run following script once:

source test.tcl
init
prepare
go

Output:

row : 1 10
row : 2 20
row : 3 30
row : 4 40
{1 10} {2 20} {3 30} {4 40}

re-Run go procedure

go

Output:

row : 
row : 
row : 
row : 
row : 
row : 
row : 
row : 
row : 
row : 
ORA-24338: statement handle not executed

Any Ideas? Why script did not work on re-run? If I am not mistaken it should reuse the opened handle _SqlH.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:16:04+00:00Added an answer on June 4, 2026 at 6:16 am

    I think you don’t need tcl to see this behavior. You can reproduce this with plain SQL. Once you have iterated over the sys_refcursor that has been returned by tst.get_test(), you cannot “rewind” it and iterate again.

    Consult the docs on how to use ref_cursors (10.2) http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i7106

    So in this current form, you can only run the tcl goagain after you also run prepare again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

simple example in Notepad++ using RegEx replace search for: anything replace with (wanted): \test
Update : Added simple test example http://jsfiddle.net/7UhrW/1/ using normalize.css. Chrome/WebKit and Firefox have different
I'm trying to create a simple WebSocket example using the HTML5/JS API. Based on
Could someone provide a simple example using getopt.pas with short and long command line
I have this simple example: using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program
I'm trying to do a simple example using jQuerys fadeTo method. It works as
I am learning and trying simple example using node.js and mongoskin. here is my
I have this very simple example that I am using to learn structs in
I wrote a simple example, which estimates average time of calling virtual function, using
I'm trying to follow the simple example of using a DataView with the SlickGrid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.