Getting result with single query

Hi,
I'm using db 10.2.0.1.0
I have a table emp_shift , with data like below
EmpCode           Shift     Effdate            Default
1                 SHFT1    02-jan-2012          N
1                 SHFT2    04-jan-2012          Y
1                 SHFT3    04-jan-2012          NSo if user inputs EmpCode and Effdate, based on that i've to take the latest record, with default = 'Y' (if any) else default 'N'
Suppose
Case 1 : Input Empcode:1 Date:10-jan-2012
Then i should get the below record
1                 SHFT2    04-jan-2012          YCase 2 : Input Empcode:1 Date:03-jan-2012
Then i should get the below record
1                 SHFT1    02-jan-2012          NI want this result with a single query, is this possible?
Thanks
Divya

Hi Thank you both,
I'm trying this process through forms. and my forms version is 6i.
There where i'm trying the query with the cursor, i'm getting error
Encountered the symbol Order when expecting one of the following
.()...and my cursor is
Cursor cur_shft(vemp Varchar2,vdate Varchar2) is Select ESM_SHIFT_TYPE
     from (Select ESM_SHIFT_TYPE from EMPLOYEE_SHIFT_MASTER
               Where ESM_EMP_CODE = vemp
               and ESM_EFF_DATE <= vdate
               Order by ESM_EFF_DATE desc,Esm_Default desc)
               Where rownum=1 ;Whats wrong?

