Funny SQL-problem

I've managed to come up with rather strange solution proposal to a problem... but I came up with this problem, that I'm unable to do queries with it.
Say for example that theres a table with following fields
ID, FIELD, VALUE
and following data
0, firstname, John
0, lastname, Doe
0, salary, 30000
1, firstname, Jane
1, lastname, Doe
1, salary, 29000
Now you must have gotten the idea of the table structure. Then is it possible to select every Doe whichs salary is above 29500?
I havent fiqured out a way to do this... can you or should I just use orginal structure?
The problem is that I would've liked an abstract approach so every time there's new structure, I don't need to create new table for that. My other option was to create table with needed indexed fields and a data portion which has XML-image of the data.

You can do this
select a.*
from yourtable a, yourtable b
where a.id = b.id
and a.field = "lastname"
and a.value = "Doe"
and b.field = "salary"
and b.value > "29500"
I hope this helps.
Regards,
KD
I've managed to come up with rather strange solution
proposal to a problem... but I came up with this
problem, that I'm unable to do queries with it.
Say for example that theres a table with following
fields
ID, FIELD, VALUE
and following data
0, firstname, John
0, lastname, Doe
0, salary, 30000
1, firstname, Jane
1, lastname, Doe
1, salary, 29000
Now you must have gotten the idea of the table
structure. Then is it possible to select every Doe
whichs salary is above 29500?
I havent fiqured out a way to do this... can you or
should I just use orginal structure?
The problem is that I would've liked an abstract
approach so every time there's new structure, I don't
need to create new table for that. My other option was
to create table with needed indexed fields and a data
portion which has XML-image of the data.

