?
Solved

proc program returns ora-01458

Posted on 2002-04-11
6
Medium Priority
?
2,505 Views
Last Modified: 2010-10-05
hello.

i have got a proc program that worked good on oracle 7, i compiled it to work with oracle 8 and when i try to tun it i get ora-01458 .

the problem is in the line :

dbms_output.get_line (:outtxt,:status);

the declaration of the relevant varaibles :

exec sql
   BEGIN DECLARE SECTION;
      VARCHAR  outtxt[255];
      int      status;
exec sql
   END DECLARE SECTION;

does anyone knows whay it doesnt work ?

tx.
   hagai.
0
Comment
Question by:hagaiy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 48

Expert Comment

by:schwertner
ID: 6933618
ENABLE Procedure
This procedure enables calls to PUT, PUT_LINE, NEW_LINE, GET_LINE, and GET_
LINES. Calls to these procedures are ignored if the DBMS_OUTPUT package is not
enabled.
If there are multiple calls to ENABLE, then buffer_size is the largest of the values
specified. The maximum size is 1,000,000, and the minimum is 2,000.
Syntax
DBMS_OUTPUT.ENABLE (
buffer_size IN INTEGER DEFAULT 20000);
Note: It is not necessary to call this procedure when you use the
SERVEROUTPUT option of Enterprise Manager or SQL*Plus.
0
 
LVL 1

Author Comment

by:hagaiy
ID: 6933770
i have this call on my program, this is the full program :



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR  username[20];
    VARCHAR  password[20];
      VARCHAR  ora_sql_command[500];
EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE SQLCA;

void main( int argc, char *argv[] )
{
   EXEC SQL INCLUDE sqlca.h;
   char *octo_env;
   char *exec_str;
   char *sql_cmd;
   char *procname;
   char *params;
   int args_len;
   int counter;
   int buf_size;
   int args_no;
   char msg[200];
   size_t buf_len, msg_len;

   exec sql
      BEGIN DECLARE SECTION;
         VARCHAR  outtxt[255];
         int      status;
   exec sql
      END DECLARE SECTION;

   /* Finding which enviroment do we work in */

   octo_env = getenv("OCTO_ENV");
   if ( !octo_env )
   {
      printf ("ERROR: enviroment OCTO_ENV must be declared.\n");
      exit(2);
   }
 
    strcpy (username.arr,"octo");
    strcat (username.arr,octo_env);
    username.len=strlen(username.arr);
    strcpy (password.arr,username.arr);
    password.len=strlen(password.arr);
   
 
 
 
   /* Checking for the number of arguments */
 
   args_no = argc - 1;
   if ( args_no < 1 )
   {
      printf("No procedure name\n");
      exit(2);
   }

   /* Connecting to the database */

   exec sql
      whenever sqlerror goto connect_error;
   exec sql
      connect :username identified by :password;

   /* Finding the procedure-name */

   procname = (char *) malloc ( sizeof(char) * strlen(argv[1]));
   if (!procname)
   {
      perror("malloc(procname) failed");
      exit(1);
   }

   strcpy (procname, argv[1]);
 
   /* Finding the length of the arguments */

   args_len = 0;
   for (counter=2;counter<=args_no;counter++)
   {
      args_len = args_len + strlen(argv[counter]) + 1;
   };
   args_len = args_len + 3;
 
   /* Preparing the paramters string */

   params = (char *) malloc ( sizeof(char) * args_len);  
   if (!params)
   {
      perror("malloc(username) failed");
      exit(1);
   }

   if ( args_no > 1 )
   {
      strcpy (params,"(");
      for (counter=2;counter<args_no;counter++)
      {
         strcat(params,argv[counter]);
         strcat(params,",");
      }
      strcat(params,argv[args_no]);
      strcat(params,");");
   }
   else
   {
      strcpy (params,";");
   }

   /* Making the executing string */

   exec_str = (char *) malloc ( sizeof(char) * strlen(params)+strlen(procname));
   if (!exec_str)
   {
      perror("malloc(exec_str) failed");
      exit(1);
   }

   strcpy (exec_str,procname);
   strcat (exec_str,params);

   /* Making the sql command to execute and executing it */

   sql_cmd = (char *) malloc ( sizeof(char) * strlen(exec_str) + 15);
   if (!sql_cmd)
   {
      perror("malloc(sql_cmd) failed");
      exit(1);
   }

   strcpy (sql_cmd,"begin ");
   strcat (sql_cmd,exec_str);
   strcat (sql_cmd," end;");
   strcpy (ora_sql_command.arr,sql_cmd);
   ora_sql_command.len = strlen(ora_sql_command.arr);
   
   /* Enabling the buffer for dbms_output */

   exec sql
      execute
         begin
            /*buf_size =  */
            dbms_output.enable(1000000);
         end;
      end-exec;
 
   exec sql
      whenever sqlerror goto exec_error;
   exec sql execute immediate :ora_sql_command;

   //exec sql
   //whenever sqlerror continue;

   /* Printing the output */

     exec sql
      execute
         begin
            dbms_output.get_line (:outtxt,:status);
         end;
      end-exec;
 
   while ( !status)
   {
      outtxt.arr[outtxt.len]='\0';
      printf ("%s\n",outtxt.arr);
      exec sql
         execute
            begin
               dbms_output.get_line (:outtxt,:status);
            end;
         end-exec;
   }

   /* Freeing the memory of the buffer */

   exec sql
      execute
         begin
            dbms_output.disable;
         end;
      end-exec;

   exit(0);

   /* Error in the connection */

   connect_error:
      fprintf(stderr,"%s: Cannot connect to the database\n",argv[0]);
      exit(2);

   exec_error:
      buf_len = sizeof (msg);
      sqlglm(msg, &buf_len, &msg_len);
      printf ("%.*s\n", msg_len, msg);
      exit(1);
}
0
 
LVL 22

Expert Comment

by:DrSQL
ID: 6934097
hagaiy,
    The question is: what's in the buffer that it's reading (get_line)?  It seems empty.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 4

Expert Comment

by:Bhatti
ID: 6934133
You buffer length is 2 byte. Increase it and will work.


Bhatti
0
 
LVL 7

Accepted Solution

by:
waynezhu earned 1200 total points
ID: 6934169
There are some changes were made for Pro*C pre-compiler
from 7 to 8.

You need to initialize the length of OUT variable to avoid the error in 8, by adding a line, such as:

-------------------------------------------------------
exec sql
  BEGIN DECLARE SECTION;
     VARCHAR  outtxt[255];
     int      status;
exec sql
  END DECLARE SECTION;

outtxt.len=255;
-------------------------------------------------------
0
 
LVL 1

Author Comment

by:hagaiy
ID: 6939651
tx alot, that solved my problem.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question