Similar Messages

  • Getting Counts with single query

    HI,
    I need help in writing a query that gets account counts in a single query,
    CREATE TABLE ACCOUNTINFO(     
    ACCOUNTID VARCHAR2(20 BYTE) NOT NULL,
    ACCOUNTNO VARCHAR2(10 BYTE) NOT NULL,
    LAST_DEPOSIT_DATE DATE,
    BALANCE NUMBER(10,0));
    I have a table like above and I am trying to write a query that gets
    Count of accounts with deposits made in last 1 month,
    Count of accounts with deposits made in last 2 months
    Account Count with balance > 0,
    Also, I need to join this ACCOUNTINFO with ACCOUNTMAIN to get name etc details
    CREATE TABLE ACCOUNTINFO(     
    EMPID VARCHAR2(20 BYTE) NOT NULL,
    FNAME VARCHAR2(30 BYTE) NOT NULL,
    MNAME VARCHAR2(30 BYTE),
    LNAME VARCHAR2(30 BYTE) NOT NULL,
    DOB DATE,
    ACCOUNTID VARCHAR2(20 BYTE));
    Question, how to write a query since I getting too-many counts (I have only 3 in sample above, actual goes on like 3-6, 6-9 etc).

    SELECT SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-1) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_MONTH,
           SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-2) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_TWO_MONTHS,
           SUM  (CASE WHEN BALANCE>0 THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_BALANCE_GREATER_ZERO
      FROM ACCOUNTINFO

  • How to get this with Single query

    Friends
    I am sure using SQL analytical function, the following can be achieved using a single query:
    Date_value | Cust_id | Customer_tenue | avg_bal
    01-aug-09 | 111 | 0 | 1000
    01-aug-09 | 112 | 1 | 2000
    01-aug-09 | 113 | 2 | 900
    01-aug-09 | 114 | 3 | 1250
    01-sep-09 | 111 | 1 | 1200
    01-sep-09 | 112 | 2 | 2000
    01-sep-09 | 113 | 3 | 1900
    01-sep-09 | 114 | 4 | 1250
    01-oct-09 | 111 | 2 | 1100
    01-oct-09 | 112 | 3 | 2200
    01-oct-09 | 113 | 4 | 1900Expected result
    If customer’s tenure is 0 then mark as ‘New’,
    If customer’s balance is increased from last month then mark as ‘Augment’
    If customer’s balance is same as last month then mark as ‘Maintain’
    If customer’s balance is decreased from last month then mark as ‘Diminish’
    Else ‘Left’
    Help please....

    If customer’s tenure in last month is 0 then mark as ‘New’,There's not such case in test data... last month is October, isn't it?
    SQL> with t as (select DATE '2009-08-01' Date_value, 111 Cust_id, 0 Customer_tenue, 1000 avg_bal from dual union all
      2  select DATE '2009-08-01', 112 , 1 , 2000 from dual union all
      3  select DATE '2009-08-01', 113 , 2 , 900 from dual union all
      4  select DATE '2009-08-01', 114 , 3 , 1250 from dual union all
      5  select DATE '2009-09-01', 111 , 1 , 1200 from dual union all
      6  select DATE '2009-09-01', 112 , 2 , 2000 from dual union all
      7  select DATE '2009-09-01', 113 , 3 , 1900 from dual union all
      8  select DATE '2009-09-01', 114 , 4 , 1250 from dual union all
      9  select DATE '2009-10-01', 111 , 2 , 1100 from dual union all
    10  select DATE '2009-10-01', 112 , 3 , 2200 from dual union all
    11  select DATE '2009-10-01', 113 , 4 , 1900 from dual)
    12  select date_value, cust_id, avg_bal, oldbal, case when Customer_tenue=0 and nextbal is null then 'NEW'
    13                                                    when oldbal<avg_bal then 'Augment'
    14                                                    when oldbal=avg_bal then 'Maintain'
    15                                                    when oldbal>avg_bal then 'Diminish'
    16                                                    else 'Left' end status
    17    from (select date_value, cust_id, customer_tenue, avg_bal, LEAD(avg_bal) over (partition by cust_id order by date_value desc) oldbal,
    18                 LAG(avg_bal) over (partition by cust_id order by date_value desc) nextbal
    19            from t)
    20  order by cust_id, date_value;
    DATE_VALU    CUST_ID    AVG_BAL     OLDBAL STATUS
    01-AGO-09        111       1000            Left
    01-SET-09        111       1200       1000 Augment
    01-OTT-09        111       1100       1200 Diminish
    01-AGO-09        112       2000            Left
    01-SET-09        112       2000       2000 Maintain
    01-OTT-09        112       2200       2000 Augment
    01-AGO-09        113        900            Left
    01-SET-09        113       1900        900 Augment
    01-OTT-09        113       1900       1900 Maintain
    01-AGO-09        114       1250            Left
    01-SET-09        114       1250       1250 Maintain
    Selezionate 11 righe.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/]

  • How to get result without single cotes in ''Cast(Multiset( '' Result.

    select cast(multiset(select column_name
    from user_tab_columns
    where table_name = 'DAILY_PRODN_MIS'
    and column_name like '%STOCK%'
    order by column_name) as tab_type) result from dual;
    RESULT
    TAB_TYPE('BAGS_STOCK', 'BLUE_DUST_STOCK', 'CEMENT_STOCK', 'CEMENT_STOCK_33', 'CEMENT_STOCK_43', 'CEMENT_STOCK_53', 'CK_ADJ', 'COAL_IND_D_STOCK', 'COAL_IND_D_STOCK_ADJ', 'COAL_IND_E_STOCK', 'COAL_IND_E_STOCK_ADJ', 'COAL_IND_F_STOCK','OCK_ADJ', 'MTD_COAL_IMP_D_STOCK_ADJ', 'MTD_COAL_IMP_E_STOCK_ADJ', 'MTD_COAL_IND_A_STOCK_ADJ', 'MTD_COAL_IND_B_STOCK_', 'YTD_COAL_IMP_B_STOCK_ADJ', 'YTD_COAL_IMP_C_STOCK_ADJ', 'YTD_COAL_IMP_D_STOCK_ADJ', 'YTD_COAL_IMP_E_STOCK_ADJ')
    How can i get result without single cotes for each column.

    Your query currently returns a collection type (tab_type) whereas it appears you want to return a delimited string.
    There are actually quite a few ways to achieve this - with your own function, with a user-defined aggregate functions (e.g. Tom Kyte's stragg), with the MODEL clause or with CONNECT BY, e.g.
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> SELECT table_name,
      2         SUBSTR (MAX (SYS_CONNECT_BY_PATH (
      3            column_name, ',')), 2) column_names
      4  FROM  (SELECT table_name, column_name,
      5                ROW_NUMBER () OVER (
      6                   PARTITION BY table_name
      7                   ORDER BY column_id) column_order
      8         FROM   user_tab_columns
      9         WHERE  table_name = 'BANK_ACCOUNT'
    10         AND    column_name LIKE '%U%') utc
    11  START WITH column_order = 1
    12  CONNECT BY column_order = PRIOR column_order + 1
    13  AND    table_name = PRIOR table_name
    14  GROUP BY   table_name;
    TABLE_NAME           COLUMN_NAMES
    BANK_ACCOUNT         ACCOUNT_NAME,ACCOUNT_NUMBER
    SQL>

  • INSERTED Table - When it gets populated with single or multiple rows?

    Hi,
    I'm trying to create a trigger which then insert to a table. i'm wondering when does the INSERTED table gets populated with single or multiple rows?
    Should I always assume that the INSERTED Table will contains several rows? What does the scope of the INSERTED table in the trigger, isn't based on the user session?
     The reason why i asked this is because as far as i know inserted table may contain several table when the trigger fires which is why I use cursor to insert  records in the table ( there's a behind why i use cursor).
    But if the inserted table will only contain a single record during the session of the trigger then i can avoid the cursor.
    Thanks.

    But since we control the transaction process and we know for a fact that user will only be able to save a record one at a time, do we still expect multiple rows? I just want to have a clear concept on the INSERTED table.
    ...and then the DBA or someone else sees fit to enter a number of rows directly from a query window. And don't laugh. That is bound to happen sooner or later.
    However, just because this can (and will) happen does not mean that you need to handle it on equal footing with the normal case user entering data through the application. What you cannot permit yourself to is to drop the DBA case on the floor, that is write
    the trigger as if there would either be single-row inserts and produce incorrect results for multi-row inserts.
    But, yes, allowing yourself to use a cursor, if you want to reuse the existing stored procedure is feasible. That is also the more drastic solution suggested by Tom to add an explicit check that disallows multi-row inserts.
    Finally, permit me to comment on this:
    Additionally, it's  difficult to use the code below as i need to pass the identity id of tbl_A to tbl_B
    You can use the OUTPUT clause to capture the values, but that requires that you have something you can map the identity values to in the columns you insert, and this is not always the case. However, there is a lot simpler solution to the problem: don't
    use IDENTITY. IDENTITY is one of these over-used and over-abused features in SQL Server. You need it when you want to support high-concurrency inserts, because rolling your own requires a serialisation point. But with a moderate insertion frequency, IDENTITY
    only gives you headache.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Single report with multiple queries OR multiple reports with single query

    Hello Experts,
    I have a confusion regarding Live Office connection for many days. I asked many people but did not get a concrete answer. I am re-posting this question here and expecting an answer this time.
    The product versions that I am using are as follows:
    FrontEnd:
      BOE XI 3.1 SP4 FP 4.1
      Xcelsius Enterprise 2008 SP4
    Backend:
      SAP BW 7.0 EHP1
    I have created a dashboard which is getting data from a webi report using LO connections.
    The webi report has five report parts which are populated by five different queries.
    Now my question is, when the five LO connections are refreshed, is the webi report refreshed five times or just once?
    If the report is refreshed five times, then I guess it is better to have five different webi reports containing single report part, because in that way we can prevent same query being executed multiple times.
    SO what is the best practice- to have a single report having multiple queries - OR - to create multiple webi reports with single query?
    Thanks and Regards,
    PASG

    HI
    I think Best Practice is Multiple reports with single query
    Any way If LO connections refresh 5 time the query will refresh 5 timesRegards
    Venkat

  • Today I purchased an ATT mifi liberate hotspot to use with my early 2011 MBP,   the iPad Air I also purchased today. I've been testing out all the settings on the hotspot, but can't seem to get results with the GPS switch. GPS just spins, searches, doesn'

    Today I purchased an ATT mifi liberate hotspot to use with my early 2011 MBP, along with the iPad Air (128GB, WiFionlyI also purchased today. I've been testing out all the settings on the hotspot, but can't seem to get results with the GPS switch. GPS just spins, searches, doesn'. I can access the hotspots settings in Safari on the laptop and still the problem persisits. I did install some new GPS drivers recommended by AT&T, that doesn't seemed to have work. Could it be that there is a port wrong somewhere? Can anybody make heads or tails of this? Any assistance is gratefully appreciated...

    Today I purchased an ATT mifi liberate hotspot to use with my early 2011 MBP, along with the iPad Air (128GB, WiFionlyI also purchased today. I've been testing out all the settings on the hotspot, but can't seem to get results with the GPS switch. GPS just spins, searches, doesn'. I can access the hotspots settings in Safari on the laptop and still the problem persisits. I did install some new GPS drivers recommended by AT&T, that doesn't seemed to have work. Could it be that there is a port wrong somewhere? Can anybody make heads or tails of this? Any assistance is gratefully appreciated...

  • How can I get the same result using single query?

    There are 3 tables
    1) tool_desc -
    a master table for storing tool records,
    columns tool_no, tool_chg,
    # of records = 1.5 Millon
    2) step_desc -
    a master table for storing plan wise step records,
    columns plan_id, step_key,
    # of records = 3700 Million
    3) step_tool - a transaction table storing tools to the steps,
    columns plan_id, step_key, tool_no, tool_chg
    For each step in the step_desc table, I need to randomly fetch 1 to 50 tools from tool_desc and insert them into step_tool table.
    Using PL/SQL block, it is like the following -
    begin
    for x in (select plan_id, step_key from step_desc) loop
    insert into step_tool(
    plan_id,
    step_key,
    tool_no,
    tool_chg)
    select
    plan_id,
    x.step_key,
    tool_no,
    tool_chg
    from
    tool sample(0.1)
    where
    rownum <= trunc(dbms_random.value(1,51))
    commit;
    end loop;
    end;
    I need to do the same using a single query so that I can use the CTAS (create table as select) statement and load the data as a bulk.
    Can I do that?

    If they have parent child releation, you can use connect by prior clause,

  • Combining results with a Query of Queries - NOT QUITE THERE!!!

    I have included a small sample of my database, specifically the four tables I am trying to work with in the hopes that someone can steer me down the right path. Here are the four tables and the bottom is a visual desciption of what I am trying to achieve;
    ORDERS
    SALES CALLS
    ID
    SaleDate
    TerritoryManager
    UserID
    SaleDate
    TerritoryManager
    ID
    UserID
    426
    01-Oct-09
    Mike B
    10112
    10/1/2009
    Mike  B
    253
    10112
    427
    01-Oct-09
    Russ  C
    10115
    10/1/2009
    Mike  B
    254
    10112
    430
    01-Oct-09
    Jerry W
    10145
    10/1/2009
    Mike  B
    255
    10112
    432
    01-Oct-09
    Ron  H
    10118
    10/1/2009
    Mike  B
    256
    10112
    433
    01-Oct-09
    Ron H
    10118
    10/1/2009
    Ron  H
    257
    10118
    10/1/2009
    Ron  H
    258
    10118
    PRODUCTS ORDERED
    10/1/2009
    Ron  H
    260
    10118
    OrderID
    Quantity
    NewExisting
    UserID
    10/1/2009
    Russ  C
    261
    10115
    426
    12
    0
    10112
    10/1/2009
    Mike  B
    267
    10112
    427
    2
    0
    10115
    10/1/2009
    Mike  B
    268
    10112
    427
    3
    1
    10115
    430
    1
    0
    10145
    USERS
    430
    1
    0
    10145
    TerritoryManager
    Zone
    UserID
    432
    1
    0
    10118
    Mike B
    Central
    10112
    432
    1
    0
    10118
    Russ  C
    Central
    10115
    432
    1
    1
    10118
    Jerry W
    Central
    10145
    432
    1
    1
    10118
    Ron  H
    Central
    10118
    433
    2
    1
    10120
    Don  M
    Central
    10120
    Central Zone
    Ttl Calls
    Ttl Orders
    Ttl Items
    Ttl New Items
    Mike B
    5
    1
    12
    1
    Russ  C
    1
    1
    5
    Jerry W
    1
    2
    Ron  H
    3
    2
    6
    3
    I have tried to achieve this result in many ways to no avail. If I try to combine PRODUCTS ORDERED with ORDERS I get an erroneous count. I finally resigned myself to getting all the info I needed with separate queries and then trying to combine them with a query of queries. This worked fine until the last query of queries which timed out with no results. I am a newbie and would appreciate any constructive help with this. I am including my queries below as well;
    <cfquery name="qGetOrders" datasource="manna_premier">
    SELECT Count(Orders.ID) AS CountOfID,
           Orders.UserID AS Orders_UserID,
        Users.UserID AS Users_UserID,
        Users.TMName
    FROM Users INNER JOIN Orders ON Users.[UserID] = Orders.[UserID]
    GROUP BY Orders.UserID, Users.UserID, Users.TMName;
    </cfquery>
    <cfquery name="qGetSalesCalls" datasource="manna_premier">
    SELECT Count(Sales_Calls.ID) AS CountOfID,
           Users.UserID AS Users_UserID,
        Users.TMName,
        Sales_Calls.UserID AS Sales_Calls_UserID
    FROM Users INNER JOIN Sales_Calls ON Users.[UserID] = Sales_Calls.[UserID]
    GROUP BY Sales_Calls.UserID, Users.UserID, Users.TMName;
    </cfquery>
    <cfquery name="qGetProducts" datasource="manna_premier">
    SELECT Count(ProductOrders.OrderID) AS CountOfOrderID,
           Sum(ProductOrders.Quantity) AS SumOfQuantity,
        Sum(ProductOrders.NewExisting) AS SumOfNewExisting,
        ProductOrders.UserID
    FROM Orders INNER JOIN ProductOrders ON Orders.[ID] = ProductOrders.[OrderID]
    GROUP BY ProductOrders.UserID;
    </cfquery>
    <cfquery name="qqCombOrd_Prod" dbtype="query">
    SELECT *
    FROM qGetOrders, qGetProducts
    </cfquery>
    <cfquery name="qqCombOrd_ProdtoSales" dbtype="query">
    SELECT *
    FROM qqCombOrd_Prod, qGetSalesCalls
    </cfquery>
    PLEASE HELP!!! I'm about to go scouting for bridges to leap from!

    You might be able to simplify that query by getting rid of the subqueries.  Something like this
    SELECT TerritoryManager
    , count(sc.userid) totalcalls
    , sum(po.quantity) total
    , sum(newexisting) totalnew
    , count(o.userid) totalorders
    from users u join salescalls sc on u.userid = sc.userid
    join orders o on u.userid = o.userid
    join productorders po on u.userid = po.userid
    where userzone = 'CENTRAL'

  • How to get result of select query from  oracle  in VC

    Dear All ,
    I have a application in oracle which insert the data in the oracle database table.
    Now i want to show all the data that has been inserted into the database table in my VC application but i don't know how to handle select query in VC.
    Regards
    Krishan

    Hi Goivndu
    Thanks for your reply .
    I know all those things.
    I have created the system & alias  for my backend oracle system.
    I can also see all the stored procedure that are there in my oracle system.
    I just want to know how to write a select query in a stored procedure .
    you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
    If you know any way to do that please do let me know .
    Regards
    Krishan

  • Files get open with single click sometimes

    I recently started having this problem. When I browse through different image/video files, some of the files get open with one click only. This is really very annoying. I am event thinking to migrate back to Windows because of this problem.
    How to reproduce the issue:
    -> Open a folder that contains many images/video files
    -> Click on anyone of them to select it
    -> Now click outside the window. So, the finder goes out of the focus (but should stay visible)
    -> Now, inside finder click any other image/video just once, it will open up automatically with just single click

    If you have access to a mouse, try using it. If everything is okay using the mouse, then it is likely trackpad related. Other troubleshooting.
    Try setting up another admin user account to see if the same problem continues. If Back-to-My Mac is selected in System Preferences, the Guest account will not work. The intent is to see if it is specific to one account or a system wide problem. This account can be deleted later.
    Isolating an issue by using another user account
    If the problem is still there, try booting into the Safe Mode.  Shut down the computer and then power it back up. Immediately after hearing the startup chime, hold down the shift key and continue to hold it until the gray Apple icon and a progress bar appear. The boot up is significantly slower than normal. This will reset some caches, forces a directory check, and disables all startup and login items, among other things. If the system operates normally, there may be 3rd party applications which are causing a problem. Try deleting/disabling the third party applications after a restart by using the application unistaller. For each disable/delete, you will need to restart if you don't do them all at once.
    Safe Mode
    Safe Mode - About
    General information.
    Isolating issues in Mac OS X
    Troubleshooting Permission Issues
    Step by Step to Fix Your Mac

  • Update several rows with single query (easy question, I guess)

    Hi all!
    I have table with two columns - name and value.
    I populate it with several sql queries:
    insert into settings (name, value) values ('company_name', 'My Company');
    insert into settings (name, value) values ('company_address', 'Company Address 12');
    insert into settings (name, value) values ('company_city', 'South Park');
    How can update rows with company_name and company_city in single query?
    Thank you in advance!

    How can update rows with company_name and company_city in single query?I guess something like this was meant:
    update settings set value = ??? where name in ('company_name ', 'company_city');But it's still unclear to me what should be used instead of question marks... :)
    Regards.

  • GET Method with long query string

    Hi there,
    Not sure if this has already been answered. Sorry if it has!
    I have a Biztalk application which does a pass-through for all http requests. It is using WCF-WebHttp transport type with URL mapping of /*.
    It works fine except for GET method that has query string longer than 256 characters. It chokes with following exception:
    The adapter "WCF-WebHttp" raised an error message. Details "System.ArgumentOutOfRangeException: The value of promoted property cannot exceed 256 characters. Property "To" Namespace "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties".
    My question is is there a workaround for this e.g. extend the string length limit? 

    Hi Karsten,
    Try giving the one part of URL in address box and other pass the arguments inside HTTP Method and URL Mapping dialog.
    Eg:
    Address (URI) : https://btstecheddemostorage.blob.core.windows.net
    <BtsHttpUrlMapping>
    <Operation Name="ListFiles"
    Method="GET" Url="/{mycontainer}?restype=container&amp;comp=list"
    /> </BtsHttpUrlMapping>
    Thank YOu,
    Tamil

  • Problem getting results with no unique key in a joined query

    I created a descriptor to do a joined query, which generated a query in log as:
    Select t0.empID,t1.empID, t1.phone from Emp t0, Phone t1
    where t0.empId=t1.empId and t0.empId=1001
    When I run it, I got the result as:
    1001,1001,9999999
    1001,1001,9999999
    The correct result should be (I copy and paste the query from log into SQL-Plus):
    1001,1001,9999999
    1001,1001,1234455
    I suspect this is caused by Toplink caching objects by primary key. I wonder if anybody has a solution for this.
    My descriptor is created using WorkBench. Emp is the primary table, Phone as additional table linked by foreignKey empId.
    The join is implemented by modifying the descriptor as the following:
    ExpressionBuilder builder = new ExpressionBuilder();
    descriptor.getQueryManage()
    .setMultipleTableJoinExpression(
    builder.getField("EMP.EMPID").equal(
    builder.getField("EMP.EMPID")));
    descriptor.disableCacheHits();
    I'd really appreciate your help.

    I am implementing a people search function. The batch reading is quite expensive if toplink does a read query for every person. A customized query requires only one database access, the other way may requires hundreds.
    I don't want to use the cache either in this case because the database is also accessed by legacy system which cann't notify toplink any updates.
    I opened a TAR on this and the solution I got is to use ReportQuery rathen than ReadAllQuery. The only problem here is that now I have to map the query result to my class manually.

  • Getting results of select query

    hi guys! I'm really into web app/java stuff and usually our dba takes care of our database problem. But now, one project that im involve with needs me to be familiar with pl/sql so if this question is really that stupid please bear with me. Anyway, i need to implement this logic to my stored procedure. Basically this is what i need to do:
    I have a Users table, Permission table and Temp table.
    I have to do a Select * from users order by uid
    I need to get hold of the resultset of this query, how can i do that in pl/sql?
    I need to get hold of it because I need to loop through the results of the users table.
    Then whenever i loop through the result I would check if the user is found in the permission the table, if found i would get the uid, lastname, firstname, age, description and I would insert that record into the Temp table. And also when i insert the description item into the Temp, I've got to make sure that white spaces are removed before it gets stored in the database, how can I do that?
    I hope somebody there can give me a helping hand. thanks.

    I was trying to give an example that is related to what I need to do. Apparently, i can't seem to make a good sample out of it. Anyway, this is really what i need to do:
    This is my logic right now:
    I need to query different tables in order to populate my arrticle table.In doing so I need to know the category of an article, then I have to test if that category should be posted into the article table. So here it goes:
    Delete all rows from articles table
         DELETE FROM articles
    Get a list of all categories
         SELECT * FROM category ORDER BY parentid
    For each category
         If the category is visible to public
              Insert the category to the article table:
    For a given category:
         Set IS_PUBLIC to false
         If this category has a parent id?
              Find the top level category id (top level categories do not have parent id)
         } else {
              Query permission table to see if this category is accesible by Public
                   SELECT access FROM permission
                   WHERE role_name = 'Public'
                   AND resource_name = 'knowledgebase.#top_category_id#'
              If there are any records
                   Set IS_PUBLIC to true
    Return IS_PUBLIC.
    Category table:
    sample data:
    ID PARENTID CATEGORY
    1 ROOT 1
    2 ROOT 3
    3 2 ROOT 3.1
    4 1 ROOT 1.1
    5 4 ROOT 1.1.1
    6 5 ROOR 1.1.1.1
    7 3 ROOT 3.1.1
    Basically, the validation that i need in here is i need to check every row of the category table then check for its id until i find a combination wherein the said doesnt have any parent id, meaning i reached already the topmost category.

Maybe you are looking for

  • Generate yearmonth for every month of the year

    Hi, I need to generate all the dates in the format of yyyymm starting with the last month. I mean something like below : rownum            yearmonth 1                       201204 2                       201203 3                       201202 4       

  • Can I connect my iPad to an external CD burner?

    Am wondering if its possible to connect via hardwire or wireless to a CD/DVD burner from an IPad 4.

  • How do i link MySQL to a WS

    hihi i been look for a way to link up WS with DB but i dont seem to find any good tut..... it would be nice if you could post link for some useful tut thx :)

  • Release PO

    hai i released one purchse order that is lost dated po, means lost month 29th dated, today i released that one, now i verifying the report(me2n,me2m) any one i did't get the released po report, becaused the report will take through the document date

  • IPQoS panic: BAD TRAP in module "flowacct" due to NULL pointer.

    I've recently started using IPQoS and the flowacct module to do some very simple tracking of bandwidth usage (along with one tokenmt action to meter traffic to and from one particular zone) on a host with multiple zones, running Solaris 10 x86, 11884