SQL Usage within PLD

We will often drop ship for customers. I have created a UDF to use as the ship to company name if we are not using the BP name. What I would like to do is have PLD use this if it is populated, but use CardName if it isn't (on our Packing Lists). If it were a query I could use:
CASE WHEN ODLN.U_ShipToCo IS NULL THEN OCRD.CardName ELSE ODLN.U_ShipToCo
I tried creating a new field and using the formula option, but that seems to want to only work with mathematical functions.
Any suggestions?
Thanks!
Monica

Hi Monica,
Try this,
Case 1
->> Create 1 UDF in Header level on Marketing Documents.
->> Assign the below FMS in UDF. This FMS will retrieve the Current CardCode (or) U_ShipToCo value.
->> put the UDF field in PLD.
Ex.
Table - ODLN.
Column - U_ShipToCo.
it will be work exactly.
SELECT DISTINCT
CASE WHEN $[ODLN.U_ShipToCo] = ' ' THEN $[ODLN.CardCode]
WHEN $[ODLN.U_ShipToCo] != ' ' THEN $[ODLN.U_ShipToCo]
ELSE 'NULLVALUE' END
FROM ODLN
Example:
Field_123 -> CardCode.
Field_456 -> U_ShipToCo value.
Case 2
->> Open the PLD and Create 2 database field in header.
->> 1 Database field is retrieve the CardCode Value and Another 1 Database field is retrieve the U_ShipToCo Value.
->> Create 1 Formula field in Header and assign the formula for Link to CardCode.
Formula Field ID - Field_789
Field_456==' '
->> Click Content Tab and Assign the Link to fields on Properties Window.
Link To
Field_123 Link To Field_789
Field_456 Link To Field_456
Save the PLD and see the Print Preview.
Regards,
Madhan.

