Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Unanswered: How to make this function in Oracle

    CREATE OR REPLACE FUNCTION f_looking (car.car_ID%TYPE) RETURNS void AS '
    DECLARE
    car ALIAS FOR $1;
    person person.person_ID%TYPE;
    username VARCHAR(20);
    sqlstring TEXT;
    hel pinteger;
    help2 integer;
    lenghtx integer;
    BEGIN
    username:=current_user;
    help:=strpos(kasutajanimi,''_'');
    help:=help+1;
    lenghtx:=length(username);
    help2:=substr(username, help, lenght2);
    person:=help2;
    sqlstring:= ''INSERT INTO Looking VALUES ('' || car || '', '' || person || '');'';
    RAISE NOTICE ''Execstring XSQL_string (%)'', sqlstring;
    EXECUTE sqlstring;
    RETURN;
    END;
    'LANGUAGE 'plpg sql';

  2. #2
    Join Date
    Sep 2003
    Location
    Virginia, USA
    Posts
    246

    Re: How to make this function in Oracle

    Three quick comments:
    1. Don't put single quotes around your PL/SQL blocks. For example, I don't know why you have a single quote after AS and another one after END.
    2. In setting variable SQLSTRING you should use single quotes, not double quotes, and you should not have a semi-colon inside the assignment (unless you are assigning a DDL block with BEGIN/END statements.) For example, change it to read sqlstring:= 'INSERT INTO Looking VALUES (' || car || ', ' || person || ')';
    3. What is the LANGUAGE stuff at the end?
    MarkRem
    Author, Oracle Database 10g: From Nuts to Soup
    http://www.remidata.com/book_nuts2soup.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •