Same WITH used in many SQL statements

Hi,
I have a need to use the same WITH clause in many places of my code. Is it ever possible to code without writing the same code in every SQL which need my WITH?
Thanks in advance.

As Tubs mentioned, views.
There only 2 basic methods of modularisation of SQL source code. Using the WITH clause (modularises in the same statement), or VIEWS (modularises across SQL statements).
Using PL/SQL functions or pipelined tables are poor choices for SQL code modularisation. And should not be considered. These tools address a different set of requirements.

Similar Messages

  • The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.

    Hello All,
    I am getting below error can you please help me
    Error:-
    The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.

    Perhaps this thread will help you out
    http://stackoverflow.com/questions/11453066/error-the-transaction-associated-with-the-current-connection-has-completed-but
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • PL SQL using variable in SQL statement

    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dual
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1
    select to_char(val) from dual
    Thanks in advance to all who answer

    Hi,
    840386 wrote:
    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?No, you don't need a bind variable, though bind variables may be more efficient than using PL/SQL variables. I don't see where you're trying to use any varibables at all in your examples. Is it in place of the literals, such as 2 or 'YYYY_MM_DD'? You can use either bind varibales or PL/SQL variables in those places.
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dualIn PL/SQL, when you have a SELECT statement, you must specify what you want to do with the results. For example, a SELECT ... INTO statement:
    SELECT  AVG (sal)
    INTO    avg_salary
    FROM    scott.emp;There's usually no point in SELECTing from dual in PL/SQL. It's not an error, but it's simpler just to use an assignment statement.
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.Post a complete procedure or anonymous block, including variable declarations, that shows exactly what you're trying to do.
    >
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1Assuming val is a DATE, that's basically correct. You have unbalanced parentheses (there's a '(', but no matching ')' ), and you need a semicolon (';') at the end of the statement. Perhaps ');' just got cut off when you were posting this.
    select to_char(val) from dualAgain, SELECTing from dual is unnecessary, but if you had some way to catch the returned value, that would work.
    Usually, the reason why you need to call TO_CHAR is that you want a value in a particular format, which is specified in the 2nd argument to TO_CHAR. Calling TO_CHAR with only one argument is a possible mistake, but not something that would raise an error.
    Here's an example that works:
    SET     SERVEROUTPUT     ON
    DECLARE
         d     DATE;
         v     VARCHAR2 (30);
    BEGIN
         d := ADD_MONTHS (SYSDATE, -2);          -- -2 = (-2*1)
         v := TO_CHAR (d, 'DD-Mon-YYYY');
         dbms_output.put_line (v || ' = v');
    END;
    /Output (when run on March 13, 2011):
    13-Jan-2011 = v

  • Use variable in SQL statement

    HI guys:
    I need code three SQL statements.the returned field and selected table are all same,there is only a difference in their "where" statement.
      Sample code:
        select marcmatnr marcwerks
        into table it_data
        from MARC inner join MBEW on marcmatnr = mbewmatnr
        where marcmatnr like 'A%' and mbewzplp1 = '001'.
        second one........................ mbew~zplp2 = '001'
        third one......................... mbew~zplp3 = '001'
      Could I write a FORM gather them with transporting a parameter ZPLPX to determine which condiniton will be execute?
    thank you very much.

    Hi tianli,
    1. source text
       This concept of dynamic where
       condition is called source text.
    2. use like this.
       This is important in the code  --->  WHERE (mywhere).
    REPORT abc LINE-SIZE 80.
    DATA : it_data LIKE TABLE OF mara WITH HEADER LINE.
    QUOTES ARE IMPORTANT
    PERFORM mysql USING 'mbew~zplp2 = ''001'''.
    FORM mysql USING mywhere.
      SELECT marcmatnr marcwerks
      INTO TABLE it_data
      FROM marc INNER JOIN mbew ON marcmatnr = mbewmatnr
      WHERE (mywhere).
    ENDFORM.                    "mysql
    regards,
    amit m.

  • Using Procedure in SQL statement

    Dear Sir,
    As you know, I can use any function in SQL statement. For example:
    SELECT systimestamp,
    Function_Name(variable1, variable2,...)
    FROM anytable;
    So the previous function could only retrieve one value -as functions concepts-. Anyhow, Can I, in someway, use Procedure that take multiple in parameters and return multiple out parameters in SQL statement.
    Thank you in advance.

    Sir,
    I got a way in order to use the benefit of procedure in function. It's trough your idea in using TYPE OBJECT as the following:
    ===================================================================
    create or replace type Missed_Txn_type AS OBJECT
    (Txn_Timestamp_obj timestamp,
    Txn_Type_Obj Number(12));
    ===================================================================
    Then I created function and used this type as returned value:
    FUNCTION Get_Shift_Missed_Txn_Obj(F_Date_In     Date,
                        F_Time_In Timestamp,
                        F_Employee_Id     number)
    RETURN Missed_Txn_type;
    The issue is: I want send the variables of the function through SELECT statement which they come from another table like:
    SELECT
    EMP.ID,
    sd.date_value,
    shf.Time_In,
    T.OBJ.Txn_Timestamp_obj,
    T.OBJ.Txn_Type_Obj
    FROM
    EMPLOYEE EMP,
    Stored_Date SD,
    Shifts shf,
    (select Get_Shift_Missed_Txn_Obj(sd.date_value,
    shf.time_in,
    EMP.Id) OBJ from dual) T
    WHERE
    [where clause]
    But the previous statement returned an error shows that it couldn't determine the (EMP.ID, shf.time_in, sd.date_value...)...
    And the same if I use it in the select list!
    So sir, there is any way in order to solve this issue?
    Thank you in advance.

  • Function or pseudo-column 'DECODE' may be used inside a SQL statement only

    Hi everyone!
    I got the error in the subject concernig the follow piece of sql code
    + v_str_sql_body :=
    v_str_sql_body || ' and cod_entita ='
    || decode(cur.cod_entita_a,str_all,cur_ent.cod_entita,cur.cod_entita_a);
    execute immediate v_str_sql_body; +
    I can't understand what's the problem with it.
    Can anyone help me to find the error?
    Thank you in advance!
    Samuel
    Edited by: 996508 on 27-mar-2013 5.29

    Hi, Samuel,
    Welcome to the forum!
    996508 wrote:
    Hi everyone!
    I got the error in the subject concernig the follow piece of sql code
    + v_str_sql_body :=
    v_str_sql_body || ' and cod_entita ='
    || decode(cur.cod_entita_a,str_all,cur_ent.cod_entita,cur.cod_entita_a);
    execute immediate v_str_sql_body; +
    I can't understand what's the problem with it.Sorry, I can't understand what you're trying to do.
    Whenever you have a problem, post a complete script that people can run to re-create the problem and test their ideas. Include your complete PL/SQL code (if the problem involves PL/SQL) including code to call your procedure, a little sample data (CREATE TABLE and INSERT statements) for any tables involved, and the results you want the given sample data.
    Always say which version of Oracle you have (e.g., 11.2.0.3.0).
    See the forum FAQ {message:id=9360003}
    Can anyone help me to find the error?As the error message says, you can only use DECODE in a SQL statement. That is:
    v_str_body := v_str_body
            || ' and cod_entita = '
            || DECODE (...);is always an error, no matter what ... stands for.
    Perhaps you meant to have the DECODE inside the string literal.
    If not, then (depending on your version) you can use CASE instead of DECODE:
    v_str_body := v_str_body
            || ' and cod_entita = '
            || CASE  cur.cod_entita_a
                     WHEN  str_all  THEN  cur_ent.cod_entita
                                 ELSE  cur.cod_entita_a
               END;Anything that DECODE can do, CASE can do, too.
    DECODE is sometimes a little simpler than CASE to use, but only a little. It is never faster than CASE.
    CASE is sometimes much, much simpler to use than DECODE, and sometimes much faster, too.
    I won't say never use DECODE; but I will say rarely use DECODE. Use CASE instead, unless you have a specific reason why DECODE is better in that particular situation.
    In PL/SQL, you can also use IF ... THEN ... ELSE in places where you might want to use DECODE or CASE.
    For example:
    v_str_body := v_str_body
            || ' and cod_entita = ';
    IF  cur.cod_entita_a = str_all
    THEN
        v_str_body := v_str_body
                    || cur_ent.cod_entita;
    ELSE
        v_str_body := v_str_body
                    || cur.cod_entita_a;
    END IF;Edited by: Frank Kulash on Mar 27, 2013 5:59 PM
    Added IF ... THEN ... ELSE example.

  • Help With SUBSTR in dynamic SQL statement

    Following is the dynamic SQL statement.
    EXECUTE IMMEDIATE 'UPDATE table_name pml
    SET pml.'|| con_fields.field ||' = SUBSTR(pml.'||con_fields.field||' ||'' ''||
    (SELECT pml1.'||con_fields.field||'
    FROM table_name pml1
    WHERE pml1.grp_id = '||los_concats.grp_id ||'
    AND pml1.row_id = '||los_concats.row_id||'
    AND pml1.loser_flg = ''Y''),1, '||con_fields.max_length||')
    WHERE pml.grp_id = '||los_concats.grp_id ||'
    AND pml.loser_flg IS NULL ';
    what it does is that it updates a particular field. This field is concatenated by a field of a similar record.
    My problem is with SUBSTR function. Since I am concatenating fields I do not want the field to be updated greater than max_length on that field, the reason why I use SUBSTR. the select query inside SUBSTR works alright with one of the AND condition in a WHERE clause not present. When I add that additional condition it gives me this error.
    ORA-00907: missing right parenthesis.
    Is there any way to get around this problem. Does SQL has other than SUBSTR function which can limit the character length.
    Appreciate it.

    The other alternative I thought about was to do this first
    EXECUTE IMMEDIATE 'SELECT pml.'||con_fields.field||'
    FROM table_name pml
    WHERE pml.grp_id = '||los_concats.grp_id||'
    AND pml.row_id = '||los_concats.row_id||'
    AND pml.loser_flg = ''Y''
    ' INTO v_concat_field;
    write into the variable v_concat_field and then use it into the previous script.
    But on this I get SQL Command not properly terminated, I don't get it Why?
    Donald I tried with your suggested script. It works fine with one of the conditions eliminated. I don't understand what the error trying to say?
    Thanks

  • HELP!!! the session hang with a merge into sql statement

    This problem is due to merge into a bug caused it??
    i have a product run on 10.2.0.4 . OS is aix 5.3 .
    today i found the product running over 24,000 sec and the current sql have run 23,734.
    Anomaly the sql Should be a quick end but run so long time.
    the awrsql report sql plan is
    Execution Plan
    Id Operation Name Rows Bytes Cost (%CPU) Time
    0 MERGE STATEMENT 4 (100)
    1 MERGE TP_B_RB013_GL_MID
    2 VIEW
    3 NESTED LOOPS 1 4048 4 (50) 00:00:01
    4 TABLE ACCESS BY INDEX ROWID TP_B_RB013_GL_MID 1 3549 0 (0)
    5 INDEX RANGE SCAN IDX_GL_RB013_MID 1 0 (0)
    6 VIEW PUSHED PREDICATE 1 499 4 (50) 00:00:01
    7 WINDOW SORT PUSHED RANK 1 586 4 (50) 00:00:01
    8 HASH JOIN 1 586 3 (34) 00:00:01
    9 TABLE ACCESS BY INDEX ROWID GL_HIST_RB013 1 124 0 (0)
    10 INDEX SKIP SCAN IDX_GL_RB013 1 0 (0)
    11 TABLE ACCESS FULL GL_EVENT 1 462 2 (0) 00:00:01
    sql_fulltext
    MERGE INTO TP_B_RB013_GL_MID TP
    USING (SELECT TRAN_NO,
    B.EVENT_DEESC,
    ROW_NUMBER () OVER (PARTITION BY TRAN_NO ORDER BY B.EVENT_DESC) I
    FROM GL_HIST_RB013 A, GL_EVENT B
    WHERE EVENT_TYPE IS NOT NULL AND A.EVENT_TYPE = B.EVENT_ID AND B.SDATE = :B1
    ) RES
    ON ( RES.TRAN_NO = TP.BATCH_NO AND RES.I = 1 AND TP.REPORT_DATE = :B1 )
    WHEN MATCHED THEN
    UPDATE SET TP.EVENT_DESC = RES.EVENT_DESC
    Focus is the table "GL_EVENT" have 0 row,the sql should do nothing.
    This problem is due to merge into a bug caused it??
    last is awrsqlrpt Please note cputime and buffer gets
    WORKLOAD REPOSITORY SQL Report
    Snapshot Period Summary
    DB Name DB Id Instance Inst Num Release RAC Host
    FTLPRD 3272430330 FTLPRD 1 10.2.0.4.0 NO bj1finteldb0
    Snap Id Snap Time Sessions Curs/Sess
    Begin Snap: 5022 26-11?-11 21:00:35 127 12.1
    End Snap: 5030 27-11?-11 05:00:40 127 14.0
    Elapsed: 480.09 (mins)
    DB Time: 626.55 (mins)
    SQL Summary DB/Inst: FTLPRD/FTLPRD Snaps: 5022-5030
    Elapsed
    SQL Id Time (ms)
    a4j4qaqkvxr08 ##########
    MERGE INTO TP_B_RB013_GL_MID TP USING (SELECT TRAN_NO, B.EVENT_DESC, ROW_NUMBER
    () OVER (PARTITION BY TRAN_NO ORDER BY B.EVENT_DESC) I FROM GL_HIST_RB013 A, GL_
    EVENT B WHERE EVENT_TYPE IS NOT NULL AND A.EVENT_TYPE = B.EVENT_ID AND B.SDATE =
    :B1 ) RES ON ( RES.TRAN_NO = TP.BATCH_NO AND RES.I = 1 AND TP.REPORT_DATE = :B1
    SQL ID: a4j4qaqkvxr08 DB/Inst: FTLPRD/FTLPRD Snaps: 5022-5030
    -> 1st Capture and Last Capture Snap IDs
    refer to Snapshot IDs witin the snapshot range
    -> MERGE INTO TP_B_RB013_GL_MID TP USING (SELECT TRAN_NO, B.EVENT_DESC, R...
    Plan Hash Total Elapsed 1st Capture Last Capture
    # Value Time(ms) Executions Snap ID Snap ID
    1 3274057091 23,733,870 0 5024 5030
    Plan 1(PHV: 3274057091)
    Plan Statistics DB/Inst: FTLPRD/FTLPRD Snaps: 5022-5030
    -> % Total DB Time is the Elapsed Time of the SQL statement divided
    into the Total Database Time multiplied by 100
    Stat Name Statement Per Execution % Snap
    Elapsed Time (ms) ########## N/A 63.1
    CPU Time (ms) 23,734 N/A 94.7
    Executions 0 N/A N/A
    Buffer Gets 371,326,923 N/A 84.8
    Disk Reads 16,740 N/A 0.2
    Parse Calls 1 N/A 0.0
    Rows 0 N/A N/A
    User I/O Wait Time (ms) 145,938 N/A N/A
    Cluster Wait Time (ms) 0 N/A N/A
    Application Wait Time (ms) 0 N/A N/A
    Concurrency Wait Time (ms) 2,348 N/A N/A
    Invalidations 0 N/A N/A
    Version Count 7 N/A N/A
    Sharable Mem(KB) 435 N/A N/A
    Execution Plan
    Id Operation Name Rows Bytes Cost (%CPU) Time
    0 MERGE STATEMENT 4 (100)
    1 MERGE TP_B_RB013_GL_MID
    2 VIEW
    3 NESTED LOOPS 1 4048 4 (50) 00:00:01
    4 TABLE ACCESS BY INDEX ROWID TP_B_RB013_GL_MID 1 3549 0 (0)
    5 INDEX RANGE SCAN IDX_GL_RB013_MID 1 0 (0)
    6 VIEW PUSHED PREDICATE 1 499 4 (50) 00:00:01
    7 WINDOW SORT PUSHED RANK 1 586 4 (50) 00:00:01
    8 HASH JOIN 1 586 3 (34) 00:00:01
    9 TABLE ACCESS BY INDEX ROWID GL_HIST_RB013 1 124 0 (0)
    10 INDEX SKIP SCAN IDX_GL_RB013 1 0 (0)
    11 TABLE ACCESS FULL GL_EVENT 1 462 2 (0) 00:00:01
    Full SQL Text
    SQL ID SQL Text
    a4j4qaqkvxr0 MERGE INTO TP_B_RB013_GL_MID TP USING (SELECT TRAN_NO, B.EVENT_DE
    ESC, ROW_NUMBER () OVER (PARTITION BY TRAN_NO ORDER BY B.EVENT_DE
    SC) I FROM GL_HIST_RB013 A, GL_EVENT B WHERE EVENT_TYPE IS NOT NU
    LL AND A.EVENT_TYPE = B.EVENT_ID AND B.SDATE = :B1 ) RES ON ( RES
    .TRAN_NO = TP.BATCH_NO AND RES.I = 1 AND TP.REPORT_DATE = :B1 ) W
    HEN MATCHED THEN UPDATE SET TP.EVENT_DESC = RES.EVENT_DESC

    Pl do not spam the forums with duplicate posts - HELP !!!  session pending or suspend beacause a merginto sql

  • Using arrays in sql statement

    Hello,
    I would like to use integer array( say..int count[] = new int[3];) on my sql statement to retrieve some values. Is there a way to use int array variable in sql statement?. If yes, how should I approach doing that?.
    Thank You in Advance.
    Regards,
    Pinal.

    I'm going to be honest, I'm not so sure there is such a thing in standard SQL syntax so it would depend upon the database you were using as to whether this option was available as part of the SQL language.
    My suggestion would be to cheat, naughty I know:String arrayString = "";
    for (int i = 0; i < arrayInt.size(); i++) {
      arrayString += "**" + arrayInt;
    arrayString = arrayString.substring(2, arrayString.length());Then just parse arrayString in to an SQL VARCHAR or TEXT field.
    Obviously when you return it just use StringTokenizer to split the string up using your deliminator (in this case **) and then convert the values back into an int array.
    I'm not sure how efficient that code would be but it should do the job.

  • Many SQl Statements

    Hello,
    i have following Problem, when i inserted data in the table "t_test",i have to do maually
    10 SQL Statements to update this table.
    Now i would like a method, how i can do this automatically.
    THX Paul

    Hi,
    You could put all of your code into a packaged procedure and then call that packaged procedure from your application passing in any parameters that you need to pass.
    Take a look here for more information on packages -
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/packages.htm

  • Issues with using Embedded PL SQL Gateway with Apex 4.2

    Hi,
    I have installed Oracle 11g R2 and want to develop an application using Apex 4.2 (needs upgrade from 3.2 version which has come bundled).
    For the server, I would like to use the Oracle HTTP server, but it seems to require a separate license as against the same in Oracle10g.
    I would like to know what are the performance related issues b/w using the embedded PL/SQL Gateway (Oracle XML DB HTTP Server) that comes with Oracle 11g R2 as against the HTTP Server found as a part of the fusion middleware bundle. Is it wise to procure the license for HTTP Server?
    Details:
    DB OS: Windows 7 (64 bit) (DB and Apex are on the same machine)
    Number Of Users of application: 10-20
    Application is mainly used more for keeping track of details as against heavy processing or the like
    Thanks

    For the server, I would like to use the Oracle HTTP server, but it seems to require a separate license as against the same in Oracle10g.What gives you this impression? The licensing position remains the same: OHS is covered by the DB license if OHS is run on the same server. See Joel's post and the document he links to: +{message:id=9256804}+.

  • Pleasse help me with this error in SQL statement

    Please tell me the error in this query:
    the Error given is
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    given :
    Databse is MS Access
    In the databse :
    account - text
    number - text
    date - date/time
    vendor - text
    Connection connection = t.getConnection();
    /* t - some object containing a connection*/
    Statement stmt = connection.createStatement();
    stmt.executeUpdate("INSERT INTO Bills (account, number, date, vendor)
    VALUES ('vai', '23', 10/12/2006, 'jaadya')");

    I would imagine the problem is with the date. Different DBs have different date formats. To avoid that problem, use a PreparedStatement.
    java.sql.Date date = ...;
    PreparedStatement ps = con.prepareStatement("INSERT INTO Bills (account, number, date, vendor) VALUES (?, ?, ?, ?)");
    ps.setString(1, "vai");
    ps.setString(2, "23);
    ps.setDate(3, date);
    ps.setString(4, "jaadya");
    ps.executeUpdate();This saves you from having to deal with vendors' various date formats, keeps you from having to escape special characters in strings, and prevents SQL injection.

  • Service that uses several insert sql statements

    Hello!  Is it possible to use one service, which updates two DB tables?  Also, one field in these two tables is the same, like the ProcessID? For example, here is the service:
    <tr>
      <td>EUM_WORKFLOW_UPDATE_ACTIONS</td>
      <td>Service
      3
      null
      null
      null<br>
      null</td>
      <td>2:IEumWorkflowActions:::null
            2:IEumWorkflowDocumentProcess:::null</td>-->
    </tr>
    Here are two separate SQL queries called from the above service:
    <tr>
      <td>IEumWorkflowActions</td>
      <td>INSERT INTO EUM_WORKFLOW_ACTIONS(WORKFLOWACTION, WKFLACTIONID) values (?, ?)</td>
      <td>WORKFLOWACTION varchar
      WKFLACTIONID int</td>
    </tr>
    <tr>
      <td>IEumWorkflowDocumentProcess</td>
      <td>INSERT INTO EUM_WORKFLOW_ACTIONS(WKFLACTIONID, DocumentProcessID, dDocName, dRevLabel) values (?, ?, ?, ?)</td>
      <td>WKFLACTIONIDint
      DocumentProcessID int
      dDocName varchar
      dRevLabel varchar</td>
    </tr>
    And here is how I call this service via GenericSoapPort call:  
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body xmlns:ns1="http://www.oracle.com/UCM">
        <ns1:GenericRequest webKey="cs">
          <ns1:Service IdcService="EUM_WORKFLOW_UPDATE_ACTIONS">
            <ns1:User></ns1:User>
            <ns1:Document>
              <ns1:Field name="WORKFLOWACTION">Reject</ns1:Field>
              <ns1:Field name="WKFLACTIONID">123</ns1:Field>
              <ns1:Field name="WKFLACTIONID">123</ns1:Field>
              <ns1:Field name="DocumentProcessID">45234</ns1:Field>
              <ns1:Field name="dDocName">1554322</ns1:Field>
              <ns1:Field name="dRevLabel">1A</ns1:Field>
            </ns1:Document>
          </ns1:Service>
        </ns1:GenericRequest>
      </soap:Body>
    </soap:Envelope>
    Would it be possible NOT to use the WKFLACTIONID twice in the service call somehow?
    Thank you for your help!

    Thank you for the confirmation that this would work.  I've also tried the Insert query like this:
    insert all
    into EUM_WORKFLOW_ACTIONS (WORKFLOWACTION, WKFLACTIONID) values (?, ?)
    into EUM_WORKFLOW_DOCUMENT_PROCESS (WKFLACTIONID, DOCUMENTPROCESSID) values (?, ?)
    select * from dual
    Would this single SQL be better for my purposes then the two statements?  If that would matter at all?
    Thank you!

  • Use param for SQL statement...

    Hi, all,
    Thanks for the help.
    I have a select statement working in sqlplus:
    SELECT A.addressid
    FROM JOHNDOE.tb_Address A, JOHNDOE.tb_Address B
    WHERE B.Addressid = 1
    AND SDO_WITHIN_DISTANCE(A.Location, B.location, 'DISTANCE = 12.8 UNIT = MILE') = 'TRUE';
    Now that I am coding in PL/SQL and to use a param to replace "12.8". Like the following:
    var p_radius NUMBER;
    exec :p_radius :=12.8;
    print p_radius;
    SELECT A.addressid
    FROM JOHNDOE.tb_Address A, JOHNDOE.tb_Address B
    WHERE B.Addressid = 1
    AND SDO_WITHIN_DISTANCE(A.Location, B.location, 'DISTANCE = ' || p_radius || 'UNIT = MILE') = 'TRUE';
    commit
    Note that with "|| p_radius ||", this is NOT working. How should I put it?
    Thanks a lot.
    -xiaocao

    Try putting a COLON in front of your reference to p_radius....
    AND SDO_WITHIN_DISTANCE(A.Location, B.location, 'DISTANCE = ' || :p_radius || 'UNIT = MILE') = 'TRUE';
    HTH
    Jeff

  • Help with a really simple SQL statement

    Hi All
    I'm relatively new to SQL and can't get my head round what I believe to be a really simple problem.
    I have a table I want to query called locations. We use locations to mean groups and regions as well as people s ofr example:
    TABLE: LOCATION
    IDENTIFIER----------NAME-----------------PART_OF
    101--------------------USER A---------------123
    123--------------------GROUP A-------------124
    etc
    What I'm trying to write is a statement that will return the 'PART_OF' as the 'NAME' rather than the ID number if the ID = 101.
    I was wondering if a nested select statement would do (select as select etc) but just can't get my head round it!
    Any ideas?
    TIA. Jake.

    Hi Jake,
    It's not clear what you are looking for. If USER A is just Part of GROUP A, a self-join will do:
    SQL> with loc as (select 101 locid, 'USER A' locname, 123 part_of from dual
                 union all
                 select 123 locid, 'GROUP A' locname, 124 part_of from dual
                 union all
                 select 124 locid, 'REGION A' locname, null part_of from dual)
    -- End of test data
    select l1.locid, l1.locname, l2.locname part_of
      from loc l1, loc l2
    where l2.locid(+) = l1.part_of
         LOCID LOCNAME  PART_OF
           101 USER A   GROUP A
           123 GROUP A  REGION A
           124 REGION A        
    3 rows selected.But if you want USER A to be part of REGION A, then you need a hierarchia lquery:
    SQL> with loc as (select 101 locid, 'USER A' locname, 123 part_of from dual
                 union all
                 select 123 locid, 'GROUP A' locname, 124 part_of from dual
                 union all
                 select 124 locid, 'REGION A' locname, null part_of from dual)
    -- End of test data
    select l1.locid, l1.locname, connect_by_root(locname) part_of
      from loc l1
    start with part_of is null
    connect by prior locid = part_of
         LOCID LOCNAME  PART_OF
           124 REGION A REGION A
           123 GROUP A  REGION A
           101 USER A   REGION A
    3 rows selected.Regards
    Peter

Maybe you are looking for

  • HP Recovery Manager only shows a black screen when opened on dv6t

    I just recently got a HP Pavilion dv6t-6c00 notebook and I tried to create my set of recovery discs, which I've already been having trouble with because I don't have the right brand of DVDs. I still haven't completed the process of making all 5 recov

  • Each item in the delivery should have separate invoice

    HI friends, who to do separated invoice for each item of the delivery, even if the bill to party and billing dates are same. thanks nitchel

  • Macbook display uneven

    hi, my macbook pro laptop's screen seems slightly uneven. The left side seems to be slightly higher than the right side when the laptop is closed. I see more space between the screen to the base (not sure if this makes sense). Is this normal? For tho

  • Time scaling

    How can I perform Time scaling on a signal like getting X(2t) or X(t/2) from x(t) in labVIEW. PLease reply quick.

  • I can't open my most recent catalog, please help!!

    I can't open my most recent catalog but I can open older ones and it's not the lock file as there isn't one....  I get a crash report saying that lightroom encountered an error reading from it's preview cache and needs to quit but will try to fix the