USING DBMS_SQL WITH A PARAMETERIZED DML STATEMENT

create or replace procedure insert_row ( table_name varchar2, id varchar2,name varchar2, region number) is
csr_id integer;
stmt varchar2(200);
rows_added number;
begin
stmt := ' INSERT INTO ' || table_name || ' VALUES ( :cid , :cname, :rid ) ' ;
csr_id := dbms_sql.open_cursor ;
dbms_sql.parse( csr_id , stmt , dbms_sql.native) ;
dbms_sql.bind_variable( csr_id , ' :cid ' , id );
dbms_sql.bind_variable ( csr_id , ' :cname ' , name) ;
dbms_sql.bind_variable( csr_id , ' :rid ' , region );
rows_added := dbms_sql.execute ( csr_id);
dbms_sql.close_cursor( csr_id);
dbms_output.put_line( rows_added);
end;
execute insert_row( ' countries ' , ' ZA ', ' SOUTH AFRICA ', 4);
Procedure created.
BEGIN insert_row( ' countries ' , ' ZA ', ' SOUTH AFRICA ', 4); END;
ERROR at line 1:
ORA-01006: bind variable does not exist
ORA-06512: at "SYS.DBMS_SYS_SQL", line 923
ORA-06512: at "SYS.DBMS_SQL", line 51
ORA-06512: at "HR.INSERT_ROW", line 9
ORA-06512: at line 1
THE PROCEDURE IS GETTING CREATED BUT WHEN I EXECUTE THE PROCEDURE THEN THIS ERROR COMES IN ..

891794 wrote:
Thank you all , see I am new to this database field , I am not a pro.Not a problem. However, one of the very first things you should learn is that dynamic SQL is seldom needed and invariably just plain wrong.
If a table name is dynamic, or a column name is dynamic - then chances are excellent that your data model is already fubar'ed (or malema'ed to put it in a za.org perspective).
And even when you are in the very exceptional situation where dynamic SQL is needed, SQL injection is a MAJOR security concern.. and almost always ignored by implementing shoddy code to create and execute the dynamic SQL.

