CR2008 - How to run a Stored Procedure using Command Window

Hi everybody,
To generate my reports, I always adopted the foll. strategy:
  (a) Create a SQL Stored Procedure (with Input parameters) in Management Studio
  (b) Design a report in Crystal Report using the SP as datasource
I want to experiment something different.
Instead of using the SP as datasource, I wish to use the SQL Command window in CR2008.
I have never succeeded to make it work.
So, I am giving a simple example below , listing all my steps, so you can spot where my problem is:
(A) Create a simple Stored Procedure in SSMS called [dbo].[usp_2014]
USE [SIMUL02]
GO
/****** Object:  StoredProcedure [dbo].[usp_2014]    Script Date: 07/21/2014 12:40:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_2014] @Project nvarchar(15)
AS
SELECT DocEntry, DocDate, U_ShipDept, DocTotalSy FROM ORDR
WHERE U_ShipCode = @Project
(B) Create a Crystal Report called TEST.rpt
      I typed the following in the Command Window (see Capture.jpg)
          {CALL "SIMUL02"."dbo"."usp_2014";1({?Project1})}
(C) I verify the database. I get this error message:
      Failed to retrieve data from the database
        Invalid character value for cast specification
I am blocked from here.
Please let me know what has gone and what I must do to continue my tests.
Thanks
Leon Lai

Hi Abhilash
I copied and pasted your formula:
Exec "SIMUL02"."dbo"."usp_2014" '{?Project}'
Now it works!
So, probably I typed something wrong, and did not notice
Thanks a lot for your patience and great reply
Closing
Leon Lai

Similar Messages

  • Running a stored procedure using  isqlPlus

    I have written a simple stored procedure which takes EMPLOYEE_ID as IN parameter returns EMPLOYEE_FIRST_NAME as OUT parameter (For Learning purpose only)
    How do I run this stored procedure using isqlPlus.
    Below is my stored procedure.
    CREATE OR REPLACE PROCEDURE "HR"."MY_PROC_2" (
    EMPLOYEE_ID_NUM in NUMBER,
    EMPLOYEE_FIRST_NAME out VARCHAR2
    as
    begin
    Select FIRST_NAME into EMPLOYEE_FIRST_NAME from Employees
    where Employee_ID = EMPLOYEE_ID_NUM;
    return;
    end;

    did you run that same procedure in SQL*Plus and it functioned ?
    Joel P�rez

  • Need an Example for How to call a Stored Procedure using DBAdapter

    Hi
    I am trying to invoke a stored procedure in Oracle Database using DB Adapter. I have successfully invoked and when i try to run it i got the following error.
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : Exception occured when binding was invoked.
    Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ExecuteScript' failed due to:
    Stored procedure invocation error.
    Error while trying to prepare and execute the RESONANCEDEMO.SP_QUERY API.
    An error occurred while preparing and executing the RESONANCEDEMO.SP_QUERY API. Cause: java.sql.SQLSyntaxErrorException: ORA-00917: missing comma
    ORA-06512: at "RESONANCEDEMO.SP_QUERY", line 7
    ORA-06512: at line 1
    Check to ensure that the API is defined in the database and that the parameters match the signature of the API.
    This exception is considered not retriable, likely due to a modelling mistake.
    To classify it as retriable instead add property nonRetriableErrorCodes with value "-917" to your deployment descriptor (i.e. weblogic-ra.xml).
    To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.
    All properties are integers.
    I am trying to have a Out Parameter in my Procedure. Please provide me an example on how to invoke a Stored Procedure using Out Paramter using DB Adapter.

    Hi,
    It looks more like an Oracle error and not within the DbAdapter.
    Try to test first your procedure from PL/SQL or other developer you are using.
    Arik

  • How to call a stored procedure using its package name in Oracle

    hi
    we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
    i have got 2 queries:
    1- How to call the stored procedure using it's package.
    2- How to capture the In/Out parameter in the response.

    hi Prateek
    thanks for the reply.
    However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
    As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
    How to get the IN-OUT parameter in XI?

  • How to call java stored procedure using RMI?

    Is it possible to make a call to java stored procedure using RMI. ?
    How can I run the RMI registry on the Oracle Server ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Thomas Grounds ([email protected]):
    Is it possible to make a call to java stored procedure using RMI. ?
    In principle it is possible. See the Java-Doc.s of Oracle 8.1.6.
    I have successful granted the java.net.SocketPermissions in my USER_JAVA_POLICY view (see Doc.) Now I was able to use the RMI-Sockets, but following
    failure try to connect to RMI-Object via RMIregistry an Oracle Error occurs
    ORA-03113: end-of-file on communication channel
    and after that my Oracle Connection is closed.
    How can I run the RMI registry on the Oracle Server ?<HR></BLOCKQUOTE>
    I think you do not need the RMI registry on Oracle Server. It should be possible to start the RMI registry wherever you want in your network and access it via the right registry string.
    Ciao
    Margit
    null

  • How to call Oracle Stored Procedure using EDQ

    Can someone tell me how to use Oracle Stored Procedure call in EDQ, sample scripts/steps will be really helpful. Thanks!

    It is also possible to do this using a custom processor in EDQ. The processor needs to do something very similar to the external task above (opens a DB connection, authenticates, runs a stored procedure).
    If you need this, please talk us through the use case so we can determine if it is the best fit. In some ways, an external task is better as logically a stored procedure call is normally divorced from any process logic in EDQ.
    Regards,
    Mike

  • How to execute MYSQL stored procedure  using java

    Hello friend
    I am very new to MYSQL stored procedure how to call external stored procedure , from where i got good tutorials about MYSQL stored procedure and JAVA

    If you need help with MYSQL or stored procedures this is not the place. If you need help with JDBC:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html

  • How to run oracle stored procedure dynamically

    How can I call a stored procedure dynamically. My requirement is to call a stored procedure based on user selection on a parameter screen. I do not want to hardcode proocedure name, but rather call dynamically.
    If I use the same methodology as of running dynamic sql's Iam getting an error.
    "invalid SQL statement after call to procedure"
    v_cursorid INTEGER;
    v_cnt NUMBER;
    v_sqlstring VARCHAR2(2000);
    v_sqlstring := 'execute insert_job_status('''||TO_CHAR(SYSDATE,
    'dd-mon-yyyy HH:mi:ss')||''');';
    v_cursorid := dbms_sql.open_cursor;
    dbms_sql.parse(v_cursorid, v_sqlstring, dbms_sql.v7);
    --cnt        := dbms_sql.execute(v_cursorid);
    dbms_sql.close_cursor(v_cursorid);

    EXECUTE is a SQL*Plus command. try
    v_sqlstring := 'begin  insert_job_status('''||TO_CHAR(SYSDATE,
    'dd-mon-yyyy HH:mi:ss')||'''); end;';Cheers, APC

  • How to run a stored procedure in TOAD

    Hello,
    I created a simple stored procedure in the procedure editor in TOAD. It's just a simple 'Hello World' output statement. Here is the code:
    create or replace procedure new_proc is
    greetings varchar2(20);
    begin
    greetings := 'Hello World';
    dbms_output.put_line(greetings);
    end;
    The procedure created fine, but when I try to call it in the procedure editor or in the SQL Editor, both tools act as if the procedure cannot be found, and I get an error message.
    In SQL Editor, I type in:
    exec new_proc;
    and it says that "new_proc" is invalid.
    Does anyone know how to run this procedure in TOAD?
    Thanks,
    Peter
    Message was edited by:
    P. Swanson

    Don't know about TOAD but this is how it is in SQL*Plus.
    SQL> create or replace procedure new_proc is
      2  greetings varchar2(20);
      3  begin
      4  greetings := 'Hello World';
      5  dbms_output.put_line(greetings);
      6  end;
      7  /
    Procedure created.
    SQL> set serveroutput on
    SQL>
    SQL> exec new_proc ;
    Hello World
    PL/SQL procedure successfully completed.
    SQL>Message was edited by:
    Kamal Kishore

  • How to run a stored procedure in TOAD 9.0

    Dear Friends,
    I am using TOAD 9.0 .
    Running a procedure but getting the error ..
    create or replace PROCEDURE UPD_TBL(I_table_name IN VARCHAR2) IS
    CURSOR c_columns is select column_name from ALL_TAB_COLUMNS where
    TABLE_NAME = I_table_name;
    BEGIN
    FOR rec in c_columns
    LOOP
    IF ( rec.COLUMN_NAME = 'X_NNM_TYPE_CD' ) THEN
    UPDATE I_table_name set X_NNM_TYPE_CD = REPLACE (X_NNM_TYPE_CD, '-', '_')
    WHERE INSTR (X_NNM_TYPE_CD, '-') > 0 ;
    ELSIF ( rec.COLUMN_NAME = 'X_REVENUE_TYPE_CD' ) THEN
    UPDATE I_table_name set X_REVENUE_TYPE_CD = REPLACE (X_REVENUE_TYPE_CD, '-', '_')
    WHERE INSTR (X_REVENUE_TYPE_CD, '-') > 0 ;
    END IF;
    END LOOP;
    EXCEPTION
    when OTHERS then
    NULL;
    END UPD_TBL;
    ERROR: TABLE OR VIEW DOES NOT EXIST.
    Please let me know how to run the procedure in toad.
    thanks/kumar

    Kumar,
    At a minimum, you would need to remove both the exception handler in your procedure and the exception handler in your anonymous block. As has been mentioned before, the code
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;is almost always a bug. In your case, your code is almost certainly generating an exception and your exception handler is silently catching and ignoring that exception. If you care whether or not any rows are updated, that is a bug.
    Once you remove the exception handlers, you'll very likely discover that the SQL statements you are generating and executing dynamically are malformed. Off the top of my head, it would appear that there is no space between the table name and the SET keyword in the string you are constructing. That means that if I_TABLE_NAME is 'EMP', for example, you'd construct a statement like
    UPDATE empSET x_nnm_typ_cd = ...'Oracle would interpret empSET as the table name, it would interpret X_NNM_TYP_CD as a table alias, and then it would encounter the equals sign unexpectedly and generate a syntax error. You'd need to insert a space after the table name and before the SET keyword (note where folks inserted extra spaces in their sample code).
    In general, you are probably better served by having a local variable that you use to build up the SQL statement. That way, you can print (or log) the SQL statement that is constructed. When you encounter a syntax error at runtime, that will generally make debugging easier. So you'd probably want something like
      l_sql_stmt VARCHAR2(1000);
    BEGIN
      FOR rec IN cur_c_columns LOOP
        IF (rec.column_name = 'X_NNM_TYPE_CD') THEN
          l_sql_stmt :=
             'UPDATE '||i_table_name||
             ' SET x_nnm_type_cd = REPLACE(x_nnm_type_cd, ''-'', ''_'')'||
             'WHERE INSTR(x_nnm_type_cd, ''-'') > 0';
          dbms_output.put_line( l_sql_stmt );
          EXECUTE IMMEDIATE l_sql_stmt;
    ...When you get a syntax error, you can then take a look at the SQL statement that was generated and debug the problem more easily.
    Justin

  • How to execute a stored procedure using Nqcmd

    hi everyone,
    I am having a stored procedure in Database which i want to execute it from nqcmd. Could anyone pls let me know how to execute it.
    Regards

    EJB3 JPA does not define stored procedure execution. There is a native query in JPA, but this is mainly for SQL. If you stored procedure has no output parameters you can normally get away with using a native query to execute it (be sure to include BEGIN/END in Oracle).
    <p>
    In TopLink 11g preview there are JPA extensions for defining stored procedures. You can use the @NamedStoredProcedureQuery for this, and then access the named query by name and execute it. You can also create an instance of a TopLink StoredProcedureCall and set it in your JPA Query through the TopLink Query extension setDatabaseQuery(), or define the named stored procedure query using a DescriptorCustomizer.
    <p>
    In TopLink Essentials there is no direct stored procedure support, so you would need to use JDBC directly.
    <p>
    If you are using a DataSource in your application the best way to get a JDBC connection is to use your DataSource directly. If the DataSource is JTA managed this will be the same connection that TopLink writes with.
    <p>
    If you need to get the connection directly from TopLink you can use,
    ((oracle.toplink.<essentials>.ejb.cmp3.EntityManager)entityManager.getDelegate()).getUnitOfWork().getConnection();
    <p>
    You may need to first call, UnitOfWork.beginEarlyTransaction(), (also ensure you release the uow connection).
    <p>
    <p>---
    <p>James Sutherland

  • How to debug java stored procedures using jdwp with Eclipse IDE?

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

  • How to run a stored procedure from sqlplus

    scehma name: aa
    package name: bb
    procedure name : cc
    I run the procedure from sql plus like this...
    execute aa.bb.cc
    I got error " not defined procedure" any one knows why? thanks!

    Based on the information you provided:
    1. You are not connected as Schema aa
    2. Schema aa has not granted permission to you to execute package bb.
    To resolve this issue:
    Connect as schema aa
    execute following statement:
    Grant execute on bb to Your_userName;connect as Your_userName
    On SQL*Plus prompt now you can execute this procedure using:
    execute aa.bb.cc;Assuming there is no parameter for procedure cc.
    You can create synoyms also to avoid specifying "aa".
    Thanks,
    Dharmesh Patel

  • Sqlbase - how to run a stored procedure with SYSDATE argument

    Hi, everyone!
    I'm trying to execute a stored procedure :
    cstmt = con.prepareCall("{ call PR_MYPROCEDURE(?, SYSDATE-1, SYSDATE) }");
    cstmt.setInt(1,1);And i get and SqlException - java.sql.SQLException: prepareCall(): An unexpected character 'S' found.
    Is there any way to pass a SYSDATE like argument?

    the problem that for sqlbase current date function is SYSDATE'sqlbase' the database?
    I couldn't ensure that the syntax that you posted looks correct but it seems possible.
    That would suggest there is a driver problem.
    Best I can suggest is modify the proc so it expects nulls for two parameters and then it creates the expressions that you are passing. Or create java Timestamp values and pass those.

  • How to schedule a Stored procedure to run every hour in SQL server express

    Hi,
    I am using SQL server express and I want to schedule a Stored procedure to run every hour.
    The Stored Procedure name is UpdateData.
    Can someone please give an example of how i can schedule this to run every hour, given that I do not have SQL Server agent on my express edition.

    Hello,
    You will find more options on the following thread.
    http://stackoverflow.com/questions/1675206/how-to-run-a-stored-procedure-every-day-in-sql-server-express-edition
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

Maybe you are looking for