Manipulating VARRAYS

Can anyone send me an example of varray manipulation (reading and writing) using C/OCI ?
I'm a beginner.
Thank's in advance.

Here is a sample routine :-
static CONST text CONST_W_PTR selar = (text )
"SELECT * from customer_va";
** execute "selar" statement which select an array column from a table.
void selectar(envhp, svchp, stmthp, stmthp1, errhp, recurse)
OCIEnv *envhp;
OCISvcCtx *svchp;
OCIStmt *stmthp;
OCIStmt *stmthp1;
OCIError *errhp;
boolean recurse;
OCIType *names_ar_tdo;
OCIDefine defn1p, defn2p;
OCIColl names_ar = (OCIColl ) 0;
sword custno =0;
sword status;
dvoid *elem;
sb4 index;
OCIString OCIInd names_null = (OCIInd ) 0;
boolean exist, eoc, boc;
OCIIter itr = (OCIIter ) 0;
OCIBind bnd1p, bnd2p;
int amount;
OCIInd ind = -1;
OCIInd *indp = &ind;
sb4 collsiz;
DISCARD printf("\n******** Entering selectar *********\n");
/* define the application request */
checkerr(errhp, OCIStmtPrepare(stmthp, errhp, (text *) selar,
(ub4) strlen((const char *) selar),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
*names;
/* bind the input variable */
checkerr(errhp, OCIDefineByPos(stmthp, &defn1p, errhp, (ub4) 1, (dvoid *) &custno,
(sb4) sizeof(sword), SQLT_INT, (dvoid *) 0, (ub2 *)0,
(ub2 *)0, (ub4) OCI_DEFAULT));
checkerr(errhp, OCIDefineByPos(stmthp, &defn2p, errhp, (ub4) 2, (dvoid *) 0,
(sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0,
(ub2 *)0, (ub4) OCI_DEFAULT));
checkerr(errhp, OCITypeByName(envhp, errhp, svchp, (const text *) "",
(ub4) strlen((const char *) ""),
(const text *) "CHAR_TAB",
(ub4) strlen((const char *) "CHAR_TAB"),
(CONST text *) 0, (ub4) 0,
OCI_DURATION_SESSION, OCI_TYPEGET_HEADER,
&names_ar_tdo));
checkerr(errhp, OCIDefineObject(defn2p, errhp, names_ar_tdo, (dvoid **) &names_ar,
(ub4 *) 0, (dvoid **) &indp, (ub4 *) 0));
checkerr(errhp, OCIStmtExecute(svchp, stmthp, errhp, (ub4) 0, (ub4) 0,
(OCISnapshot *) NULL, (OCISnapshot *) NULL,
(ub4) OCI_DEFAULT));
/* execute and fetch */
DISCARD printf(" Execute and fetch.\n");
while ((status = OCIStmtFetch(stmthp, errhp, (ub4) 1, (ub4) OCI_FETCH_NEXT,
(ub4) OCI_DEFAULT)) == OCI_SUCCESS | |
status == OCI_SUCCESS_WITH_INFO)
/* print the customer number */
DISCARD printf("\nThe customer number is : %d.\n", custno);
if (*indp == -1)
DISCARD printf("The varray is NULL.\n\n");
continue;
/* check how many elements in the typed table */
checkerr(errhp, OCICollSize(envhp, errhp, (CONST OCIColl *) names_ar,
&collsiz));
DISCARD printf("---> There are %d elements in the varray.\n", collsiz);
DISCARD printf("\n---> Dump the array from the top to the bottom.\n");
checkerr(errhp, OCIIterCreate(envhp, errhp, names_ar, &itr));
for(eoc = FALSE;!OCIIterNext(envhp, errhp, itr, (dvoid **) &elem,
(dvoid **) &names_null, &eoc) && !eoc;)
names = *(OCIString **) elem;
DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
DISCARD printf(" atomic null indicator is %d\n", *names_null);
DISCARD printf("\n---> Dump the array from the bottom to the top.\n");
checkerr(errhp, OCIIterGetCurrent(envhp, errhp, itr, (dvoid **) &elem,
(dvoid **) &names_null));
names = *(OCIString **) elem;
DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
DISCARD printf(" atomic null indicator is %d\n", *names_null);
for(boc = FALSE;!OCIIterPrev(envhp, errhp, itr, (dvoid **) &elem,
(dvoid **) &names_null, &boc) && !boc;)
names = *(OCIString **) elem;
DISCARD printf(" The names is %s\n", OCIStringPtr(envhp, names));
DISCARD printf(" atomic null indicator is %d\n", *names_null);
checkerr(errhp, OCIIterDelete(envhp, errhp, &itr));
/* insert into the same table, then dump the info again */
if (recurse)
custno = custno * 10;
checkerr(errhp, OCIStmtPrepare(stmthp1, errhp, (text *) insar,
(ub4) strlen((const char *) insar),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
/* bind the input variable */
checkerr(errhp, OCIBindByName(stmthp1, &bnd1p, errhp, (text *) ":custno",
(sb4) -1, (dvoid *) &custn o,
(sb4) sizeof(sword), SQLT_INT,
(dvoid *) 0, (ub2 *)0, (ub2 *)0, (ub4) 0, (ub4 *) 0,
(ub4) OCI_DEFAULT));
checkerr(errhp, OCIBindByName(stmthp1, &bnd2p, errhp, (text *) ":names",
(sb4) -1, (dvoid *) 0,
(sb4) 0, SQLT_NTY, (dvoid *) 0, (ub2 *)0, (ub2 *)0,
(ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT));
/* if custno == 20, then insert null nested table */
*indp = -1;
checkerr(errhp, OCIBindObject(bnd2p, errhp, names_ar_tdo,
(dvoid **) &names_ar,
(ub4 *) 0, (custno == 20) ? (dvoid **) &indp :
(dvoid **) 0, (ub4 *) 0));
checkerr(errhp, OCIStmtExecute(svchp, stmthp1, errhp, (ub4) 1,
(ub4) 0, (OCISnapshot *) NULL,
(OCISnapshot *) NULL, (ub4) OCI_DEFAULT));
checkerr(errhp, OCITransCommit(svchp, errhp, (ub4) 0));
null

Similar Messages

  • I would like to know why my bill was manipulated to cause an overage fee.

    Halfway through my previous billing cycle, I reduced my data plan from 3GB shared between me and my girlfriend to 2GB shared, so they pro-rated the next bill, showing it to be around $30 cheaper than it would otherwise be. Fast forward to today, I go to check my bill and see that I've incurred a $15 usage fee. However, when I go look at the Usage breakdown, I see the following:
    It clearly shows that the billing cycle started on May 20th, and that I made the change to go down to 2GB on the 30th. They decided to set my usage allowance for that period to 1.06400GB even though I'd already used 1.37900GB, leaving a .31800GB overage. Now, of course it shows that from May 31st through June 19th, I was allowed 1.29000GB and used 1.21100GB, clearly showing that even if it were split properly, I'd still be over.....except for the fact that I have text alerts set to notify me when I'm at 50%, 75%, and 90% usage so I can decide when to stop and avoid an overage fee.
    They seemingly, intentionally, manipulated the numbers in such a way as to get $15 more out of me that they otherwise wouldn't get because they knew I'd stop using data before an overage occurred.
    I am fully aware that $15 isn't a big deal. However, the fact that they apparently manipulated the numbers in such a way as to force an overage fee upon me is just plain wrong and it makes me very angry. The best part about this is that when you add up the 1.06400GB allowance of the first portion and the 1.29000GB of the second portion, that only totals 2.354GB, not the 3GB that the plan originally was. I had chosen to have the changes apply at the beginning of the next billing cycle, so there is no reason for me to have been shorted the 0.646GB of data, much less to have incurred an overage fee.
    Is this sort of thing common? Is it a glitch in the system, or was someone manually making these changes with malicious intent? More importantly, can or will they do anything to fix this?Verizon Wireless Customer Support

    See, the problem is you're both ignoring two facts.
    #1 - of the two options when changing the plan, I chose to have the changes not apply until the beginning of the next billing cycle. There never should have been the possibility of an overage as there should have been no prorating when I chose to have no changes until next billing cycle. The plan I was on was a 3GB plan, I had only used a total of 2.59GB. Again, that's aside from the fact that there shouldn't have been a prorating to begin with as I chose to have the new plan not apply until the next billing cycle.
    #2 - The total allowance between the two pieces of prorated data allowances is only 2.354GB, not the 3GB of the plan I was currently on. Yet again, I don't know how many more times I have to say this for it to be understood, I chose to have the changes not apply until the next billing cycle. This means that the plan should have never been split to begin with, let alone shorted 0.646GB of usage allowance.
    I'm sorry if I'm being short with you, but this is a clear-cut case of an error in the process and I do not appreciate being told I am mistaken when you haven't even bothered to pay attention to all the details and check the math for yourself.

  • User is getting Error while opening a Discoverer report::Model Manipulation

    Hi,
    I am stuck with a peculaiar error as reported:
    While opening a Discoverer Report its giving Error:
    Model manipulation via state object.Server writes and pass through reads can only be made on objects attached to the model
    instance of
    oracle.disco.model.corbaserver.ScheduleRunWorkbookInfoImpl made state from:removed from
    oracle.disco.model.corbaserver.schedule.ScheduleRunWorkbookInfoImpl
    Kindly any help will be benefitial for me.
    Thanks and Regards

    Pl post details of OS, database and Discoverer versions. Pl detail the steps to replicate this error. This MOS Doc may be helpful
    734850.1- Error "Failed to Find Workbook ParameterValue.." When Trying to Edit Scheduled Discoverer Workbooks
    HTH
    Srini

  • Image Processing Cells Manipulation

    Hi Guys,
    I am working on cells manipulation. Due to the nature of image processing which scans from a top-down-left to right approach, i am unable to fix a index number on the specific cell which I required this information in order to manipulate the cells as my command. The image processing will be running throughout the programme. As attached is the picture of the Imaq count objects i am using. 
    On a side note, just want to ask a biology-related experiment if anyone encounter the same issue before, why is a cell easily stuck onto the surface as this action prevents the cells from being trapped once it get stuck on the surface of the cover slip. 
    Thank you in advance,
    Scott
    Attachments:
    Image Processing.png ‏227 KB

    Hello,
    yes I understand your problem. But it seems to me that the scan direction has no effect on this... What if the scan direction was from bottom-up, left-to right and the cell flows in from the left bottom corner? You would have the same problem...
    Or do new cells flow into FOV of the camera only from top-left corner? Could you count the number of objects and linearly increment the indexes of your cells? For example, the first cell that comes into the FOV of the camera has index 0, and when the next cell is introduced, the first cell will have an incremented index that equals 1. And so on...
    But if the new cells come into the FOV of the camera randomly from left, right, bottom, top, etc... it would be more difficult. What you could do is calculate some parameters (check particle measurements in NI Vision Concepts)  for the cell you want to manipulate (at the time when you are sure this is the correct cell) and then compare these parameters with the cells on every subsequent frame. You can build a feature vector of these parameters and use classification tools. When you classify the cell, then you would have no problems manipulating it.
    If your cell changes shape dynamically, then I do not see a way to do this.
    Best regards,
    K
    https://decibel.ni.com/content/blogs/kl3m3n
    "Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."

  • Need Date manipulation in BI Publisher report template

    Hi All,
    I need date manipulation in BI Publisher report template for e.g sysdate+4 this means i need 4 days after todays sysdate.
    That menas if today date(sysdate) is 09/01/2008 then i need (sysdate+4) i.e 13/01/2008.
    Please help me.
    Thanks
    Edited by: user562690 on Jan 9, 2009 3:21 PM

    Hi M14,
    I have doubt on similar type.I have AgreementStartDate as
    <AgreementStartDate>12/03/2008 07:24:10</AgreementStartDate> in XML format.
    I am not able to apply same formula for thsi date format in similar manipulation.
    Please help me.
    TIA
    skr

  • Bug:4705928 PLSQL: Memory leak using small varrays

    We have Oracle version 10.2.0.1.0
    We have a problem with a procedure.
    In our scenario we make use of VARRAY in the procedure to pass some filter parameters to a select distinct querying a view made on three tables.
    Unfotunately not always execution it is successful.
    Sometimes it returns wrong value (0 for the count parameter), sometimes (rarely) the server stops working.
    We suspect that this is caused by a bug fixed in versione 10.2.0.3.0
    Bug:4705928 PLSQL: Memory leak using small varrays when trimming the whole collection and inserting into it in a loop
    We suspect this becasue we made two procedure the first (spProductCount) uses a function (fnProductFilter) to calculate the values of a varray and passes them into the select,
    while in the second procedure (spProductCount2) parameters are passed directly into the statement without varray
    and there are failures only in the first procedure.
    On the other hand on another server 10.2.0.1.0 we never have this problem.
    The instance manifesting the bug runs under shared mode, while the other is under dedicated mode.
    Turning the first one to dedicated mode makes the bugs disapear.
    Unfortunately this is not a solution.
    In the sample there are the three table with all constraints, the view, tha varray custom type, the function and the two procedures.
    Is there someone that may examine our sample and tell us if the pl/sql code corresponds to the bug desciption.
    We also want to know if it's possibile that the same server running under different mode (SHARED/DEDICATED) doesn't behave the same way.
    The tables:
    --Products
    CREATE TABLE "Products" (
         "Image" BLOB
         , "CatalogId" RAW(16)
         , "ProductId" RAW(16)
         , "MnemonicId" NVARCHAR2(50) DEFAULT ''
         , "ProductParentId" RAW(16)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M04" CHECK ("CatalogId" IS NOT NULL)
    ALTER TABLE "Products"
         ADD CONSTRAINT "NN_Products_M05" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "Products"
    ADD CONSTRAINT "PK_Products"
    PRIMARY KEY ("ProductId")
    CREATE INDEX "IX_Products"
    ON "Products" ("CatalogId", "MnemonicId")
    CREATE UNIQUE INDEX "UK_Products"
    ON "Products" (DECODE("MnemonicId", NULL, NULL, RAWTOHEX("CatalogId") || "MnemonicId"))
    --Languages
    CREATE TABLE "Languages" (
         "Description" NVARCHAR2(250)
         , "IsStandard" NUMBER(1)
         , "LanguageId" RAW(16)
         , "MnemonicId" NVARCHAR2(12)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "Languages"
         ADD CONSTRAINT "NN_Languages_M05" CHECK ("MnemonicId" IS NOT NULL)
    ALTER TABLE "Languages"
    ADD CONSTRAINT "PK_Languages"
    PRIMARY KEY ("LanguageId")
    ALTER TABLE "Languages"
    ADD CONSTRAINT "UK_Languages"
    UNIQUE ("MnemonicId")
    --ProductDesc
    CREATE TABLE "ProductDesc" (
         "Comment" NCLOB
         , "PlainComment" NCLOB
         , "Description" NVARCHAR2(250)
         , "DescriptionText" NCLOB
         , "PlainDescriptionText" NCLOB
         , "LanguageId" NVARCHAR2(12)
         , "ProductId" RAW(16)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM01" CHECK ("LanguageId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
         ADD CONSTRAINT "NN_ProductDescM02" CHECK ("ProductId" IS NOT NULL)
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "PK_ProductDesc"
    PRIMARY KEY ("ProductId", "LanguageId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc1"
    FOREIGN KEY("ProductId") REFERENCES "Products" ("ProductId")
    ALTER TABLE "ProductDesc"
    ADD CONSTRAINT "FK_ProductDesc2"
    FOREIGN KEY("LanguageId") REFERENCES "Languages" ("MnemonicId")
    /The view:
    --ProductView
    CREATE OR REPLACE VIEW "vwProducts"
    AS
         SELECT
               "Products"."CatalogId"
              , "ProductDesc"."Comment"
              , "ProductDesc"."PlainComment"
              , "ProductDesc"."Description"
              , "ProductDesc"."DescriptionText"
              , "ProductDesc"."PlainDescriptionText"
              , "Products"."Image"
              , "Languages"."MnemonicId" "LanguageId"
              , "Products"."MnemonicId"
              , "Products"."ProductId"
              , "Products"."ProductParentId"
              , TRIM(NVL("ProductDesc"."Description" || ' ', '') || NVL("ParentDescriptions"."Description", '')) "FullDescription"
         FROM "Products"
         CROSS JOIN "Languages"
         LEFT OUTER JOIN "ProductDesc"
         ON "Products"."ProductId" = "ProductDesc"."ProductId"
         AND "ProductDesc"."LanguageId" = "Languages"."MnemonicId"
         LEFT OUTER JOIN "ProductDesc" "ParentDescriptions"
         ON "Products"."ProductParentId" = "ParentDescriptions"."ProductId"
         AND ("ParentDescriptions"."LanguageId" = "Languages"."MnemonicId")
    /The varray:
    --CustomType VARRAY
    CREATE OR REPLACE TYPE Varray_Params IS VARRAY(100) OF NVARCHAR2(1000);
    /The function:
    --FilterFunction
    CREATE OR REPLACE FUNCTION "fnProductFilter" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId                    NVARCHAR2 := N'it-IT',
         parFilterValues                    OUT Varray_Params
    RETURN INTEGER
    AS
         varSqlCondition                    VARCHAR2(32000);
         varSqlConditionValues          NVARCHAR2(32000);
         varSql                              NVARCHAR2(32000);
         varDbmsCursor                    INTEGER;
         varDbmsResult                    INTEGER;
         varSeparator                    VARCHAR2(2);
         varFilterValue                    NVARCHAR2(1000);
         varCount                         INTEGER;
    BEGIN
         varSqlCondition := '(T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId )';
         varSqlConditionValues := CHR(39) || TO_CHAR(parCatalogId) || CHR(39) || N', ' || CHR(39 USING NCHAR_CS) || parLanguageId || CHR(39 USING NCHAR_CS);
         parFilterValues := Varray_Params();
         varSql := N'SELECT FilterValues.column_value FilterValue FROM TABLE(Varray_Params(' || varSqlConditionValues || N')) FilterValues';
         BEGIN
              varDbmsCursor := dbms_sql.open_cursor;
              dbms_sql.parse(varDbmsCursor, varSql, dbms_sql.native);
              dbms_sql.define_column(varDbmsCursor, 1, varFilterValue, 1000);
              varDbmsResult := dbms_sql.execute(varDbmsCursor);
              varCount := 0;
              LOOP
                   IF (dbms_sql.fetch_rows(varDbmsCursor) > 0) THEN
                        varCount := varCount + 1;
                        dbms_sql.column_value(varDbmsCursor, 1, varFilterValue);
                        parFilterValues.extend(1);
                        parFilterValues(varCount) := varFilterValue;
                   ELSE
                        -- No more rows to copy
                        EXIT;
                   END IF;
              END LOOP;
              dbms_sql.close_cursor(varDbmsCursor);
         EXCEPTION WHEN OTHERS THEN
              dbms_sql.close_cursor(varDbmsCursor);
              RETURN 0;
         END;
         FOR i in parFilterValues.first .. parFilterValues.last LOOP
              varSeparator := ', ';
         END LOOP;
         RETURN 1;
    END;
    /The procedures:
    --Procedure presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varResult := "fnProductFilter"(parCatalogId, parLanguageId, varFilterValues);
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, varFilterValues(1), varFilterValues(2);
    END;
    --Procedure NOT presenting anomaly\bug
    CREATE OR REPLACE PROCEDURE "spProductCount2" (
         parCatalogId "Products"."CatalogId"%TYPE,
         parLanguageId NVARCHAR2 := N'it-IT',
         parRecords OUT NUMBER
    AS
         varFilterValues Varray_Params;
         varResult INTEGER;
         varSqlTotal VARCHAR2(32000);
    BEGIN
         parRecords := 0;
         varSqlTotal := 'BEGIN
         SELECT count(DISTINCT T_Product."ProductId") INTO :parCount FROM "vwProducts" T_Product
              WHERE ((T_Product."CatalogId" = HEXTORAW(:parentId)) AND (T_Product."LanguageId" = :languageId ));
    END;';
         EXECUTE IMMEDIATE varSqlTotal USING OUT parRecords, parCatalogId, parLanguageId;
    END;Edited by: 835125 on 2011-2-9 1:31

    835125 wrote:
    Using VARRAY was the only way I found to transform comma seprated text values (e.g. "'abc', 'def', '123'") in a collection of strings.A varray is just a functionally crippled version of a nested table collection type, with a defined limit you probably don't need. (Why 100 specifically?) Instead of
    CREATE OR REPLACE TYPE varray_params AS VARRAY(100) OF NVARCHAR2(1000);try
    CREATE OR REPLACE TYPE array_params AS TABLE OF NVARCHAR2(1000);I don't know whether that will solve the problem but at least it'll be a slightly more useful type.
    What makes you think it's a memory leak specifically? Do you observe session PGA memory use going up more than it should?
    btw good luck with all those quoted column names. I wouldn't like to have to work with those, although they do make the forum more colourful.
    Edited by: William Robertson on Feb 11, 2011 7:54 AM

  • How to find out which plugin is missing ( embed width="100%" height="100%" messagecallback="parent.frames.MANIPULATIONS.AppendMessage" spinfps="15" spiny="30")?

    How to find out which plugin is missing fro mthe website: http://web.it.nctu.edu.tw/~twli/interactive/scr_tutf.htm?
    After looking at one similar question found in mozilla support and answered by jscher2000 (https://support.mozilla.org/en-US/questions/957655), I have found out I have to look for either &lt;object or &lt;embed. What I found is : &lt;embed width="100%" height="100%" messagecallback="parent.frames.MANIPULATIONS.AppendMessage" spinfps="15" spiny="30"
    What do I have to do now?

    This big1.mol (and possibly big2.mol) file is loaded in the embed plugin object that is opened in a iframe, so you can right-click the plugin area to check the embed code.
    *http://web.it.nctu.edu.tw/%7Etwli/interactive/big1.mol
    *http://web.it.nctu.edu.tw/%7Etwli/interactive/big2.mol

  • Creating and displaying Varrays in Apex 4.1

    Hi,
    I am creating quite a sophisticated database, which has to support relations between different tables. In order to implement that, I've decided to use user-defined datatype - a varray which consists of 100 integers (and only of that) that will contain ID's to different rows in different tables. Since it is a user-defined datatype I have problems with using it in Application Express :)
    First question: Is there any way to make this simple datatype 'readable' for Apex? In each application I create it shows that it is 'an unsupported datatype'. Maybe I should define something more than just varray construction - the way Apex should read and edit it etc ?
    Second question: How can I implement a function that will read the IDs in the varray and transform them into names to which that IDs correspond? I would like an application to show full name of an organization (ex. "ABC Corporation") instead of its ID. I tried to put some part of code that takes up the name of an organisation in a row with given ID into +"Source"+ form in the +"Edit page item"+, however Apex doesn't seem to get the fact that the data is in different table. Any ideas? :)
    I will be grateful for any help since it is an urgent case :]

    KamilGorski wrote:
    I would happily do that if only I had more time to study SQL and learn it properly :) Unfortunately, our start-up company has no time and money at the moment to allow me to do so.Then isn't using technologies that no one knows rather a strange decision?
    But coming back to your solution - it still works only if user inputs only one product quality. Let's say that user has chosen 3 qualities and the 'SELECTED_QUALITIES' collection looks like that:
    n001 = 1,
    n002 = 3,
    n003 = 5
    And since the SELECT query you have created compares pq.quality_id only to n001, it returns all the products that have the quality no 1 - not all the products that have all three selected qualities - 1, 3 and 5. Of course, we can change the 'EXISTS' condition and add more 'OR' conditions like that:
    where pq.quality_id = q.n001
    or pq.quality_id = q.n002
    or pq.quality_id = q.n003But it has few flaws - first we assume that we know the number of qualities user has selected - 3 (and we don't know that), You've misunderstood. SQL is row based. To handle multiple values, we create more rows, not additional columns. In your preferred terms, the result of any query is an <i>m</i>&times;<i>n</i> array of columns and rows, where the number of columns <i>m</i> is fixed, and the number of rows <i>n</i> varies according to the query predicates.
    It is not necessary to know the number of selected qualities, simply create a row in the collection for each selected quality to give a set of selected qualities.
    The SELECTED_QUALITIES collection should look like:
    N001
       1
       3
       5
    secondly the query will return all the products that have one of the three selected qualities (and we want products that have all three qualities). That wasn't really clear from the information previously given, but it's certainly possible. With <tt>product_qualities(product_id, quality_id)</tt> as a primary/unique key, and with no duplicates in the selected qualities, a solution is the set of all products with the selected qualities, where the number of qualities matched for each product equals the number of qualities selected, as in this example:
    SQL> create table products (
      2      product_id    integer       primary key
      3    , product_name  varchar2(30)  not null);
    Table created.
    SQL> create table qualities (
      2      quality_id    integer       primary key
      3    , quality_name  varchar2(30)  not null);
    Table created.
    SQL> create table product_qualities (
      2        product_id  integer   not null references products
      3      , quality_id  integer   not null references qualities,
      4      constraint product_qualities_pk primary key (
      5            product_id
      6          , quality_id))
      7    organization index;
    Table created.
    SQL> create index product_qualities_ix2 on product_qualities (
      2      quality_id
      3    , product_id);
    Index created.
    SQL> insert all
      2    into products (product_id, product_name) values (1, 'widget')
      3    into products (product_id, product_name) values (2, 'thingummy')
      4    into products (product_id, product_name) values (3, 'whatsit')
      5    into products (product_id, product_name) values (4, 'gizmo')
      6    into products (product_id, product_name) values (5, 'gadget')
      7    into products (product_id, product_name) values (6, 'contraption')
      8  select * from dual;
    6 rows created.
    SQL> insert all
      2    into qualities (quality_id, quality_name) values (1, 'green')
      3    into qualities (quality_id, quality_name) values (2, 'silver')
      4    into qualities (quality_id, quality_name) values (3, 'shiny')
      5    into qualities (quality_id, quality_name) values (4, 'furry')
      6    into qualities (quality_id, quality_name) values (5, 'digital')
      7    into qualities (quality_id, quality_name) values (6, 'hd')
      8    into qualities (quality_id, quality_name) values (7, 'wireless')
      9  select * from dual;
    7 rows created.
    SQL> insert all
      2    into product_qualities (product_id, quality_id) values (1, 1)
      3    into product_qualities (product_id, quality_id) values (1, 3)
      4    into product_qualities (product_id, quality_id) values (2, 2)
      5    into product_qualities (product_id, quality_id) values (2, 4)
      6    into product_qualities (product_id, quality_id) values (3, 1)
      7    into product_qualities (product_id, quality_id) values (3, 3)
      8    into product_qualities (product_id, quality_id) values (3, 5)
      9    into product_qualities (product_id, quality_id) values (4, 2)
    10    into product_qualities (product_id, quality_id) values (4, 4)
    11    into product_qualities (product_id, quality_id) values (4, 6)
    12    into product_qualities (product_id, quality_id) values (5, 2)
    13    into product_qualities (product_id, quality_id) values (5, 3)
    14    into product_qualities (product_id, quality_id) values (5, 5)
    15    into product_qualities (product_id, quality_id) values (6, 1)
    16    into product_qualities (product_id, quality_id) values (6, 3)
    17    into product_qualities (product_id, quality_id) values (6, 5)
    18    into product_qualities (product_id, quality_id) values (6, 7)
    19  select * from dual;
    17 rows created.
    SQL> commit;
    Commit complete.For the purposes of creating a quick and simple example outside of APEX, I'm using a temporary table instead of the SELECTED_QUALITIES APEX collection. For various reasons collections work better in APEX than GTTs and are the preferred approach for temporary storage.
    SQL> create global temporary table selected_qualities (
      2    n001 integer)
      3  on commit delete rows;
    Table created.With one quality selected, we get all the products having that quality:
    SQL> insert into selected_qualities (n001) values (1);
    1 row created.
    SQL> insert into selected_qualities (n001) values (1);
    1 row created.
    SQL> select
      2            p.product_id
      3          , p.product_name
      4  from
      5            products p
      6           join product_qualities pq
      7             on p.product_id = pq.product_id
      8           join selected_qualities sq
      9             on pq.quality_id = sq.n001
    10  group by
    11            p.product_id
    12          , p.product_name
    13  having
    14             count(*) = (select count(*) from selected_qualities);
    PRODUCT_ID PRODUCT_NAME
          1 widget
          6 contraption
          3 whatsitThese products all have the next quality added, so continue to be returned:
    SQL> insert into selected_qualities (n001) values (3);
    1 row created.
    SQL> select
      2            p.product_id
      3          , p.product_name
      4  from
      5            products p
      6           join product_qualities pq
      7             on p.product_id = pq.product_id
      8           join selected_qualities sq
      9             on pq.quality_id = sq.n001
    10  group by
    11            p.product_id
    12          , p.product_name
    13  having
    14             count(*) = (select count(*) from selected_qualities);
    PRODUCT_ID PRODUCT_NAME
          1 widget
          6 contraption
          3 whatsitThen as additional qualities are selected, the result set is progressively reduced:
    SQL> insert into selected_qualities (n001) values (5);
    1 row created.
    SQL> select
      2            p.product_id
      3          , p.product_name
      4  from
      5            products p
      6           join product_qualities pq
      7             on p.product_id = pq.product_id
      8           join selected_qualities sq
      9             on pq.quality_id = sq.n001
    10  group by
    11            p.product_id
    12          , p.product_name
    13  having
    14             count(*) = (select count(*) from selected_qualities);
    PRODUCT_ID PRODUCT_NAME
          6 contraption
          3 whatsit
    SQL> insert into selected_qualities (n001) values (7);
    1 row created.
    SQL> select
      2            p.product_id
      3          , p.product_name
      4  from
      5            products p
      6           join product_qualities pq
      7             on p.product_id = pq.product_id
      8           join selected_qualities sq
      9             on pq.quality_id = sq.n001
    10  group by
    11            p.product_id
    12          , p.product_name
    13  having
    14             count(*) = (select count(*) from selected_qualities);
    PRODUCT_ID PRODUCT_NAME
          6 contraption

  • How do I know that a PDF files was manipulated?

    Is it possible to find out if a PDF files was manipulated? Such as if was added o deletede and so on?
    Thanks.
    Miguel

    Identifying fraudulent "phishing" email
    Report it to Apple: report phishing.mailtoloc

  • How to retrieve data from a table that match values in a varray?

    Using - Oracle 10g Release 1.2
    How to do write a sql to retrieve data matching values in a varray?
    I have the following:
    declare
        v_ct          NATURAL := 0;
        type t_cur is  REF CURSOR;
        v_cursor t_cur;
        TYPE t_array IS VARRAY(100) OF NUMBER;
        l_codes t_array := t_array();
    begin
        select count(*)
          into v_ct
          from table1
         where ind_cd IS NULL;
        IF v_ct = 0 THEN
            l_codes(1) := 1;
        END IF;
        select count(*)
          into v_ct
          from table2
         where cd IS NULL;
        IF v_ct = 0 THEN
            l_codes(2) := 2;
        END IF;  
       OPEN v_cursor for
          select * from error_table where error_cd in (SELECT * FROM TABLE(CAST(l_codes AS t_array)) );
    end;

    This may not answer your question, but what about a pure SQL solution?
    NOTE THIS IS UNTESTED:
    SELECT *
    FROM     ERROR_TABLE
    WHERE     ERROR_CD IN
              SELECT      1
              FROM      table1
              HAVING      COUNT(*) > 0
              UNION ALL
              SELECT      2
              FROM      table2
              HAVING      COUNT(*) > 0     
         )HTH!

  • What is the actual size of an (empty) varray in a record?

    what is the actual size occupied by an (empty) varray in a record?
    For example, if I create my table defined as:
    create or replace type XXX as object (
    myRefs VARRAY(10) of REF(yyy)
    create table YYY as XXX;
    what is the actual size of the record of type XXX when 'myRefs' is empty? For some reason, select data_length from all_tab_cols where table_name = YYY seems always to return 3K as the length of column myrefs.... is that correct? If not, what is the correct size?

    A tad late here...
    Storage sizes of REF attributes are described here:
    [Design Considerations for REFs - Storage Size of REFs|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11822/adobjdes.htm#i452226]
    The size of your REF attribute (or element, in your case) will depend on whether it is primary key-based or system-generated, whether it is scoped or not, and whether it carries with it a rowid hint. The overall size of your VARRAY attribute as it grows will also depend on whether you allow null REF values or not, but essentially will be the size of your REF multiplied times the number of elements in your VARRAY (plus a small, constant amount of storage for internal housekeeping, both for the attribute and for each element).
    You could try the VSIZE function as an appromixation...
    [Oracle® Database SQL Language Reference - VSIZE|http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions233.htm#SQLRF06162]
    Hope it helps...
    Gerard

  • String Manipulation in BI Publisher Report Paramater

    Hi,
    My Problem is that I am not able to do string manipulation on BI Publisher report Prameters.
    Actually I want to Show Deptno-Dname in Menu(LOV).and when I select Certain combination like '10-Accounting',and while passing the parameter:Dept I wanted to Cut the department no(10) using string manipulation functions provided by oracle in Data Model(Query) in where clause like (where deptno=to_number(substr(:Dept,1,2)).
    This query is working fine in other application like TOAD,But not giving results in BI Publisher Report.
    It's also not giving any error while saving or running the report.
    Please suggest any solution.

    even I tried the following query in data model..
    select DISTINCT EMP.EMPNO as EMPNO,
    EMP.ENAME as ENAME,
    EMP.JOB as JOB,
    DEPT.LOC as LOC
    from SCOTT.DEPT DEPT,
    SCOTT.EMP EMP
    where emp.DEPTNO=DEPT.deptno
    and DEPT.deptno=nvl(to_number(substr(:department,1,2)),DEPT.deptno)
    But the Parameter which I want to pass say Department('10-Accounting'),
    Still it is showing employees from all departments.

  • Calling a stored procedure with VARRAY as out parameter using JDBC

    Hi,
    I want to use the data type VARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    I'm using Oracle 8.1.5 for Windows NT.
    Please help me.
    Thanks
    Sumanta
    null

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Manipulating  XML file using flex 2.0

    Hi,
    how to add contents in to xml file using flex 2.0, ie i
    actually wants to write data in to a xml file, so that data to be
    appended at the end of the file.
    Kumar

    You can't! Well, at least Flex cannot do this. All Flex can
    do is send this data -- any data -- to the server and it's up to
    you how you want to append this data to a file on the server.
    You see, flex can't write to local files. If you looking for
    client side file manipulation, take a look at Flex's desktop
    brother call AIR!
    ATTA

  • Urgent Help needed in Objects & VARRAY

    Hi all,
    This is my first time doing query involving varray and objects. I have create tables, varray and object with below scenario :-
    CREATE TABLE Analogue
    (UniqueName varchar2(20) not null,
    DefaultRole T_ROLE,
    AlarmRoles T_ROLEARRAY);
    CREATE TYPE T_ROLE REPLACED AS OBJECT
    (ROLE varchar2(20));
    CREATE TYPE T_ROLEARRAY AS VARRAY(100) OF T_ROLE;
    Ok, my questions was :-
    1) How to do insertion into T_ROLEARRAY ? And, after a record added into T_ROLEARRAY, how to
    do SELECT to view the inserted record ?
    2) Does the insertion somehow insert values into T_ROLE as well if we insert record into
    T_ROLEARRAY since T_ROLEARRAY is a varray to T_ROLE?
    3) How to do Update and Delete from both DefaultRole and AlarmRoles in Analogue table ?
    Please consult if anyone of you had came across the above case.
    Thank you.
    Sharon.

    Sharon,
    You can check out some examples online,
    1. Querying collections: http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96594/adobjbas.htm#458840
    2. DMLs with collections:
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96594/adobjbas.htm#463813.
    Regards,
    Geoff
    Hi all,
    This is my first time doing query involving varray and objects. I have create tables, varray and object with below scenario :-
    CREATE TABLE Analogue
    (UniqueName varchar2(20) not null,
    DefaultRole T_ROLE,
    AlarmRoles T_ROLEARRAY);
    CREATE TYPE T_ROLE REPLACED AS OBJECT
    (ROLE varchar2(20));
    CREATE TYPE T_ROLEARRAY AS VARRAY(100) OF T_ROLE;
    Ok, my questions was :-
    1) How to do insertion into T_ROLEARRAY ? And, after a record added into T_ROLEARRAY, how to
    do SELECT to view the inserted record ?
    2) Does the insertion somehow insert values into T_ROLE as well if we insert record into
    T_ROLEARRAY since T_ROLEARRAY is a varray to T_ROLE?
    3) How to do Update and Delete from both DefaultRole and AlarmRoles in Analogue table ?
    Please consult if anyone of you had came across the above case.
    Thank you.
    Sharon.

Maybe you are looking for

  • Go through this image to gif converter

    Hello! public class ImageToGifConverter {      public static void main(String args[]) {           try{                System.out.println("starting");                String file="E:/downloads/animgif/toanimate/4.jpg";                Frame f=new Frame(

  • HT5361 Trying to set up a Crazy Domains hosted email address in Mail is proving impossible. Anyone got any idea of the correct settings?

    Help! Does anyone know how to set up a Crazy Domains email account in Mac Mail? I'm at the point of screaming with frustration. None of the settings are specific enough and the automatic setup app doesn't work. Any help would be greatly appreciated.

  • Daisy chaining

    I don't have the proper cable to connect my camera and computer, so I was hoping there was a way to daisy chain from camera to external hard drive to computer - but when I try to log and capture footage in FCP it doesn't find the camera. Is there som

  • I can't erase my new Crucial MX100 SSD...Won't let me reformat the partition.

    Hello All, I believe my old HD crashed so I bought a new Crucial MX100 SSD 256 GB to replace it. I haven't had any luck thus far. I went into Disk Utility and it shows the Crucial SSD in the side bar. I tried to erase/rename, however it won't complet

  • Itunes on a backupn hard drive problem

    OK here's my tale of woe. I ran out of room on my laptop and moved my itunes library to a backup hard drive. I was able to figure this out fine. In preferences/advanced its pointing properly to E:itunes music. I recently added 4 albums (not purchased