Similar Messages

  • How to use Count with Date Parameters

    Hello,
    I am having issues using the Count() function in conjunction with date parameters.
    This is a Siebel report and in my report I have 2 date parameters(From Date, To Date). In a nutshell I am basically trying to count Opportunities that has a start date within the given date period. However I don't see a reasonable way to put my date parameters within the Count() function. The reason being is that I need to have a huge chunk of code to convert the dates into a common format that can be compared, and it won't even fit within the code block in my rtf template. I am not even sure how to put multiple conditional statements inside a Count() function since all the examples I have seen are very simple.
    Anyone have a suggestion on how to use Count() with date parameters?
    Thanks.

    Any chance you can get the date formats in the correct format from siebel?
    I don't know Siebel - so I can't help you with that. If you get the correct format it is just
    <?count(row[(FromDate>=date) and  (date<=ToDate))?>
    Otherwise the approach would probably need to use string function to get year/monthd/day from the date
    and store it into a varialbe and compare later the same way
    <?variable@incontext:from; ....?>
    <?variable@incontext:to; ...?>
    <?count(row[($from>=date) and  (date<=$to))?>
    Potentially you can use the date functions such as xdofx:to_date to do the conversion
    [http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481158.htm]
    But I am not sure if they are available in your siebel implementation.
    Hope that helps

  • SSO to BSP using NTLM with application parameters

    Hi all,
    As part of the CRM activity, the customer's system sends out an email to a user with a link pointing to a bsp. Part of the url is the call id which the bsp needs to display.
    The customer does not wish for the users to input user/pass when accessing the bsp.
    According to documentation, NetWeaver supports only SAP logon tickets and X.509 SSO methods(http://help.sap.com/saphelp_nw04/helpdata/en/02/
    d4d53aa8a9324de10000000a114084/content.htm).
    Found this thread that suggest a workaround:
    BSP without logon?
    Seems like it should work, but ITS forwards to a static URL.
    Any ideas on how I can make sure that after the whole sso process is complete, the bsp will still remember which call-id it needs to display?
    Regards,
    Eric

    The goal is to have the changes made inside the bsp recorded to the logged in user. So one user for all is not applicable.
    After fiddlig around with the forwarding settings and the ITS, I managed to get this thing working. Almost.
    When I access the BSP url, it gets forwarded to and from the ITS and I get a SSO2 ticket. However, when it comes back from the ITS I get a http 404 error page. If I refresh that page, the BSP loads fine, with the transferred parameters and the correct user.
    Can't get my head around why it gives me a 404.
    Eric
    Message was edited by: Eric Labiner

  • Using methods with refrence parameters

    I'm having problems completing this program I'm writing for class. I must use the setNum and getNum methods. and its must read input files as such:
    John Smith
    9.45 40 15
    Jane Doe
    12.50 45 15
    I'm keep getting a boolean identifier error. Are there any examples that anyone can give me to make my program work?
    import java.io.*;
    import java.util.*;
    public class Payroll3
         static final double FULL_TIME = 40.0;
         public static void main (String[] args)
                                                      throws FilesNotFoundException
              Scanner inFile = new Scanner(new FileReader("payroll.dat"));
              StringBuffer employeeName = new StringBuffer("");
              DoubleClass hourlyRate = new DoubleClass();
              DoubleClass hoursWorked = new DoubleClass();
              DoubleClass taxRate = new DoubleClass();
              double grossAmount = 0.0;
              double netAmount = 0.0;
              instructions();
              reportTitle();
              inputData();
              while(inFile.hasNext())
                   employeeName = inFile.nextLine();
                   hourlyRate = inFile.nextDouble();
                   hoursWorked = inFile.nextInt();
                   taxRate = inFile.nextInt();
              printEmployeeInfo(employeeName, hourlyRate, hoursWorked, taxRate, grossAmount, netAmount);
              inFile.close();     
         public static void instructions()
              System.out.println("               Instructions for Payroll Report Program              \n");
              System.out.println("This program calculates a paycheck for each employess.\n"
                                       + "A text file containing the following information will be created:\n"
                                       + "name, payrate, hours worked, and tax percentage to be deducted.\n");
              System.out.println("The program will create a report in columar format showing the \n"
                                       + "employee name, hourly rate, number of hours worked, tax rate,\n"
                                       + "gross pay, and net pay.\n");
              System.out.println("After all employees are processed, totals will be displayed,\n"
                                       + "including total gross amount and total net pay.\n");
         public static void reportTitle()
              System.out.println("                              Payroll Report                  \n"
                                            + "\n");
              System.out.println("Employee             Hourly      Hours   Tax     Gross     Net     ");
              System.out.println("Name                 Rate       Worked   Rate    Amount   Amount    ");
              System.out.println("----------------     -------   -------  -----  -------   -------");
         public static void printEmployeeInfo(StringBuffer employeeName, Doubleclass hourlyRate, Doubleclass hoursWorked, Doubleclass taxRate, Doubleclas grossAmount, Doubleclass netAmount)
         System.out.printf("%-20s%8.2f%9.2f%8.2f%9.2f%10.2f%n", employeeName, hourlyRate, hoursWorked, taxRate, grossAmount, netAmount);
              if (hoursWorked > FULL_TIME)
                    System.out.println("OT");
              else
                   System.out.println();
         public static void boolean inputData(StringBuffer employeeName, Doubleclass hourlyRate, Doubleclass hoursWorked, Doubleclass taxRate)
              if (
              hourlyRate.getNum();
              hoursWorked.getNum();
              taxRate.getNum());
              return true;
              else
               return false;
    }

    I had FilesNotFoundException in the code but I corrected the other issues. my main problem now is the DoubleClass methods. here are the errors that came up now.
    Payroll3.java:31: incompatible types
    found : double
    required: DoubleClass
                   taxRate = inFile.nextDouble();
    ^
    Payroll3.java:34: printEmployeeInfo(java.lang.StringBuffer,DoubleClass,DoubleClass,DoubleClass,DoubleClass,DoubleClass) in Payroll3 cannot be applied to (java.lang.StringBuffer,DoubleClass,DoubleClass,DoubleClass,double,double)
              printEmployeeInfo(employeeName, hourlyRate, hoursWorked, taxRate, grossAmount, netAmount);
    ^
    Payroll3.java:63: operator > cannot be applied to DoubleClass,double
              if (hoursWorked > FULL_TIME)
    ^
    Payroll3.java:73: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              hourlyRate.getNum();
    ^
    Payroll3.java:74: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              hoursWorked.getNum();
    ^
    Payroll3.java:75: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              taxRate.getNum();
    ^
    11 errors
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    ----jGRASP exec: javac -g E:\Chapter 7 Source Code\Payroll3.java
    Payroll3.java:9: cannot find symbol
    symbol : class FilesNotFoundException
    location: class Payroll3
                                                      throws FilesNotFoundException
    ^
    Payroll3.java:24: inputData(java.lang.StringBuffer,DoubleClass,DoubleClass,DoubleClass) in Payroll3 cannot be applied to ()
              inputData();
    ^
    Payroll3.java:28: incompatible types
    found : java.lang.String
    required: java.lang.StringBuffer
                   employeeName = inFile.nextLine();
    ^
    Payroll3.java:29: incompatible types
    found : double
    required: DoubleClass
                   hourlyRate = inFile.nextDouble();
    ^
    Payroll3.java:30: incompatible types
    found : int
    required: DoubleClass
                   hoursWorked = inFile.nextInt();
    ^
    Payroll3.java:31: incompatible types
    found : int
    required: DoubleClass
                   taxRate = inFile.nextInt();
    ^
    Payroll3.java:34: printEmployeeInfo(java.lang.StringBuffer,DoubleClass,DoubleClass,DoubleClass,DoubleClass,DoubleClass) in Payroll3 cannot be applied to (java.lang.StringBuffer,DoubleClass,DoubleClass,DoubleClass,double,double)
              printEmployeeInfo(employeeName, hourlyRate, hoursWorked, taxRate, grossAmount, netAmount);
    ^
    Payroll3.java:63: operator > cannot be applied to DoubleClass,double
              if (hoursWorked > FULL_TIME)
    ^
    Payroll3.java:73: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              hourlyRate.getNum();
    ^
    Payroll3.java:74: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              hoursWorked.getNum();
    ^
    Payroll3.java:75: cannot find symbol
    symbol : method getNum()
    location: class DoubleClass
              taxRate.getNum();
    ^
    11 errors

  • If we use DML statement in function then that function can be used inside s

    if we use DML statement in function then that function can be used inside select query or any DML query?

    select f from t2;I think you meant to query t1.
    It works if the function is an autonomous transaction:
    create or replace function f return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
        update t1 set c=2;
        commit;
        return 1;
    end;
    select f from t1But as Billy said why would you want to do DML this way. And this is not the way autonomous procedures should be used either.
    An an answer to an interview question though nothing wrong with it.

  • Need to execute Long Insert (6000 characters)statement using dbms_sql.parse

    I built an insert statement which is more than 6000 (six thousand) characters stored into two varchar2 variables. I need to execute the statement using dbms_sql.parse.
    I tryed using dbms_sql.varchar2s variable and having no success.
    Any ideas or examples?
    Thanks
    JK

    6000 chars shouldn't be a problem.
    What do you mean with no success?Did you get any error?
    Any ideas or examples?See this thread
    Re: execute immediate with a string longer than 32767

  • PLS-00435: DML statement without BULK In-BIND cannot be used

    My requirement
    I am dynamically creating a staging table my_stg, and then populate it. Seems simple, but not sure why i get this error,
    create table gtest4(myid varchar2(10), mykey varchar2(10));
    create table gtest5(myid varchar2(10), mykey varchar2(10));
    insert into gtest4 values(1,3);
    insert into gtest4 values(2,7);
    insert into gtest5 values(5,3);
    insert into gtest5 values (1,7);
    commit;
    /* Formatted on 2012/01/27 17:52 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PROCEDURE px
    IS
    TYPE rectype IS RECORD (
    myid VARCHAR2 (100),
    mykey VARCHAR2 (100)
    TYPE tabtype IS TABLE OF rectype
    INDEX BY BINARY_INTEGER;
    rec tabtype;
    cur sys_refcursor;
    BEGIN
    EXECUTE IMMEDIATE 'create table my_stg(myid varchar2(100), mykey varchar2(100)) ';
    OPEN cur FOR 'select a.myid, b.mykey
    from gtest4 a, gtest5 b
    where a.mykey = b.mykey';
    LOOP
    FETCH cur
    BULK COLLECT INTO rec LIMIT 500;
    FORALL i IN 1 .. rec.COUNT
    EXECUTE IMMEDIATE 'insert into my_stg(myid, mykey) values (rec(i).myid,
    rec(i).mykey)';
    EXIT WHEN cur%NOTFOUND;
    END LOOP;
    END;
    I compile the above proc, and get
    PLS-00435: DML statement without BULK In-BIND cannot be used
    the reason I do insert in execute immediate is because the table my_stg does not exist, it is created on the fly

    I tried the below, used plsql table variables instead of record type
    CREATE OR REPLACE PROCEDURE px
    IS
    TYPE rectype IS RECORD (
    myid VARCHAR2 (100),
    mykey VARCHAR2 (100)
    TYPE tabtype1 IS TABLE OF varchar2(100)
    INDEX BY BINARY_INTEGER;
    TYPE tabtype2 IS TABLE OF varchar2(100)
    INDEX BY BINARY_INTEGER;
    rec1 tabtype1;
    rec2 tabtype2;
    cur sys_refcursor;
    BEGIN
    EXECUTE IMMEDIATE 'create table my_stg(myid varchar2(100), mykey varchar2(100)) ';
    OPEN cur FOR 'select a.myid, b.mykey
    from gtest4 a, gtest5 b
    where a.mykey = b.mykey';
    LOOP
    FETCH cur
    BULK COLLECT INTO rec1, rec2 LIMIT 500;
    FORALL i IN 1 .. rec.COUNT
    execute immediate 'insert into my_stg(myid, mykey) values (:1,:2)
    using rec1(i).myid, rec2(i).mykey;
    EXIT WHEN cur%NOTFOUND;
    END LOOP;
    END;
    I get error
    PLS-00103: Encountered the symbol "insert into my_stg(myi
    mykey) values (:1,:2)
    using rec1(i).myi" when expecting one of the following:
    ( - + case mod new not null <an identifier>
    <a double-quoted delimited-identifier> <a bind variable>
    count current exists max min prior sql stddev sum varianc
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal
    Please help

  • Forall with multi dml statements

    hi
    I am trying to write a procedure for learning purpose, but it gives error message.
    Normally we use for loops, it is slow but for loop is a block and you can execute many select and dml statements inside for loop.
    I want to achieve this with bulk collect and for all but I can not. Can you help me?
    /* Formatted on 2009/07/28 07:34 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PROCEDURE bulk_collect_query
    IS
    TYPE employee_tt IS TABLE OF employees.employee_id%TYPE
    INDEX BY BINARY_INTEGER;
    TYPE salary_tt IS TABLE OF employees.salary%TYPE
    INDEX BY BINARY_INTEGER;
    TYPE hire_date_tt IS TABLE OF employees.hire_date%TYPE
    INDEX BY BINARY_INTEGER;
    hire_datet hire_date_tt;
    employeet employee_tt;
    salariet salary_tt;
    BEGIN
    DBMS_OUTPUT.put_line ('Before Bulk Collect: ' || SYSTIMESTAMP);
    SELECT employee_id, salary, hire_date
    BULK COLLECT INTO employeet, salariet, hire_datet
    FROM employees;
    DBMS_OUTPUT.put_line ('After Bulk Collect: ' || SYSTIMESTAMP);
    FORALL indx IN employeet.FIRST .. employeet.LAST
    begin
    INSERT INTO t_emp_history
    (employee_id, salary, hire_date
    VALUES (employeet (indx), salariet (indx), hire_datet (indx)
    INSERT INTO t_emp_history
    (employee_id, salary, hire_date
    VALUES (employeet (indx), salariet (indx), hire_datet (indx)
    end;
    DBMS_OUTPUT.put_line ('After FORALL: ' || SYSTIMESTAMP);
    COMMIT;
    END;
    /

    /* Formatted on 2009/07/28 07:34 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PROCEDURE bulk_collect_query
    IS
    type v_datareturn IS record(
    employee_id employees.employee_id%TYPE,
    salary employees.salary%TYPE,
    hire_date employees.hire_date%TYPE
    TYPE employee_tt IS TABLE OF v_datareturn
    INDEX BY BINARY_INTEGER;
    employeet employee_tt;
    CURSOR c IS
    SELECT employee_id, salary, hire_date
    FROM employees;
    BEGIN
    DBMS_OUTPUT.put_line ('Before Bulk Collect: ' || SYSTIMESTAMP);
    OPEN c;
    FETCH c BULK COLLECT INTO employeet;
        FORALL i IN 1..employeet.COUNT
        INSERT INTO t_emp_history VALUES employeet(i);
        CLOSE c;
    DBMS_OUTPUT.put_line ('After Bulk Collect: ' || SYSTIMESTAMP);
    COMMIT;
    END;
    /Untested one.....
    Ravi Kumar

  • Error when using Analytic view with Input Parameters

    Hi,
    I am trying to create an info space based on my Analytic view which has input parameters. The infospace is validated and indexed without any issue. However when I ran the view, I get an error (50011) as it is unable to fetch any results. I tried using an infospace based on Calculation view with input parameters and the explorer view works without any issue.
    Has anyone faced similar issues?
    We are using HANA SP 6 rev 67 and BI 4.0 SP 4.
    Also is there a way to enable input prompts for the users when they refresh the BO Explorer view? If not currently available is there any work around ?
    Thanks

    Hello George,
    I don't have any personalization set on the info space. Also I am using mapped Account in BI to connect to HANA. The confusing part is that it is able to validate the infospace with the input parameters and index it. However query does not return any results. I even tried running the same query which explorer sends to HANA in the SQL editor and there too the same results,the query does not return anything. The model does return data when I do a data preview and if accessed from other tools like AAO.
    Also when I use SSO connection to HANA, indexing of the infospace fails. Where can I see the error log?
    Thanks,

  • Happy Holidays.  I have Adobe Actobat 7.0 Standard for quite a while, and I'm happy with it. I use it for mainly filings at the federal court.  They require PDF.  I use two computers in two different states for work.  I realize my Adobe 7.1 is a few years

    .  I have Adobe Actobat 7.0 Standard for quite a while, and I'm happy with it. I use it for mainly filings at the federal court.  They require PDF.  I use two computers in two different states for work.  I realize my Adobe 7.1 is a few years old, but sometimes I have difficulty using it with the other days downloading a boarding pass, and e filing at the USDC. .  There's a problem with Adobe Flash, media, etc.  and other Adobe programs, (which I use for downloading boarding passes for airlines, etc.) so basically I have to delete these other Adobe programs, besides the Adobe Acrobat 7.0 Standard if I want to 7.0 Standard to work.  I periodically download the updates, but there's still a problem. My question is:  Can or should I purchase another program to update the present Adobe Acrobat 7.0 standard, or just buy a new program such as the Adobe 11?  Am I mistakenly doing something wrong, such as when I download?  I'm an old valued customer so I don't want to spend a lot of money since I am replacing my Dell XP for a new computer now, and my other computer is a Dell Vista.
    I'd appreciate your valued advice.

    If you are getting a new computer (for a PC it would have Win 7 or 8), then you will need to purchase XI if you wish to continue using Acrobat. Acrobat 7 is not compatible with these systems (and probably the same for MAC systems), though sometimes workarounds are possible, though not easy to use. I guess the answer is to buy the new version. Try http://www.adobe.com/products/catalog/software._sl_id-contentfilter_sl_catalog_sl_software _sl_mostpopular.html, click on the Buy for Acrobat, and then select the version you want.

  • Erased all content on 3G but now won't sync with iTunes. Error states, "This iPhone cannot be used because the Apple Mobile Device service is not started." I don't want phone service on this old 3G. Just want to use it as an iTouch. Any suggestions?

    Erased all content on 3G but now won't sync with iTunes. Error states, "This iPhone cannot be used because the Apple Mobile Device service is not started." I don't want phone service on this old 3G. Just want to use it as an iTouch. Any suggestions?

    Type "Apple Mobile Device service " into the search bar at the top of this page by "Support"

  • Problem Using Multiple With Statements

    I'm having a problem using multiple WITH statements. Oracle seems to be expecting a SELECT statement after the first one. I need two in order to reference stuff from the second one in another query.
    Here's my code:
    <code>
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy)
    /*Use terms from calculate_terms to generate attendance periods*/
    WITH gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    SELECT *
    FROM gen_attn_terms
    <code>
    I get ORA-00928: missing SELECT keyword error. What could be the problem?

    You can just separate them with a comma:
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy),
    /*Use terms from calculate_terms to generate attendance periods*/
    gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    )Not tested because there are no scripts.

  • Using a StoredProcedure with OUT parameters in CrystalReports

    Hi All,
    I am creating a report using CrystalReport Designer 2008.I have a StoredProcedure which takes 2 input parameters,2 output parameters and a cursor.I am not able to add this SP directly using the DatabaseExpert. if I use
    'call SP1(input1,input2,input3,input4,@output1,@output2)' from AddCommand option then it gets added as a Command but the tree under Command does not expand and it does not allow me to use the output parameters in my reports.
    Hence,can anyone please help me here such that how should I use this SP with out parameters in my CrystalReports.Also note that I am able to use StoredProcedure with only input parameters,with input parameters and cursor in my CrystalReports.Should I do something extra to add this StoredProcedure in my CrystalReports?
    Any help for this issue would be highly appreciated.
    Regards.
    Ajit

    Ajit,
    If you are using a Command, you execute a SP in CR with the same syntax that you would in the databases native environment.The only difference is that you'll need to add CR parameters so that the inputs can be added to the SP's input parameters.
    So, using your example... 'call SP1({?input1}, {?input2}, {?input3} , {?input4}, output1, output2)'
    I'm not familiar with this particular syntax but hopefully you get the idea.
    If you want to hard code the input parameters (and not have them prompt in CR), just hard code them in the command.
    HTH,
    Jason
    Edited by: Jason Long on Aug 25, 2010 2:15 PM

  • Calling stored procedures with output parameters using RDO and VB

    I have a simple test procedure defined as follows:
    CREATE OR REPLACE PROCEDURE test_sp (inval1 IN VARCHAR2,
    inval2 IN NUMBER, inval3 OUT VARCHAR2, inval4 OUT NUMBER) IS
    BEGIN
    inval3 := 'RETURN TEST';
    inval4 := 10;
    END;
    I am attempting to call this procedure from VB 5.0 using RDO and the Oracle ODBC Driver 8.01.06:
    dim rdoQd as rdoQuery
    dim grdoCn as rdoConnection
    strSQL = "{ call test_sp('SOMETHING',?,?,?) }"
    Set rdoQd = grdoCn.CreateQuery("", strSQL)
    rdoQd(0).Direction = rdParamInput
    ' get error# 40041 at above line
    ' "Object Collection: Couldn't ' find item indicated by text."
    rdoQd(0).Type = rdTypeINTEGER
    rdoQd(0).Value = 5
    rdoQd(1).Direction = rdParamOutput
    rdoQd(1).Type = rdTypeVARCHAR
    rdoQd(2).Direction = rdParamOutput
    rdoQd(2).Type = rdTypeINTEGER
    Set rdoApp = rdoQd.OpenResultset()
    MsgBox (CStr(rdoQd(1)))
    MsgBox (CStr(rdoQd(2)))
    When I run this VB code, I get the above mentioned error. If I use placeholders for all parameters (like "{ call test_sp (?,?,?,?) }" ), no error occurs.
    I really need to use the first type of syntax from above and not have to use placeholders for all parameters. Is there a way to accomplish this?
    TIA,
    Esther

    Are you getting any warning while importing the stored procedure?
    Please check the below datatypes:
    While creating the stored procedure, if you have used varchar(MAX), please ALTER it to varchar(255) and reimport to DS.
    Also, the datatype of $message (global variable or local variable) used inside DS should also be varchar(255)
    Try a print statement in between.
    ADMIN.DBO.SPJOBSUMMARY(69,$message,$rtCode,$rtVal);
    print('Message is '||$message);
    smtp_to('leighattest.com.au', 'Results of ' || job_name(), $rtCode || '//' || $rtVal || '~~' || $message || '//', 0,0);
    and see in the job log if DS is able to retrieve the output from DB.
    Regards,
    Suneer

  • Dynamic TSQL Statement with Dynamic Parameters

    I'm trying to utilize a dynamic TSQL Statement where I can have various parameters passed of differing kinds, e.g. In some cases parameter 1 would be an int, other cases it may be a datetime, or varchar, etc.
    I'm going to keep  a table of with certain key SQL Statements, and then parameters in another column so this can be resusable.
    Here is my code:
    Case 1
    Declare @FromDate as DATE='2013-10-01'
    Declare @ToDate as DATE='2013-10-31'
    Declare @FamilyMember as nvarchar(2)='20'
    DECLARE @retval int
    DECLARE @sSQL nvarchar(500);
    DECLARE @ParmDefinition nvarchar(500);
    DECLARE @tablename nvarchar(50)
    --Select Convert(nvarchar(15), @FromDate,126)
    SELECT @sSQL = N'select count(distinct id) as AggregateCount from [Table] where familyMember = @FamilyMember
    and DateStamp between @FromDate and @ToDate';
    SET @ParmDefinition = N'@retvalOUT int OUTPUT';
    EXEC sp_executesql @sSQL, @ParmDefinition, @retvalOUT=@retval OUTPUT;
    Case 2
    Declare @FromDate as DATE='2013-10-01'
    Declare @ToDate as DATE='2013-10-31'
    Declare @Id as int=3510021
    DECLARE @retval int
    DECLARE @sSQL nvarchar(500);
    DECLARE @ParmDefinition nvarchar(500);
    DECLARE @tablename nvarchar(50)
    --Select Convert(nvarchar(15), @FromDate,126)
    SELECT @sSQL = N'select count(distinct id) as AggregateCount from [Table] where Id=@Id
    and DateStamp between @FromDate and @ToDate';
    SET @ParmDefinition = N'@retvalOUT int OUTPUT';
    EXEC sp_executesql @sSQL, @ParmDefinition, @retvalOUT=@retval OUTPUT;
    John

    The following is an example I found, but I am receiving a Message "Must declare the scalar variable @StudentNumber"
    Alter Procedure [dbo].[spInsertStudentDoc2]
    @StudentNumber integer
    AS
    Begin
    DECLARE @P_StudentNumber integer
    DECLARE @ParameterList nvarchar(max)
    DECLARE @SQLSnippit as nvarchar(max)
    SET @ParameterList = N'@P_StudentNumber integer'
    SET @SQLSnippit = N'Select Count(*) from dbo.student where patid=@StudentNumber'
    PRINT @SqlSnippit -- debug & test
    Exec SP_EXECUTESQL @SqlSnippit, @ParameterList, @P_StudentNumber=@StudentNumber
    End
    John

Maybe you are looking for

  • How I can displsy the results in a nice readable format

    I have this query in a cursor I is displaying the data like this Major/Minor RestrictionEnglish English and Theater Envir St-English How I can make it to display something like this Must be enrolled in one of the following Majors: English, English an

  • Paramter visibility in Report Output

    Hello All, I am having a requirement to "Print Parameters in a output(pdf,xls,csv) of a report", which i am providing to my query for fetching a data. Is this possible, yes then how? Pls Help. Regards, UKJ

  • How to create an auction website using Action Script 3

    I want to develop an auction website for a flash assignment but I don't know how to go about doing it. Can I get some suggestions?

  • How do I get iWeb Keywords recognised on Google searches?

    I have completed my website on iWeb 08 - NOT hosted via MobileMe. If I search for various related products via Google, on a Windows machine, my site doesn't appear unless I enter my business name. I am informed that I need to get my Keywords recognis

  • Quicken 2007 for Lion is out but won't launch

    I downloaded the 2007/Lion Quicken for Mac (just came out?). I am using Lion... When I click on it is asks for my password then crashes, or just doesnt open. Has anyone gotten it to work for them? tried the usual stuff, reboot etc. roger