Pass parameter to sql statement in query manager

Hai to all,
           I want to pass the percentage  as the parameter into the sql statemnet.i what to execute it in the query manager.
          If i execute that statement then cann't found the tablename error is coming.
         Other than the data in the table (general data)  pass to the parameter in the sql at runtime.
for example:
select [%0] *100
how to pass 10 to that sql statement.
Please help me...
Regards,
Raji.

Hi Ramya,
You can create a SP with parameters to accept and then execut this SP from SAP Business One Query Manager by passing the parameter (in your case 10). The result will be as desired.
Ex:
Create this Procedure in SQL Management Studio
create proc Test(@a as int)
as
begin
select (@a*100)
end
To Execute the Query use this Query and pass the desired values with parameters
execute Test 10
Regards,
Reno

Similar Messages

  • Passing parameter into SQL statement in Crystal Reports

    Hi all,
    I would like to call Crystal Reports in JSP. I can handle it well now. But I hope to let user input their selection criteria before printing out the report. I know how to get the parameter value in JSP, but I really dunno how to pass these parameter values into the SQL statement in Crystal Report. Actually, is it possible to do so?
    If anyone has idea, please tell me. Thx Thx!
    Regards,
    Betty

    Dear Sir,
    I want to use Crystal Report as a web base using JSP. But, I am getting how to call .rpt file in .jsp file & passing of parameter.
    If you have any idea, please reply as early as possible
    Thanking U.
    My userid = [email protected]
    Regds
    Pankaj..

  • PASSING PARAMETER IN SQL STATEMENT .

    HI,
    Can any one tell me how to use on of the field name as a parameter in the same sql statement ? Here is what i am looking for :
    SELECT EMPNO, DEPTNO, (SELECT COUNT(ORDERNO) FROM ORDERS WHERE DEPTNO = :DEPTNO AND EMPNO = :EMPNO) TOTAL_ORDER FROM EMP;
    Here the embeded sql statment should take the paramter :DEPTNO , :EMPNO from the main sql statement. That means , each DEPTNO, EMPNO should be passed as a aparameter to the embeded SQL statement.
    Thanks
    Feroz

    WHATS THE CONACT, ||, +, HOW TO USE IT, CAN U GIVE ME AN EXAMPLE.
    SORRY , HERE IS THE ACTUAL THING WHAT I AM LOOKING FOR, I WANT TO GET THE MEDIAN AND MODE VALUE IN ORACLE, BUT COZ ORACLE DOES NOT HAVE IN BUILT FUNCTION TO ET THE ABOVE TOW , I WROTE MY SQL STATEMENTS, FOR EXAMPLE THE MEDIAN OF SAL FOR DEPT 20 IS IS
    SELECT AVG(SAL) FROM
    (SELECT RowNum The_Rownum, SAL FROM
    (SELECT SAL FROM EMP WHERE DEPTNO = 20 ORDER BY 1)) V
    WHERE V.The_Rownum = ( SELECT FLOOR((COUNT(SAL)+1)/2) FROM EMP WHERE DEPTNO = 20)
    OR V.the_rownum = (SELECT CEIL((count(SAL)/2) + 1/2) FROM EMP WHERE DEPTNO = 20)
    This median value ncalculation i can put in a functio and return it, but for a record os 1,800,000 volume, calling this function that many times, the sql never executes. It just hangs. so i thought if i can emabede the whole calculaton in the main sql statement instead of writing a function and calling that function in the sql statement. But the median calculation needs the department no as a parameter to calculate the median for that perticular department. Here , where the requirement of PARAMETER comes. ANY IDEA ???
    Thanks
    Feroz

  • Passing Parameter to SQL-Query

    Hello ,
    i have an SQL Query as Data Source of my Crystal Report . I d like to pass the parameter to my SQL-Query.
    Parameter ?city
    Query1
    select
    Order ID,
    City,      -- How to pass my ?city here
    Amount
    from Orders,
    thanx ..

    You can do this by using the 'Add Command' feature.
    Click Add Command -> Create your ?City Parameter -> type SQL statement:
    select
    Order ID
    where City='{?City}'
    Make sure you add single quotes around your parameter.
    Regards,
    Zack H.

  • Passing Parameter in SQL

    How to Passing parameter in SQL.For Example,Table name=&From_Clause.It will asking table name at runtime.How to assign table name based on user.

    Hi,
    796776 wrote:
    It will returm error.what problem in this
    Select * From Emp a,
    (SELECT CASE
    WHEN USER = :UserType
    THEN 'scott.Dept'
    ELSE 'scott.order'
    END AS b
    FROM dual)
    Where a.DeptNo= b.DeptNo &WhereClauseIt's hard to guess, from an example like this with so many errors, exactly what you're trying to do.
    Please post a description of the problem, including CREATE TABLE and INSERT statments for any tables you need (unless you can state the problem using commonly available tables, such as those in the data dictionary or the scott schema), a few values of a parameter (or examples of different user names, if USER acts like a parameter) and the results you want from the same data for each value.
    For example
    "In addition to the scott.dept table, I have a table called my_dept: CREATE TABLE my_dept ...
    which has this data: INSERT INTO my_dept ...
    I need a script such that, when user scott runs it, the results are ...
    but when any other user runs it, the results are ..
    As you can see, the difference is ..."
    Table names must be explicitly given when a SQL statement is compiled. That's why I usggested a preliminary query; so by the time you compiled the main query, the table name would be known and could be passed in a substitution variable.
    If you really want to do it in one query, you can do a UNION of two queries, one of which returns nothing because of the parameter. It's not very efficient.

  • Pass ORG_ID as sql statement for parameter in request set

    We are in a multi-org environment. We are running the request PRC: Generate Draft Revenue for a Single Project as part of the request set. We want the request to automatically fill in the open pa period as the accrue through date. We have been using the SQL Statement below as the value for the accrue through date parameter.
    select end_date
    from pa_periods_all
    where status = 'O'
    and current_pa_period_flag = 'Y'
    Unfortunately that does not limit to a specific company. We a company that still have DEC-05 while another has an open period of JAN-06. This is causing the program fits. How do I pass the org_id to the request? [in beginners terms please]
    Thanks.
    Anne

    No idea what might be wroong without more info...
    Do some output. Test the ${params.id} variable passed to the second jsp. If that is correct, then error is in the select statement or display of jsp2. If it is correct the error comes from jsp1.
    If I have to guess, then I would say the error comes from JSP1, and the ${row.vac_id} should only be called once. In which case I would do something like this:
    //in jsp 1
                <c:forEach var="row" items="${results.rows}"  varStatus="counter"  >
                    <c:set var="vac_id" value="${row.vac_id}" scope="page"/>
                    <tr>
                        <td>${vac_id}</td>
                        <td><a href="vacancydetails.jsp?id=${vac_id}">More</a></td>But that is a guess only...
    Errr... Hold on to that as reference, but the it is entirely likely that I misspelled ${params.id} It may be ${param.id} I forget and away from my machine right now...

  • Hiding SQL statement in Query Result Window

    Hi everyone,
    Is it possible to hide the SQL statement from a query result window? This can usually be done by click the orange triangle that is positioned to the left of the SQL string box (to expand and collapse it). The System Queries have this box collapsed per default, is it possible to have this setup as default for all queries, including the custom? If so, please let me know where this can be done.
    Cheers

    You should do this only with SDK programming - dont allow to show the syntax. The next, but problematic way, is the code you have do inside stored procedure and call only this sp inside the query generator window - if you have there some input parameters, you should use filling variables before executing sp and get it as input parameters to sp.

  • Working with Custom SQL Using Descriptor Query Manager Queries

    Hi All,
    I am Working on Descriptor Query Manager Queries
    Configuring Custom SQL Using Java and Workbench
    Using Java I wrote a static method as in the code given below.
    public static void insertEmployee(ClassDescriptor descriptor){
    descriptor.getQueryManager().setInsertSQLString(
    "insert into EMPLOYEE (EMP_ID, EMP_NAME, EMP_JOB, SAL, DEPTNO) values (#EMP_ID, #EMP_NAME, #EMP_JOB, #SAL, #DEPTNO)"
    I wrote a insert SQL Query in the custom SQL tab of the Toplink workbench .
    Using java and Using Toplink Workbench I had a problem how to call this insert query in the sessionEJBBean .
    Can any one suggest me in this regard.
    Thanks in advance
    regards,
    Satish

    What is the problem you are experiencing?
    Normally you can just execute the query by calling
    'executeQuery(queryName, domainclass) on the session.
    See also
    http://www.oracle.com/technology/products/ias/toplink/
    doc/10131/main/_html/qrybas003.htm#BCFIBGGJ
    Just out of curiosity: why do you need a custom SQL
    to insert something? Can't you use persist()?
    regards,
    LonnekeOr even UnitOfWork ? Why go down the route of using custom inserts to insert objects unless you have some business logic that Toplink's UnitOfWork API cannot provide ?

  • Executing SQL statements in container managed transactions

    I have a problem when using TopLink 9.0.3 with WebSphere 4, Oracle 9i and J2EE container managed transactions.
    The data changing SQL statements are executed at the end of the (container managed) transaction, not at the time of the calls to UnitOfWork.registerNewObjekt(),
    UnitOfWork.validate...() or UnitOfWork.commit...().
    UnitOfWork(2035008996)--validate object space.
    UnitOfWork(2035008996)--validate cache.
    UnitOfWork(2035008996)--JTS#beforeCompletion()
    UnitOfWork(2035008996)--Connection(398132708)--INSERT INTO SVM_PERSONEN (FAX, NAME, ID, [...]) VALUES ([...])
    UnitOfWork(2035008996)--JTS#afterCompletion(org.omg.CosTransactions.Status._StatusRolledBack=4)
    UnitOfWork(2035008996)--release unit of work
    But the end of the transaction is out of the application server code. The transaction ends after the invoke of the applixcation server method, as the stack trace of an occurring exception shows:
    remote exception
    javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0 No; nested exception is:
         org.omg.CORBA.TRANSACTION_ROLLEDBACK:
    org.omg.CORBA.TRANSACTION_ROLLEDBACK: com.ibm.websphere.csi.CSITransactionRolledbackException:
         at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:194)
         at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:67)
         at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:414)
         at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:1818)
         at de.gedas.svm.server.app.ejb.EJSRemoteStatelessNavigationEJB.findPersonenZulieferer(EJSRemoteStatelessNavigationEJB.java:964)
         at de.gedas.svm.server.app.ejb._EJSRemoteStatelessNavigationEJB_Tie._invoke(_EJSRemoteStatelessNavigationEJB_Tie.java:589)
         at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:506)
         at com.ibm.CORBA.iiop.ORB.process(ORB.java:2376)
         at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:186)
         at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:104)
         at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
    So the application server code has no possiblity for special reaction to this error condition.
    How can I use TopLink to execute my SQL statement immidately, not at the the end of the transaction (which is out of the area of my code)? Only the transaction should end at the usual time, managed by the container.

    I don't think there is anyway to currently do this in a JTS managed environment, to handle the exceptions you could,
    - Make use of TopLink session ExceptionHandlers to handle the database errors during the JTS commit.
    i.e.
    uow.setExceptionHandler(yourExceptionHandler);
    or,
    - Let TopLink control the transactions instead of JTS.

  • How to get month value from custom calendar without passing parameter from SSRS in MDX query

    Could you please throw some light to achieve below requirement?  
    I need to filter the data between two periods dynamically . The date calendar here works differently(ex:-Date 26-Aug-2014 will fall in period 7 which is last date and 27-Aug-2014 will fall in period 8 and it is first date of period 8),so I cannot go
    with system date period/Month. Date Hierarchy is like YEAR,QUARTER,PERIOD ,WEEK and DAY.
    I cannot use SSRS for passing parameter. Requirement is to extract last 2 period of data dynamically in Power Pivot with MDX.
    Thanks Chandan

    Hi Chandan,
    You might try something like this
    Tail(null:
    Extract(
    StrToMember("[FYDay].[DATE].&[ + cStr(Format(Now(),"yyyy-MM-ddT00:00:00")) + "]")
    *[FYDay].[DateHierarchy].[Day]
    ,[FYDay].[DateHierarchy]).parent.parent
    ,2)
    What it is doing is multiplying Day by the current date, which returns a set of one date with cardinality of (Date,Day).  The Extract is pulling out just the datehierarchy Day.  the the Tail() is getting it and the previous day.
    Hope that helps,
    Richard

  • Passing parameter into select statement by using function in discoverer

    I have created two functions in database named Period_in and Period_out and a global variable  g_period_name
    I have called Period_out function in VIEW(Select statement where condition).
    I have registered Period_in function in discoverer admin then created calculation (called Period_in(:input parameter))in discoverer plus.
    My expectation is user will enter period name and that will hit Period_in function and returns 1 and stores entered period name in g_period_name at runtime. then VIEW will executed and fetches data.
    But i am getting no data found.
    Problem is 2 functions running at the same time in select statement. Please help me to overcome this. Thanks in advance
    FUNCTION period_in (p_period VARCHAR2)
          RETURN NUMBER
       AS
       BEGIN
          g_period_name := p_period;
          RETURN 1;
       END period_in;
       FUNCTION period_out
          RETURN VARCHAR2
       AS
       BEGIN
          RETURN g_period_name;
       END period_out;

    You can use this code: 
    WITH cte
    AS ( SELECT EmpID ,
    EmpName ,
    [dbo].[udf_testFunction](EmpID) AS testfunctionvalue
    FROM #Temp
    SELECT EmpID ,
    EmpName ,
    testfunctionvalue ,
    testfunctionvalue * EmpID ,
    testfunctionvalue + 2
    FROM cte
    But using scalar functions in select clause can hurt the performance. Please see this link: 
    SQL Server Scalar User Defined Function Performance
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Passing parameter in sql reports

    Hi all,
    I created a sql file to generate a sql*report, in which i am passing a parameter and i stored it in the respective top.
    I created a executable, program in which i passed the parameter as usual.
    But while i submitted the request, it is not getting completed.
    please help
    --regards
    --Raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Do you spool the output to a File?
    If you do, then maybe the filename you are using is locked for some reason. Try using a different file name.

  • How to pass parameter into sql block?

    example code
    @script.sql a b c d
    Inside script
    DECLARE
    cursor cur is select col1 from table where col1 in ('a','b','c','d','e');
    BEGIN
    END;
    Not sure 1) The the total number of parameters will be passed at run time
    2) Not sure of case, could be lower upper or both....
    Please help...

    do you have different queries which are defined to use different numbers of parameters, OR (more likely) sometimes you just want to pass less parameters?
    sqlplus / @file1 "a" "b" "" "" ""
    now I only passed 2 "real" params, and 3 blanks. that way, sqlplus still has the values of &3 - &5 defined, and everything works fine. you'lll need either single or double quotes (or perhaps single quotes within double quotes) depending on your os, version, etc.

  • Using passed values in SQL statements

    Using Adobe Livecycle Designer 7, we wish to populate a pdf document with values from a MS SQL database. The values will change depending on the ID of the record called for.
    We can already populate the form using SQL (SELECT firstname FROM names WHERE id = 1), but we need to populate it based on a 'passed' value in a url (http://www.mysite.com/mypdf.pdf?id=1).
    When we try to include this into the SQL (SELECT firstname FROM names WHERE id = request.id) we get an error. Could anyone provide us with the correct syntax that will allow us to populate the form based on the ID passed in a URL?
    Many Thanks
    Craig

    Hi all of you,
    I do have a problem with coding correctly a form I am designing sing the Adobe Livecycle . In one of the field, there is an underlying field that when you exit the first name field or the Middle Initial field or the last name, it should all pass the respective values to the underlying field which becomes visible on printout. I do have this code I wrote on the exit event, but do not understand why it it not working. Please, can anyone tell me why it is not working or help me out on a better way of making it work.
    xfa.host.messageBox("Check this");
    if (EMPFNAME.rawValue <> " " ){
    xfa.host.messageBox("EMPFNAME");
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " ";
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + ".";
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " ")&&(EMPLNAME.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + "." + " " + String(EMPLNAME.rawValue);
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    Thanks
    Lucky P

  • How to pass parameter in sql developer for debubing record type

    DECLARE
      IB_BP_BANK_ACCOUNT_BUF PL/SQL RECORD;  ---record type
      IP_BP_ID NUMBER;
      IOP_ACC_SEQ_NO NUMBER;
      OP_ERROR VARCHAR2(200);
    BEGIN
      IB_BP_BANK_ACCOUNT_BUF := NULL;
      IP_BP_ID := NULL;
      IOP_ACC_SEQ_NO := NULL;
      ORAGTW11.MAINTAIN_BP_BANK(
        IB_BP_BANK_ACCOUNT_BUF => IB_BP_BANK_ACCOUNT_BUF,
        IP_BP_ID => IP_BP_ID,
        IOP_ACC_SEQ_NO => IOP_ACC_SEQ_NO,
        OP_ERROR => OP_ERROR
      /* Legacy output:
    DBMS_OUTPUT.PUT_LINE('IOP_ACC_SEQ_NO = ' || IOP_ACC_SEQ_NO);
      :IOP_ACC_SEQ_NO := IOP_ACC_SEQ_NO;
      /* Legacy output:
    DBMS_OUTPUT.PUT_LINE('OP_ERROR = ' || OP_ERROR);
      :OP_ERROR := OP_ERROR;
    END;

    Something like this:
    Assuming you have a procedure like this:
    CREATE OR REPLACE PROCEDURE abc (p_emp emp%ROWTYPE)
    IS
    BEGIN
       DBMS_OUTPUT.put_line (p_emp.empno);
    END;
    Then you have to call it from a PL/SQL Block in this way i.e.:
    DECLARE
      v_emp emp%ROWTYPE;
    BEGIN
      SELECT *
        INTO v_emp
        FROM emp
       WHERE ROWNUM<=1;
       abc(v_emp);
    END;
    Regards.
    Al

Maybe you are looking for