Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Embedded SQL Question..... Please help......

Re: Embedded SQL Question..... Please help......

From: <fitzjarrell_at_cox.net>
Date: 10 Oct 2006 10:21:52 -0700
Message-ID: <1160500909.834951.10320@e3g2000cwe.googlegroups.com>

cmgray74_at_gmail.com wrote:
> All,
> I am trying to write a simple function that will allow a user to enter
> a Update query similar to the one below on the command line.
>
> Update person set personName = 'P0' Where personID = :placeHolder;
>
> I have written the following code to try and complete this task but I
> am having difficulty as I am new to Embedded SQL in C++;
>
> void Query::UpdateOption()
> {
>
> EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error:");
>
> EXEC SQL BEGIN DECLARE SECTION;
>
> varchar username[UNAME_LEN]; // VARCHAR is an ORACLE supplied
> struct
> varchar password[PWD_LEN]; // varchar can be in lower case
> also
> varchar sql_statement[1000]; //holds the sql stat being
> constructed..
>
> int inputNumber;
>
> EXEC SQL END DECLARE SECTION;
>
> memset((char*)sql_statement.arr,'\0',1000);
>
> cout<<"Please Enter the Update Query String"<<endl;
> cin.getline((char *)sql_statement.arr,1000,';');
> cout<<endl;
>
> cout<<"Enter User Name "; cin>>username.arr;
> cout<<"Enter Password: "; cin>>password.arr;
>
> username.len = strlen((char *) username.arr);
> password.len = strlen((char *) password.arr);
>
> cout<<"Before Connection "<<(char *)username.arr<<" "<<(char
> *)password.arr<<endl;
>
> // CONNECTS TO DATABASE
> EXEC SQL CONNECT :username IDENTIFIED BY :password;
>
> int theLength = strlen((char*) sql_statement.arr);
> cout<<(char *)sql_statement.arr<<endl;
>
> sql_statement.len = theLength;
> cout<< "...Query is " <<endl<<(char *) sql_statement.arr << endl;
> cout<<endl;
>
> cout<<"Please Enter Number ";
> cin>>inputNumber;
> cout<<endl;
>
> EXEC SQL PREPARE q FROM :sql_statement;
>
> EXEC SQL WHENEVER NOT FOUND DO break;
>
> EXEC SQL EXECUTE q using :inputNumber;
>
> //EXEC SQL COMMIT work release;
>
> }
>
> Thanks for any help,
> Chris

You'll need to better explain your 'difficulty'.

David Fitzjarrell Received on Tue Oct 10 2006 - 12:21:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US