ora_parse error - whats wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cricketunes@yahoo.com

    ora_parse error - whats wrong?

    Hi folks,
    this one's had me stumped!

    $conn=ora_logon ("cricketunes@p ickles","j8j3kf ");
    if ($conn != TRUE)
    die("Unable to connect to oracle, exiting...\n");

    $cursor = ora_open($conn) ;
    if ($cursor != TRUE)
    die("Unable to open a cursor, exiting...\n");

    $result = ora_parse($curs or,$query);
    if ($result != TRUE)
    die("Unable to parse SQL block<BR>");

    Warning: Ora_Parse failed (ORA-00911: invalid character -- while
    processing OCI function OPARSE) in add.php on line 33

    What is wrong with my ora_parse function call??

    Puzzled,
    Benny

  • cricketunes@yahoo.com

    #2
    Re: ora_parse error - whats wrong?

    This is what the query has:
    insert into movie
    values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');

    Comment

    • Erwin Moller

      #3
      Re: ora_parse error - whats wrong?

      cricketunes@yah oo.com wrote:
      [color=blue]
      > This is what the query has:
      > insert into movie
      > values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');[/color]

      Try naming the columns if you use VALUES keyword.
      eg:

      INSERT INTO tbluser (userid, username) VALUES (1,'cricket');

      Regards,
      Erwin Moller

      Comment

      • cricketunes@yahoo.com

        #4
        Re: ora_parse error - whats wrong?


        Erwin Moller wrote:[color=blue]
        > cricketunes@yah oo.com wrote:
        >[color=green]
        > > This is what the query has:
        > > insert into movie
        > > values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');[/color]
        >
        > Try naming the columns if you use VALUES keyword.
        > eg:
        >
        > INSERT INTO tbluser (userid, username) VALUES (1,'cricket');
        >[/color]

        This is what happens:
        1. A simple SELECT query works.
        2. INSERT into movies values('a','a', 'a','a',55,'a', 'a');
        This doesnt work.

        Whats the prob with INSERT queries? They're just not working with
        ora_parse.

        :(

        Comment

        • Malcolm Dew-Jones

          #5
          Re: ora_parse error - whats wrong?

          cricketunes@yah oo.com wrote:

          : Erwin Moller wrote:
          : > cricketunes@yah oo.com wrote:
          : >
          : > > This is what the query has:
          : > > insert into movie
          : > > values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');
          : >
          : > Try naming the columns if you use VALUES keyword.
          : > eg:
          : >
          : > INSERT INTO tbluser (userid, username) VALUES (1,'cricket');
          : >

          : This is what happens:
          : 1. A simple SELECT query works.
          : 2. INSERT into movies values('a','a', 'a','a',55,'a', 'a');
          : This doesnt work.

          : Whats the prob with INSERT queries? They're just not working with
          : ora_parse.

          Does that insert statement work as-is from sqlplus?




          --

          This space not for rent.

          Comment

          • Andy Hassall

            #6
            Re: ora_parse error - whats wrong?

            On 14 Apr 2005 03:58:35 -0700, cricketunes@yah oo.com wrote:
            [color=blue]
            >Hi folks,
            >this one's had me stumped!
            >
            >$conn=ora_logo n("cricketunes@ pickles","j8j3k f");[/color]

            Don't use ora_logon, that's for Oracle 7, which is long dead. Use the OCI
            extension, i.e. OCILogon (PHP 4) or oci_logon (PHP 5 - OCILogon still works
            there though as an alias).
            [color=blue]
            >if ($conn != TRUE)
            >die("Unable to connect to oracle, exiting...\n");
            >
            >$cursor = ora_open($conn) ;
            >if ($cursor != TRUE)
            >die("Unable to open a cursor, exiting...\n");
            >
            >$result = ora_parse($curs or,$query);
            >if ($result != TRUE)
            >die("Unable to parse SQL block<BR>");
            >
            >Warning: Ora_Parse failed (ORA-00911: invalid character -- while
            >processing OCI function OPARSE) in add.php on line 33
            >
            >What is wrong with my ora_parse function call??[/color]

            And later you post:
            [color=blue]
            >This is what the query has:
            >insert into movie
            >values('M081', 'saefa','VHS',' sd',44,'Comedy' ,'sdfsf');[/color]

            You do not put a semicolon at the end of statement in calls to OCI. That's
            only for PL/SQL or when you're in SQL*Plus.

            The semicolon will result in ORA-00911.

            --
            Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
            <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

            Comment

            • cricketunes@yahoo.com

              #7
              Re: ora_parse error - whats wrong?

              Yep Malcolm. I manually type the same thing from sql and it works:

              SQL> describe movie;
              Name Null? Type
              ----------------------------------------- -------- --------------
              MOVIEID NOT NULL VARCHAR2(4)
              TITLE NOT NULL VARCHAR2(60)
              TYPE NOT NULL VARCHAR2(3)
              DIRECTOR NOT NULL VARCHAR2(40)
              YEAR NOT NULL NUMBER
              CATEGORY NOT NULL VARCHAR2(12)
              DESCRIPTION VARCHAR2(50)

              Manual Insert:
              ----------------------------------
              SQL> INSERT into movie values('a','a', 'a','a',55,'a', 'a');
              1 row created.

              PHP code segment:
              -------------------------------------------------------------------------------------
              $query="insert into movie values('a','a', 'a','a',55,'a', 'a');";
              print $query;

              Output:
              --------------------------------------------------------------------
              insert into movie values('a','a', 'a','a',55,'a', 'a');
              Warning: Ora_Parse failed (ORA-00911: invalid character -- while
              processing OCI function OPARSE) in
              G:\cpsc462\stud ents\prabhur\ad dmov.php on line 35
              Unable to parse SQL block


              Lines 35-37:
              -----------------
              $result = ora_parse($curs or,$query);
              if ($result != TRUE)
              die("Unable to parse SQL block<BR>");

              Comment

              • cricketunes@yahoo.com

                #8
                Re: ora_parse error - whats wrong?

                Yep Malcolm. I manually type the same thing from sql and it works:

                SQL> describe movie;
                Name Null? Type
                ----------------------------------------- -------- --------------
                MOVIEID NOT NULL VARCHAR2(4)
                TITLE NOT NULL VARCHAR2(60)
                TYPE NOT NULL VARCHAR2(3)
                DIRECTOR NOT NULL VARCHAR2(40)
                YEAR NOT NULL NUMBER
                CATEGORY NOT NULL VARCHAR2(12)
                DESCRIPTION VARCHAR2(50)

                Manual Insert:
                ----------------------------------
                SQL> INSERT into movie values('a','a', 'a','a',55,'a', 'a');
                1 row created.

                PHP code segment:
                -------------------------------------------------------------------------------------
                $query="insert into movie values('a','a', 'a','a',55,'a', 'a');";
                print $query;

                Output:
                --------------------------------------------------------------------
                insert into movie values('a','a', 'a','a',55,'a', 'a');
                Warning: Ora_Parse failed (ORA-00911: invalid character -- while
                processing OCI function OPARSE) in
                G:\cpsc462\stud ents\prabhur\ad dmov.php on line 35
                Unable to parse SQL block


                Lines 35-37:
                -----------------
                $result = ora_parse($curs or,$query);
                if ($result != TRUE)
                die("Unable to parse SQL block<BR>");

                Comment

                • Erwin Moller

                  #9
                  Re: ora_parse error - whats wrong?

                  cricketunes@yah oo.com wrote:
                  [color=blue]
                  >
                  > Erwin Moller wrote:[color=green]
                  >> cricketunes@yah oo.com wrote:
                  >>[color=darkred]
                  >> > This is what the query has:
                  >> > insert into movie
                  >> > values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');[/color]
                  >>
                  >> Try naming the columns if you use VALUES keyword.
                  >> eg:
                  >>
                  >> INSERT INTO tbluser (userid, username) VALUES (1,'cricket');[/color][/color]

                  Well, did you actually TRY my suggestion cricket?

                  Your SQL is just not valid.

                  The fact that SQL+ will correct your faulty SQL-statement, made you believe
                  it was correct.

                  insert into movie
                  (columnname1,co lumnname2,colum nname3,columnna me4,columnname5 ,columnname6,co lumnname7)
                  values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');

                  Replace the columnname1 - 7 by real columnnames.
                  [color=blue][color=green]
                  >>[/color]
                  >
                  > This is what happens:
                  > 1. A simple SELECT query works.
                  > 2. INSERT into movies values('a','a', 'a','a',55,'a', 'a');
                  > This doesnt work.
                  >
                  > Whats the prob with INSERT queries? They're just not working with
                  > ora_parse.
                  >
                  > :([/color]

                  Comment

                  • Andy Hassall

                    #10
                    Re: ora_parse error - whats wrong?

                    On Fri, 15 Apr 2005 09:58:51 +0200, Erwin Moller
                    <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
                    [color=blue][color=green][color=darkred]
                    >>> > This is what the query has:
                    >>> > insert into movie
                    >>> > values('M081',' saefa','VHS','s d',44,'Comedy', 'sdfsf');
                    >>>
                    >>> Try naming the columns if you use VALUES keyword.
                    >>> eg:
                    >>>
                    >>> INSERT INTO tbluser (userid, username) VALUES (1,'cricket');[/color][/color]
                    >
                    >Well, did you actually TRY my suggestion cricket?
                    >
                    >Your SQL is just not valid.[/color]

                    Is too. If you don't name the columns, then "all columns" is assumed. It
                    wouldn't raise ORA-00911, that's likely caused by the semicolon as I said
                    earlier.

                    --
                    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
                    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

                    Comment

                    Working...