Similar Messages

  • Queries on pl/sql tables within a function

    hi,
    how can i execute regular sql-queries within a function on a pl/sql table which the function has recieved as a parameter ? i have tried quite a bit and always get type mismatches or internal errors. anybody has a good example on this ?
    thanks in advance,
    stephan

    hi,
    okay, i will not post the actual code i have, because it won't make too much sense out of the context, but here are the relevant parts...
    i have a few object definitions that represent the records of the three tables (two input and one output)...
    create type t1 as object (...);
    create type t2 as object (...);
    create type t3 as object (...);
    and a package with the table definitions
    create or replace package t_defs as
    type tab_t1 is table of t1;
    type tab_t2 is table of t2;
    type tab_t3 is table of t3;
    end t_defs;
    and here is a rough sketch what the function should look like later:
    CREATE OR REPLACE FUNCTION some_function (
    tab1 IN t_defs.tab_t1, tab2 IN t_def.tab_t2)
    RETURN t_defs.tab_t3 PIPELINED IS
    TYPE refcur IS REF CURSOR;
    cur0 refcur;
    curr_rec t3 := t3(NULL, ....);
    BEGIN
    open cur0 for 'here is the statement i could not do';
    LOOP
    FETCH cur0 INTO curr_rec.....;
    EXIT WHEN cur0%NOTFOUND;
    . -- (manipulate the record) --
    PIPE ROW(curr_rec);
    END LOOP;
    RETURN;
    END;

  • Anonymous PL/SQL block within a select statement

    I read somewhere that it was possible to build an anonymous pl/sql block within a sql statement. Something along the lines of:
    select
    begin
    i = 0;
    return i;
    end;
    from dual;
    However, for the life of me, I can't find documentation on this. Could someone please point me to the right place, assuming I'm not just imagining it.
    Thanks.

    Did you mean, executing a pl/sql block generated from an sql.
    declare
    cmd varchar2(100);
    begin
    select 'declare i pls_integer := 0; begin i:=1; end;' into cmd from dual;
    execute immediate cmd;
    end;
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Is the anyway to get a report of component usage within an Application.

    It would sure be 'nice' to have a report of the component usage within an Application. I am most interested in where the LOVs are being referenced. It is extremely time consuming to check every report/form item by item. I'm sure this information is available 'somewhere' within the Portal schema but I don't know where. Anyone got any ideas? Thanx in advance

    Such info can be obtained from Portal schema.
    Those tables are not granted to public.
    How do you plan to use it? For your own maintain purpose?

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • Multiple SQL Update within Parent Query

    I am tring to extract an image from within a MS SQL image field,
    opening the image using JAI, getting the src.getWidth() & src.getHeight
    () of each item within the database, and then writing the width and
    height back into the database. Everything works except when I goto
    write the values into the database - the page (when loading) continues
    to work and work and work until I restart the tomcat service. I do not
    understand why this would occur, and what is even stranger - I have
    very similar code i used for resizing images in the database into a
    thumbnail - display and original file sizes using a similar approach...
    and that works with out a problem...
    I have tried the code with out the inner update query - it works. I
    tried with just the selection of a single specific item in the first
    query and that works, but when I try multiple updates the second query
    appears to stall.
    The code is as follows.:
    <%@ page language="java" import="javax.servlet.*,javax.servlet.http.*,java.io.*,java.util.*,java.sql.*,javax.media.jai.*,java.awt.*,java.awt.image.*,java.awt.Graphics.*,java.awt.geom.*,java.awt.image.renderable.*,javax.media.jai.widget.*,com.jspsmart.upload.*,java.net.*,com.sun.media.jai.codec.*"%>
    <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
    <%
         // Variables
         int count=0;
         int width                                             = 0;
         int height                                             = 0;
         String vFileName                                   = "";
         String vFileExt                                        = "";
         String vFileID                                        = "";
         String format                                        = "0";
         // Connect to the database
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
         Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://206.152.227.62:1433;DatabaseName=WWWBBD;User=wwwbbd;Password=bbd1412");
         //Create the statement
         Statement sqlGetPics                              = con.createStatement();
         Statement sqlUpdate                                   = con.createStatement();
         //build the query
         String qryGetPics                                   = "SELECT TOP 5 FileID, FileExt, FileName, AdjFile = CASE WHEN FullFile IS NULL THEN Display ELSE FullFile END FROM FileStore WHERE (UPPER(FileExt) = '.JPG' OR UPPER(FileExt) = '.TIF' OR UPPER(FileExt) = '.GIF' OR UPPER(FileExt) = '.BMP') AND (NOT Display IS NULL OR NOT FullFile IS NULL)";
         //execute the query
         ResultSet rsGetPics                                   = sqlGetPics.executeQuery(qryGetPics);
         // Initialization
         SmartUpload uploader                              = new SmartUpload();
         uploader.initialize(getServletConfig(),request,response);
         mySmartUpload.initialize(getServletConfig(), request, response);
         // Upload
         mySmartUpload.upload();
         while (rsGetPics.next()) {
              vFileID                                             = rsGetPics.getString("FileID");
              vFileExt                                        = rsGetPics.getString("FileExt");
              vFileName                                        = rsGetPics.getString("FileName") + vFileExt;
              width                                             = 0;
              height                                             = 0;
              uploader.fieldToFile(rsGetPics, "AdjFile", "/upload/" + vFileName);
              if (vFileExt.equalsIgnoreCase(".JPG") || vFileExt.equalsIgnoreCase(".JPEG"))
                   format                                        = "JPEG";
              else if (vFileExt.equalsIgnoreCase(".TIF") || vFileExt.equalsIgnoreCase(".TIFF"))
                   format                                        = "TIFF";
              else if (vFileExt.equalsIgnoreCase(".GIF"))
                   format                                        = "JPEG";
              else if (vFileExt.equalsIgnoreCase(".BMP"))
                   format                                        = "BMP";
              else
                   format                                        = "0";
              // update the width & height
              if (format != "0")
                   try
                        //Opens the image
                        RenderedImage src                    = JAI.create("fileload","d:\\servers\\tomcat\\webapps\\jsp\\upload\\" + vFileName);
                        width                                   = src.getWidth();
                        height                                   = src.getHeight();
                        java.io.File imageFile               = new java.io.File("d:\\servers\\tomcat\\webapps\\jsp\\upload\\" + vFileName);
                        InputStream is                         = new FileInputStream(imageFile);
                        //build the query
                        String qryUpdate                    = "UPDATE FileStore SET Width = " + width + ", Height = " + height + " WHERE FileID = " + vFileID;
                        //execute the query
                        ResultSet rsUpdate                    = sqlUpdate.executeQuery(qryUpdate);
                        %>[<%=width%>x<%=height%>:<%=vFileID%>:<%=qryUpdate%>]<BR><%
                   catch(Exception e)
                        {out.println("An error occurs : " + e.toString());}               
              count++;          
         //rsUpdate.close();
         sqlUpdate.close();
    %>
    <HTML>
    <HEAD>
         <TITLE>Repair Files</TITLE>
    </HEAD>
    <BODY>
    <%=count%> files updated in the database.
    </BODY>
    </HTML>

    BTW - I also tried this with a prepared statment query... no good.

  • Passing variables to a SQL script within GC

    Does anyone know if it is possible to pass in a variable to a SQL script job within Grid Control? I don't see that I can but I wanted to ask a larger group before cloing the loop on this.
    For example, I have a few different databases which contain schemas which contain date-range daily partitioned tables. I have a single code block which normally accepts the table_owner as a variable then loops through to analyze the current day partition. I'd love for OEM to be able to have the job submitted to different database targets whilst passing in a different schema name.
    Thank you in advance!

    This can be done in two steps, but first create a table containing 1 field in all the target databases (something like table_owner) you want to analyze. Before running the analyze script change in all the to be analyzed databases the table_owner (as a job?). Then run the analyze script that contains a statement that first reads the table_owner and use this table_owner as the variable you want.
    Even more simple would be to use a database link from the to be analyzed db's to a central db so you only have to change the table_owner in one table.
    Eric

  • SYS_GUID()  SQL functions within XQuery

    Is there any simple way to invoke regular SQL functions from within XQuery?
    I would like to create an identifier attribute, and set the value to SYS_GUID(), but when I try to directly embed the function, it comes back saying:
    ORA-19237: XP0017 - unable to resolve call to function - fn:SYS_GUID
    select XMLQUERY('
    <AgeCmf dtm="{current-dateTime()}" id="{SYS_GUID()}"/>
    ' RETURNING CONTENT) from dual;
    I could dump the value into a temp table, or make it an input parameter via another function, but I am looking for something simple within a SQL call.
    Thanks,
    HW

    Maybe this?:
    michaels>  select xmlquery('<AgeCmf dtm="{current-dateTime()}" id="{s}"/>' passing xmltype('<s>' || sys_guid() || '</s>') returning content) x from dual
    X                                                                                                 
    <AgeCmf dtm=" 2007-06-20T07:05:19.515000+02:00" id="6304A70F5C104ACB98C69EEB3D47891C"></AgeCmf>   

  • Reporting on link usage within federated portal environment

    Hi,
    We have a fedrated portal environment and woul like to be able to report on how many users click on a web link within one of the portal pages.  Is there an easy way to gather this information across all of the portal systems?
    Thanks in advance.

    I agree with Oliver on how easy it is to misunderstand SSO. People unfamiliar with the technology often assume that all varieties of SSO (e.g., logon tickets, x.509 certificates) are all sufficiently "secure".
    It seems like people talk a lot more about logon tickets in the SNC. That's fine and all (because it's free), but people might be overlooking the security problem with logon tickets; they share the same security problems with web browser cookies (because a login ticket is essentially a cookie).
    Additionally, there's the issue of insecure communications. If you use certificates to authenticate, then you can take advantage of SAP's "Secure Network Communications" technology. It's something like SSL but for the RFC/DIAG protocol.
    One word of caution though: SAP only provides SNC from server-to-server with the SAP Cryptographic Library for free. For client-to-server encrypted communications, you probably have to find a vendor in the SAP EcoHub. You can query something along the lines of "single sign-on". Just find a vendor that uses certificate-based SSO. Most of the time they can deal with whichever identity repository that your company uses (e.g., ADS, eDirectory, RSA, SQL).
    Summary:
    1) There are different forms of SSO with different levels of "security"
    2) Pay some attention to encrypted communications (you can address two important problems with the "right" SSO technology
    3) You can do a lot with free SAP tools (e.g., cryptolib, logon tickets), but be willing to accept the security tradeoffs
    Edited by: Ha Le on Nov 10, 2010 8:26 AM

  • Help with a select statement from a SQL Server within a DTS !!

    Hello Gurus!
    I help with the script bellow, when I run it within DTS (in SQL Sever 2000), I got the error Invalid number/or not a valid month.
    Please bellow with the WHERE CLASUE '08/01/2001' AND '03/09/2002'
    And in the other hand I change this forma to '01-AUG-01' AND
    '03-MAR-2002', the DTS start and run witha successful messages, but it does not returns row, which is wrong.
    Somebady please help!
    Thanks Gurus!
    GET Total ANIs with Trafic By Area Code
    select
         substr(b.ct_num, 0,3) as Area_Codes,
         COUNT(DISTINCT B.CT_NUM) AS ANIS
    from
         wasabi.v_trans A,
         wasabi.V_Sur_Universal B,
         wasabi.V_Sub C,
         wasabi.V_Trans_Typ D
    where
         D.Trans_typ = A.Trans_Typ AND
         A.Sur_ID = B.Sur_ID AND
         C.Sub_ID = A.Sub_ID AND
         a.trans_stat != 'X' AND     
         a.Trans_DTTM >= '08/01/2001'AND
         a.Trans_DTTM < '03/09/2002 AND
         B.AMA3 = 'PHONE1'
         AND C.SUB_ID not in (100117)
    GROUP BY
         substr(b.ct_num, 0,3)
    ORDER BY
         Area_Codes

    I think that you need a "to_date" function eg
    change '08/01/2001' to to_date('08/01/2001','dd/mm/yyyy')

  • Calling set of sql scripts within a sqlscript

    Hi i tried running set of scripts as follows
    SQL>@c:\c1 which connects to the DB
    and i have two more scripts within c1 as follows
    connect usrname/pwd
    @c:\i1
    @c:\i2
    exit
    While running this i get the following error
    SP2-0310: unable to open file "@c:\i1.sql"
    SP2-0310: unable to open file "@c:\i2.sql"
    however if i run as SQL>@i1 SQL>@i2 my execution seems to be fine, it errors out if i wrap it into c1 as mentione above, am i doing something wrong or missing something.

    I see that in your script you run @c:\i1 and in SQLPlus you run SQL>@i1. What happens when in SQLPlus you run SQL>@c:\i1.
    I see that you are working on Windows. Usually the starting directory for SQLPlus on Windows is $ORACLE_HOME\bin and not c:\.

  • Running SQL stored within a varchar2 for an update statement

    I have a table that stores option settings for different programs that run in our system. It just has an id (number), name (varchar2(4000)) and value (varchar2(4000)). I will have one record (id=1) that stores sql code to generate a date that is converted into a character format, something like "to_char(sysdate-60,'YYYY-MM-DD HH24:MI:SS')", and I have two records that store dates (id=2 and 3) as text.
    I want to run something like "update options set value=(select value from options where id=1) where id=2;", but I know that will store my sql code ('to_char(sysdate-60,''YYYY-MM-DD HH24:MI:SS'')'), and not a text-formatted date ('2009-04-16 13:04:05'). Is there any way within sql that I can use an update statement to store the results of value and not value itself? I generally use C++, so if I had to write a function to accomplish this, I would probably place it in the C++ program instead of a pl/sql function.

    "triggers...<shivers>
    Are you allowed to change database-side functionality?"
    For the most part, yes. We're a small group, and I still do most of the DBA work, despite being a C++ developer and having a part-time DBA. The few triggers we have created are for record id numbers on data that a customer will input through APEX, and I will have to keep those. They're only on inserts, do nothing if the id is populated, and don't exist on this table. The trigger here seems to be something deep within oracle that I cannot change.
    CREATE DATABASE LINK LOOPBACK USING '(description=(address=(protocol=beq)(program=/your/path/to/bin/oracle)))';
    UPDATE options SET VALUE = dbms_xmlgen.getxmltype('SELECT VALUE FROM options@loopback WHERE id = 1').EXTRACT('//text()').getstringval () WHERE id = 2;
    ERROR at line 1:
    ORA-12899: value too large for column "TEST"."OPTIONS"."VALUE" (actual: 65, maximum: 55)The "VALUE" column is a varchar(4000). I'm guessing something is too large for one of the oracle functions or there is a problem with a datatype, but I haven't found any answers. Will using extract affect my data in any way, say if my formula has a less than character for some strange reason? I happened to see a comparison between extract().getstringval() and extractval() at [http://pbarut.blogspot.com/2007/01/oracle-xmltype-exctractvalue-vs-extract.html], which makes it look like EXTRACT('//text()').getstringval () will change the less than to '&lt'. I can run tests to check once I get this working, but I'm not sure I can switch the procedure to extractval().
    Edited by: jbo5112 on Jun 15, 2009 5:25 PM -- The forum mangled my response when I actually typed the less than character

  • Execute sql ddl within pl/sql

    Hi, all! I want to execute TRUNCATE TABLE command within a pl/sql block, please let me know if there is any package or way to do so.

    Thanks Todd! Its working
    Now another problem is
    I want to collect information using oracle at the databas end about my database clients on whick pc they are working. I mean what is the name and ip of client pc.
    Hopefully waiting

  • PL/SQL usage in Datawarehousing projects

    Hi,
    In Datawarehousing projects, most of the processing can be done through SQL code directly.
    I found from few articles that we should strongly avoid PL/SQL Scripts in DWH projects.
    But, if situation warrants, can we use PL/SQL for processing in D/W projects, is it advisable?
    Please suggest, thank you.
    Regards,
    DR

    PL/SQL is used instead of single SQL statements due to the "BULK COLLECT/FORALL" functionality which reduces the size of redo operations.It uses more redo, not less.
    Tested in 11.1.0.6:
    SQL> @desc one_million_rows
    Name                                      Null?    Type
    ID                                                 NUMBER
    VAL                                                VARCHAR2(30)
    SQL> set autotrace on statistics
    SQL> insert into test_redo select * from one_million_rows;
    1000000 rows created.
    Statistics
              0  recursive calls
          42508  db block gets
          16959  consistent gets
           5827  physical reads
       48187952  redo size
            920  bytes sent via SQL*Net to client
           1017  bytes received via SQL*Net from client
              4  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
        1000000  rows processed
    SQL> roll
    Rollback complete.
    SQL> set autotrace off
    SQL> SELECT s.value FROM v$mystat s JOIN v$statname n USING (statistic#)
      2  WHERE  n.name = 'redo size';
         VALUE
    317239240
    1 row selected.
    SQL> DECLARE
      2      CURSOR c IS SELECT * FROM one_million_rows;
      3      TYPE t IS TABLE OF one_million_rows%ROWTYPE;
      4      v_rows t;
      5  BEGIN
      6      OPEN c;
      7      LOOP
      8          FETCH c BULK COLLECT INTO v_rows LIMIT 500;
      9
    10          FORALL i IN v_rows.FIRST..v_rows.LAST
    11              INSERT INTO test_redo VALUES v_rows(i);
    12
    13          EXIT WHEN c%NOTFOUND;
    14      END LOOP;
    15  END;
    16  /
    PL/SQL procedure successfully completed.
    SQL> SELECT s.value FROM v$mystat s JOIN v$statname n USING (statistic#)
      2  WHERE  n.name = 'redo size';
         VALUE
    365731476
    1 row selected.
    SQL> select 365731476 - 317239240 redo from dual;
          REDO
      48492236
    1 row selected.The PL/SQL block used 304,284 bytes more redo, which is not much but still more than the SQL version.

  • SQL*LOADER/SQL usage in Migration

    I have very limited migration requirements. I DO NOT need to
    migrate a database. I DO need to change some SQL and BCP load
    scripts from SQL-SERVER 6.5 to their equivalents in ORACLE 8.0.5.
    For this limited purpose, should I proceed to handcode these, or
    would the workbench be of use to me?
    Thanks for your help.
    null

    The migration workbench does, as part of the migration,
    generate the BCP and SQL*Loader files required to migrate a
    database. However, since you already have the BCP files created
    then the Workbench would not actually be able to just generate
    the other side of the picture (the SQL*Loader files). I can
    suggest the following to you :
    1. Perhaps use the Workbench to run a tiny migration that would
    show you how we generate the SQL*Loader scripts. It is fairly
    straight forward however we need to do some manipulation on
    dates.
    2. There is a chapter on SQL*Loader as part of the Oracle8i
    documentation set.
    Chapter 3 "SQL*Loader Concepts"
    Oracle8i Utilities, Release 8.1.5
    A67792-01
    Regards,
    Marie
    Raja Marla (guest) wrote:
    : I have very limited migration requirements. I DO NOT need to
    : migrate a database. I DO need to change some SQL and BCP
    load
    : scripts from SQL-SERVER 6.5 to their equivalents in ORACLE
    8.0.5.
    : For this limited purpose, should I proceed to handcode these,
    or
    : would the workbench be of use to me?
    : Thanks for your help.
    Oracle Technology Network
    http://technet.oracle.com
    null

Maybe you are looking for