Similar Messages

  • Two SQL problems

    First problem...
    SQL root will not access all databases...
    If I try to access al databases using SQL Administrator the connection is refused even if I use root.
    all databases are accessable va individual username and password..
    Tried changing root password with GUI but makes no difference...
    Second SQL problem...
    10.4.11 server failed all raid volumes so corrupted no rescue was possible on any volume reinstall failed as well...
    Have rebuilt the server using 10.5.6 I will have to manually import the SQL databases from the old server... what do I do ??? I cannot boot the old server so cannot do an SQL export or anything...
    Thanks...

    Hi Jun,
    Can i contribute a little for ur 2nd problem.
    This error is coz, If u are using a filter against a File "data store" u can't test it, only against RDBMS query will be tested at data store level.
    Well, for using that filter and make sure its working, drag and drop the source file in the interface (u can get the filter) and make it to execute on STAGING.
    Thanks,
    Guru

  • Small SQL problem

    Hello,
    I have a small SQL problem...
    I am designing an online bank using servlets for a university project and it allows customers to view their statements. They select which of their account numbers they want to view the statement for and the start and end date of the statement.
    The problem lies with the dates. Here is the SQL:
    SELECT date, details, amount, balance
    FROM HISTORY
    WHERE bankaccnumber=13494925 And date>=1/1/01 And date<=31/1/01;
    All of the books I have looked at show dates in '1/1/01' format but whenever I try it this way I get a 'Data type mismatch in criteria expression' error (the 'date' field in the Database IS a Date type).
    Although, whenever I run the query in Access and prompt the user to enter the start and end date, it works fine.
    I have spoken to a few people and no-one seems to know why it is not working.
    Any ideas???
    Thanks

    If your database is MS Access and you don't expect to switch to something else, then write this:
    SELECT date, details, amount, balance
    FROM HISTORY
    WHERE bankaccnumber=13494925 And [date]>=#1/1/01# And [date]<=#1/31/01#
    Note that you MUST format your dates as MM/DD/YY and not as DD/MM/YY, that's an Access rule, and that you will probably have to "quote" your column name "date", which I think is a reserved word in SQL and hence a bad choice for column name.
    Personally I always use PreparedStatements. That way my SQL would look like this:
    SELECT date, details, amount, balance
    FROM HISTORY
    WHERE bankaccnumber=13494925 And date>=? And date<=?
    and I would use the setDate() method to fill in the parameters. Since this method uses a Date as a parameter, I don't need to fight with date formats, the JDBC driver handles that for me.

  • Sql problem, pivot question?

    Hi guys,
    I have an interesting problem and do not manage to find a sollution.
    I need to create a report, and we call it variance/trending report. let me explain.
    I have a table that holds all employess with their salaries, every month.
    currenly my selects gets all employess with their salaries from current and previous month. and the result looks like:
    Employee_iD| Salary| month
    1          |500   |   C
    2          |100   |   P
    1          |650   |   P
    3          |100   |   p
    3           |180   |   C
    how can I do my select so I can see the result, in different columns, in a manner in which I can compare the salaries between them (from current and previous month):
    Employe_iD| current_month| previous_month | variance
    1        |500                 | 650                 | -150
    2        |                      | 100                 |
    3        |180                 |100                   |80you can see that C, measn current month, and P measn previous month.
    I think I will have data in my select for both, previous and current. If not, I will treat it as zero.
    I gave a simple exemple . My select is a little more complex.
    any help is appreciated.
    Thanks

    May be..
    SQL> WITH tbl AS (SELECT 1 empid,500 sal,'C' mon FROM DUAL UNION ALL
      2               SELECT 2 empid,100 sal,'P' mon FROM DUAL UNION ALL
      3               SELECT 1 empid,650 sal,'P' mon FROM DUAL UNION ALL
      4               SELECT 3 empid,100 sal,'P' mon FROM DUAL UNION ALL
      5               SELECT 3 empid,180 sal,'C' mon FROM DUAL
      6               )
      7  SELECT empid,NVL(MAX(DECODE(mon,'P',sal)),0) previous_sal
      8              ,NVL(MAX(DECODE(mon,'C',sal)),0) current_sal
      9              ,NVL(MAX(DECODE(mon,'P',sal)),0)- NVL(MAX(DECODE(mon,'C',sal)),0)
    10                var
    11  FROM tbl
    12  GROUP BY empid          
    13               ;
         EMPID PREVIOUS_SAL CURRENT_SAL        VAR
             1          650         500        150
             2          100           0        100
             3          100         180        -80

  • PL/SQL problem in portal

    hello all,
    PROBLEM :
    I followed this thread Copying data from one field to another on a form
    but unfortunately..encountered with d following error...
    Any PL/SQL coding is throwing such errors on my portal..
    I have to install any additional tools or configure something..( I done executed the provsyns.sql for myschema)
    Someone please suggest me..
    ERROR :
    Internal error (WWC-00006)
    An unexpected error occurred: ORA-01001: invalid cursor (WWV-16016)
    Error displaying form : ORA-01001: invalid cursor (WWV-16408)
    Error running user PL/SQL code: ORA-01001: invalid cursor (WWV-16403)
    ORA-06550: line 5, column 7:
    PLS-00201: identifier 'P_SESSION.GET_VALUE_AS_VARCHAR2' must be declared
    ORA-06550: line 5, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 8, column 9:
    PLS-00201: identifier 'P_SESSION.GET_VALUE_AS_VARCHAR2' must be declared
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 11, column 1:
    PLS-00201: identifier 'P_SESSION.SET_VALUE' must be declared
    ORA-06550: line 11, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 15, column 1:
    PLS-00201: identifi (WWV-11230)
    Failed to parse as PORTAL_PUBLIC - BEGIN declare
    id varchar2(20);
    name varchar2(20);
    begin
    id := p_session.get_value_as_VARCHAR2(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'EMP_ID');
    name := p_session.get_value_as_VARCHAR2(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'EMP_NAME');
    p_session.set_value(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'ID',
    p_value => id);
    p_session.set_value(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'NAME',
    p_value => name);
    end; END; (WWV-08300)
    The preference path does not exist: ORACLE.WEBVIEW.PARAMETERS.1668713167 (WWC-51000)
    Many Thanks In Advance :-)

    hi Pappu
    if you have used the same exact code as given in the message you have mentioned, then please correct one variable's name. the reply I gave in that thread has a typo. in suggesting a solution to that question, I had tried it with a different set of variables on my system and in replying back, i mistakenly left one such variable in that thread.
    try it and see if you still get errors.
    AMN
    declare
    v_address1 varchar2(20);
    begin
    v_address1 := p_session.get_value_as_VARCHAR2(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'A_ADDRESS1');
    p_session.set_value(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'A_LOCATION1',
    p_value => v_address1);
    end;

  • PL/SQL- Problem in creating a partitioned fact table using select as syntax

    Hi All,
    I am trying to create a clone(mdccma.fact_pax_bkng_t) of existing fact table (mdccma.fact_pax_bkng) using dynamic pl/sql. However, pl/sql anonymous block errors out with following error:
    SQL> Connected.
    SQL> SQL> DECLARE
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 1608
    ORA-06512: at "SYS.DBMS_SQL", line 33
    ORA-06512: at line 50
    Here is pl/sql block:
    -- CREATING FPB_T
    DECLARE
    v_owner VARCHAR2(32) := 'MDCCMA';
    v_table_original VARCHAR2(32) := 'FACT_PAX_BKNG';
    v_table VARCHAR2(32) := 'FACT_PAX_BKNG_T';
    v_tblspc VARCHAR2(32) := v_owner||'_DATA';
    CURSOR c_parts IS SELECT TABLESPACE_NAME, PARTITION_NAME,HIGH_VALUE, ROW_NUMBER() OVER (ORDER BY PARTITION_NAME) AS ROWNUMBER
    FROM USER_TAB_PARTITIONS
    WHERE TABLE_NAME = v_table_original
    ORDER BY PARTITION_NAME;
    v_cmd CLOB := EMPTY_CLOB();
    v_cmd3 varchar2(300) := 'CREATE TABLE ' ||v_owner||'.'||v_table||' TABLESPACE '||v_tblspc
    ||' NOLOGGING PARTITION BY RANGE'||'(' ||'SNAPSHOT_DTM '||')' ||'(';
    v_part VARCHAR2(32);
    v_tblspc_name VARCHAR2(32);
    v_row number;
    v_value LONG;
    v_tmp varchar2(20000);
    v_cur INTEGER;
    v_ret NUMBER;
    v_sql DBMS_SQL.VARCHAR2S;
    v_upperbound NUMBER;
    BEGIN
    v_cmd := v_cmd3;
    OPEN c_parts;
    FETCH c_parts INTO v_tblspc_name, v_part,v_value, v_row;
    WHILE c_parts%FOUND
    LOOP
    IF (v_row = 1) THEN
    v_tmp := ' PARTITION '||v_part||' VALUES LESS THAN ' ||'('|| v_value||')'||' NOLOGGING TABLESPACE '||v_tblspc_name;
    ELSE
    v_tmp := ', PARTITION '||v_part||' VALUES LESS THAN ' ||'('|| v_value||')'||' NOLOGGING TABLESPACE '||v_tblspc_name;
    END IF;
    v_cmd := v_cmd || v_tmp;
    -- DBMS_OUTPUT.PUT_LINE(v_cmd);
    FETCH c_parts INTO v_tblspc_name, v_part,v_value, v_row;
    END LOOP;
    -- DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_cmd));
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2'||';';
    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_cmd)/256);
    FOR i IN 1..v_upperbound
    LOOP
    v_sql(i) := DBMS_LOB.SUBSTR(v_cmd
    ,256 -- amount
    ,((i-1)*256)+1 -- offset
    END LOOP;
    v_cur := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    v_ret := DBMS_SQL.EXECUTE(v_cur);
    CLOSE c_parts;
    DBMS_OUTPUT.PUT_LINE(v_cmd);
    -- EXECUTE IMMEDIATE v_cmd ;
    END;
    The above pl/sql creates a DDL for partitioned fact table(new) based on an existing fact table and get executes through CLOB.
    Please look into the issue and let me know any changes or modifications/suggestions that are required to fix the issue. Any help is appreciated.
    Thank You,
    Sudheer

    Think this is your problem:
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2'||';';Remove the SQL terminator ';' ... dynamic SQL doesn't require it, try this instead:
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2';Thanks
    Paul

  • Funny align problem....

    Link to online page : http://www.episodesoft.com/demo/index_fr.html
    Hello.
    I have a funny probleme dealing with alignment when you must have a webpage that can resize itself depending of the screen resolution. i know i am not a pro, but this is kindra funny...
    The basic setting is 1024x768, up to 1920x1080. my probleme is that i want the content (text) to always fit with the logo "logiciel episode" and currently it is working only with the 1024x768. The arm of the lady is cut on purpose in this format.
    I've try to put a margin-left in the CSS here, but when you do that, it fix the log/content fitting, but the text itself go over the lady ( yes the lady and the content are separate file for futur edition purpose). Now because the arm of the lady appear only when you are in a higher resolution that 1024x768, the table itself is larger than what is require by the 1024x768 size, thus messing thing.
    I cannot modifie the header either because the header as you see is not a single color that you can put in backgroup in the CSS. i had to make a file of 2000 pixelx95 for that.
    Does anyone know a way to fix or force the content and the lady something about 30-40 px from the left border of the cell in the table ?... when i try to type that directly in the code, nothing happen at all.
    Also please take note that the actual content will be in html, and not a Jpg ( however the background of the table will be a png ). this is still a demo.
    i am a little puzzled here.
    Since you cannot open the file, i copy here the whole code ( there is some part that are desactivated, dont mind it )
    Any help will be welcome.
    Thanks
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Logiciel Épisode</title>
    <style type="text/css">
    <!--
    #bottom {
    background-color: #FFFFFF;
    background-repeat:no-repeat;
    background-position: bottom;
    background-image: url(images/barre_bottom.png);
    height: 5px;
    #headinner  {
    background-position: center top;
    margin-top: 0px;
    margin-bottom: 0px;
    background-color: #F5F6F7;
    background-repeat: no-repeat;
    height: 95px;
    background-image: url(images/HeaderFR.png);
    body {
    background-color: #ffffff;
    margin-top: auto;
    margin-right: auto;
    margin-bottom: auto;
    margin-left: auto;
    background-image: url(images/fond.png);
    text-align: center;
    background-position: center;
    #Copyright {
    text-align: center;
    margin-bottom: 1px;
    margin-top: 1px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    #layer2 #Layer2 tr td p {
    text-align: center;
    font-size: 36px;
    <!-- margin-left: 30px;
    -->}
    -->
    </style>
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    </head>
    <body>
    <div id="headinner">
    </div>
    <!--<div id="layer1" style="position:absolute; left:50%; margin-left:-475px; top:70px; width:950px; height:580px; z-index:2">
    <table width="950" border="0" align="center" >
      <tr>
        <td align="center" valign="middle">
        <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="950" height="580">
          <param name="movie" value="Video/Menu.swf" />
          <param name="wmode" value="transparent">
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="swfversion" value="6.0.65.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <param name="embed" value="wmode=&quot;transparent&quot;" />
          <param name="selectable" value="false" />
          <param name="border" value="0" />
          <param name="embed" value="border=&quot;0&quot;" />
         <object type="application/x-shockwave-flash" data="Video/Menu.swf" width="950" height="580">
            <param name="quality" value="high" />
            <param name="wmode" value="transparent" />
            <param name="swfversion" value="6.0.65.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <param name="embed" value="wmode=&quot;transparent&quot;" />
            <param name="selectable" value="false" />
            <param name="border" value="0" />
            <param name="embed" value="border=&quot;0&quot;" />
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
          </object>
          </object>
        </td>
      </tr>
    </table>
    </div> -->
    <div id="layer2">
    <table border="0" align="center" id="Layer2" name="Layer2">
      <tr>
        <td background="images/accueil_fond.png" width="1035" height="485" aling="right" ><img src="images/accueil2_3.png" width="950" height="485" align="left" valign="middle"/></a></td>
      </tr>
    </table>
    </div>
    <div id="bottom">
    </div>
    <p id="Copyright">© 2010 - Logiciel Episode Inc.</p>
    <table width="10" border="0" align="center">
      <tr>
        <td align="center" valign="middle"><a href="index_us.html" target="_self">English</a></td>
        <td align="center" valign="middle"><a href="index_fr.html" target="_self">Francais</a></td>
    <!--
        <td align="center" valign="middle"><p><a href="index_us.html" target="_self"><img src="images/Drapeau_US.png" width="25" height="15" border="0" align="absmiddle" /></a></p></td>
        <td align="center" valign="middle"><a href="index_fr.html" target="_self"><img src="images/Drapeau_fr.png" width="25" height="15" border="0" align="absmiddle" /></a></td>
    -->  </tr>
    </table>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID");
    //-->
    </script>
    </body>
    </html>

    Building a "liquid" page layout for sizes rranging from 1024 to 1920 is going to give you problems if you expect your container's text content to remain fixed as the page (and the container) expands to fit the screen, in order to match a background picture.
    It's a little like building a house with movable walls but expecting the flooring and furniture and plumbing and wiring and windows to change sizes and location exaclty right every time you decide to slide a wall in or out.
    It can theoretically be done, but it's waaaaaaaaaayyyyyyyyyy more work than anyone would reasonably want to do.
    Better off to build a fixed container with a background image that fits.
    If you really want a fluid container, stick to adding text directly to a header image and leave that in a fixed position at the top of the page so no matter how big a visitor's screen is it will always look right, even if the page expands to 2048 X 1536 or larger.

  • SQL problem

    I've got a problem with a servlet I'm writing. Here's a code snippet:
    if(operation.equals("Lookup details"))
              {     //get customer details
                   String Hnum = req.getParameter("HouseNum");
                   String Pcode = req.getParameter("PostCode");
                  String sql = "SELECT * FROM Customer WHERE house_num = " Hnum " AND postcode = '" Pcode "'";
                  String url = "jdbc:pointbase:server://localhost:9092/projectdb";
                  Connection con;
                  Statement stmt;
                  ResultSet rs;
                   try {
                        Class.forName("com.pointbase.jdbc.jdbcUniversalDriver");
                   catch(ClassNotFoundException ex) {
                        out.println("Failed to find driver");
                   try {
                        con = DriverManager.getConnection(url, "PBPUBLIC", "PBPUBLIC");
                        stmt = con.createStatement();
                        //execute query
                        rs = stmt.executeQuery(sql);
                   catch(SQLException ex) {
                        out.println("SQL Exception");
                        out.println("" + ex);
              }When it comes to actually executing the sql command I get the following error:
    SQL Exception
    java.sql.SQLException: Expected to find "end of SQL command" instead found "POSTCODE" at position 46.
    I can't quite see whats wrong with my SQL string, its probably something simple tho. Any ideas?

    For sure (200%) your request does not contain HouseNum parameter.
    You should check presence of HouseNum parameter for instance like:
    String hnum=req.getParameter("HouseNum");
    if(hnum==null || hnum.trim().length()==0)
       //do something here - for instance put default HouseNum value like:
       hnum="1"
    }

  • Sql Problems, Same Field Names In Multiple Mysql Tables?

    I have a keyword search that searches multiple DB tables for thumbnail images using UNION ALL. I have two pages, results.php, and view.php.  My goal is to able to click a thumbnail image on results.php and be directed to a larger version of that same image on view.php. The problem is each image in all my tables uses the field name "id" so when I click a thumbnail on results.php I get two different images with the same id from different tables.  I tried changing the id's to different names, but when it was time to pass url parameters I can only choose 1 value. (if you can choose more than 1 I don't know how).  So my question is why are my id's from different tables being grouped together, and how can I change this?
    Image Results Page (which works perfect):
    SELECT *
    FROM table1
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    UNION ALL
    SELECT *
    FROM table2
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    View Image Page (having problems here):
    SELECT *
    FROM table1
    WHERE id = colname
    UNION ALL
    FROM table2
    WHERE id = colname

    Yes, that is going to be a problem - and it's just the beginning of your problems when you do not normalize your data. Your data model is not correct. You should not be storing similar data in 15 tables - it's a really big mistake.
    To solve your current problem you would need to include a table identifier in the query results in the Image results page, and pass that to the view page and then use PHP to dynamically create the SQL with the correct table....ugh!

  • Java.sql problem

    Hi,
    I have a problem with "import java.sql.*".
    When a try to compile i get the error:
    "package java.sql does not exist"
    I've tried everything, classpath, add JAR/Libraries, install CDC tools, looked into hundred forums and can't solve the problem.
    I'm using NetBeans 5.5 with Mobility Pack.
    If anybody have any idea about what can I do, I'll appreciate it a lot.
    Thank You!
    If you need me to be more specific, please let me know

    I just start the application with
    import java.sql
    an then the rest of the applicationIf you want to import all the classes from the java.sql package, the correct import statement is:import java.sql.*;� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Oracle-PHP PL/SQL Problem

    Dear,
    I have this situation:
    Inside PHP I call this statement:
    $usr_stmt = oci_parse($conn, "begin PKG_USERBEHEER_TEST.user_insert(PKG_USERBEHEER_TEST.user_create_type(:usr_id,:usr_naam,:usr_vnaam,:usr_email,:usr_pass,SYSDATE,NULL),:p_exusr_id); end;");
    binding the variables
    oci_bind_by_name($usr_stmt, ':usr_id', $USR_ID);
    oci_bind_by_name($usr_stmt, ':usr_naam', $USR_NAAM);
    oci_bind_by_name($usr_stmt, ':usr_vnaam', $USR_VNAAM);
    oci_bind_by_name($usr_stmt, ':usr_pass', $USR_PASS);
    oci_bind_by_name($usr_stmt, ':usr_email', $USR_EMAIL);
    oci_bind_by_name($usr_stmt, ':p_exusr_id', $EXEC);
    INSIDE MY PACKAGE:
    FUNCTION user_create_type(usr_id users.usr_id%TYPE, usr_naam users.usr_naam%TYPE, usr_vnaam users.usr_vnaam%TYPE, usr_email users.usr_email%TYPE, usr_pass users.usr_pass%TYPE, usr_start_datum users.usr_pass%TYPE, usr_eind_datum users.usr_eind_datum%TYPE) return user_rec is
    v_rec user_rec;
    Begin
    v_rec.usr_id := usr_id;
    v_rec.usr_naam := usr_naam ;
    v_rec.usr_vnaam:=usr_vnaam;
    v_rec.usr_email:=usr_email;
    v_rec.usr_pass :=usr_pass;
    v_rec.usr_start_datum := usr_start_datum;
    v_rec.usr_eind_datum := usr_eind_datum;
    return v_rec;
    end user_create_type;
    PROCEDURE user_insert(r IN OUT user_rec, p_exusr_id IN users.usr_id%TYPE) IS
    BEGIN
    --check if allowed
    IF(NOT checkallowedactions(p_exusr_id, 117)) THEN
    raise_application_error(-20999, 'User is not allowed executing this action');
    END IF;
    --end check if allowed
    SELECT seq_users.nextval
    INTO r.usr_id
    FROM dual;
    SELECT sysdate
    INTO r.usr_start_datum
    FROM dual;
    INSERT
    INTO users(usr_id, usr_naam, usr_vnaam, usr_email, usr_pass, usr_start_datum)
    VALUES(r.usr_id, r.usr_naam, r.usr_vnaam, r.usr_email, cryptit.encrypt(r.usr_pass), r.usr_start_datum);
    END user_insert;
    When I excecute my statement I get this error:
    Warning: oci_execute() [function.oci-execute]: ORA-06550: line 1, column 39: PLS-00363: expression 'PKG_USERBEHEER_TEST.USER_CREATE_TYPE' cannot be used as an assignment target ORA-06550: line 1, column 7: PL/SQL: Statement ignored in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\add_user.php on line 22
    But I need the out parameter, because I need my generated ID (Sequence) for futher use in my script.
    I'm not able to edit the pl/sql script because an other application is using it.
    Somebody can help me?
    Thx
    Davy

    The call to PKG_USERBEHEER_TEST.user_insert needs to pass a single PL/SQL variable as the first argument so that user_insert can return an update record. The OUT declaration of 'r' in user_insert is throwing the error. To that point, the problem is not due to PHP. You would get the same error in SQL*Plus.
    But, because you can't bind a record in PHP, you need to create a new PL/SQL function that calls PKG_USERBEHEER_TEST.user_create_type putting the returned record into a PL/SQL variable, and then calls user_insert. PHP would call the wrapper PL/SQL function.
    -- cj

  • Report SQL problem

    hi all,
    need some help in oracle report 6i, I have a SQL statement like
    SQL> select p.person_id, p.person_name, p.birth_date,max(cg.effective_start_date) "Last Concession",
    add_months(max(effective_start_date),24) "Next Concession"
    from person p, conc_given cg
    where p.person_id = cg.person_id
    group by p.person_id, p.person_name, p.birth_date
    p.person_id p.person_name p.birth_date Last Concession Next concession
    1234 peter scott 01/06/1967 05/07/00 05/07/02
    1489 smith bratt 09/04/1958 07/10/01 07/10/03
    The p.person_id I am selecting in my SQL statement do have some relationship
    with some other non-clients. Its all in relationship table...and person_id is a foreign key in that table..
    I want the results like as follows:
    p.person_id p.person_name p.birth_date relationship.person_id related person_name Last Concession Next concession
    1234 peter scott 01/06/1967 05/07/00 05/07/02
    1584 anita scott 07/09/01 07/09/03
    1897 david scott NULL NULL
    1489 smith bratt 09/04/1958 07/10/01 07/10/03
    1354 sonia bratt 09/06/1998 09/06/2000
    I can attach the related person_ID and his name with the p.person_id but the problem I am having
    I don't know how the relationship_ID and name can appear in the next line and their conc_dates as well...
    pls help
    Thanks

    Hi,
    Please run this sql statement in the SQL session. This way you will get the line number where the problem is happening.
    The error seems to be because the column in the select is not in the group by clause.
    Thanks,
    Sharmila

  • SQL problem with JSP

    In sql statements with JSP. Heres the deal:
    Access database:
    Tablename: EVENT
    FieldName: event_id
    DataType: Number
    I want to compare the event_id to an integer variable called "var" in a WHERE clause in an SQL statement through a JSP.
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = 'var' ";
    It says "Data type mismatch in criteria expression."
    Any Suggestions? I thought this should be straight forward! am i missing something?

    if i am reading correctly "var" is an int variable correct? If this is the case then the following will work;
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = " + Interger.toString(var) ;
    Hope that helps ( and i hope i read your problem correctly)

  • Reports Printing Dupes but not a SQL Problem

    I have a query that is not linked to any other query or group in my Data Model view. I ran the same query in TOAD and the correct results printed, however, when, I put the same query in the Data Model view it prints dupes. I have a repeating frame around the columns so that the entire recordset will print. Has anyone ever seen this before? I do not know what to look at because the SQL is running fine agains the database and there are no links that could cause the data output to have problems. There are multiple frames with separate queries, but they are not above and under this particular group. This group is the only one that is printing dupes. The frames are not overlapping or anything like that.

    Every group can have 3 lines only;
    Length(Detail01:A000001)<=16
    indicate:
    select Length('Detail01:'||'A000001') into d_len_1 from dual;
    d_len_1 must <=16
    Length(Detail02:A0002 A00003)<=22
    indicate:
    select Length('Detail02:'||'A0002'||' '||'A00003') into d_len_2 from dual;
    d_len_2 must <=22
    Length(Detail03:A00004 A00005)<=22
    indicate:
    select Length('Detail03:'||'A00004'||' '||'A00005')<=22 into d_len_3 from dual;
    d_len_3 must <=22
    Every record in this table can be used for one times;

  • Strange SQL problem (order by fieldname@text)

    Hi all,
    I 'm taking a strange problem in Oracle 9i.
    Why does this query work correctly? (look the order by clause)
    SELECT foo1,
    FROM vw_prat_vend1
    WHERE 1=1
    AND (ce_vcod = '30888.03P34')
    AND (TRIM (ce_piva) = '01931450363')
    AND ( ce_dofl IN ('VAR') )
    ORDER BY cd_prat@text
    It seems that Oracle ignores it.
    In the 11g version the same query goes wrong.
    Thank you.

    Indeed, very strange.
    I cannot come up with an explanation
    SQL> Select distinct object_type from user_objects Order by object_type@foofoo desc
    OBJECT_TYPE       
    VIEW              
    TYPE BODY         
    TYPE              
    TRIGGER           
    TABLE             
    SYNONYM           
    SEQUENCE          
    SCHEDULE          
    RULE SET          
    RULE              
    QUEUE             
    PROCEDURE         
    PACKAGE BODY      
    PACKAGE           
    LOB               
    JOB               
    JAVA SOURCE       
    JAVA CLASS        
    INDEX             
    FUNCTION          
    EVALUATION CONTEXT
    DATABASE LINK     
    22 rows selected.
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production   
    1 row selected.

Maybe you are looking for