Article View: borland.public.cppbuilder.database.multi-tier
Article #1888Re: HELP! How to run SQL script in C++Builder Program
From: ���������̳
Date: Sat, 02 Jan 1999 00:00
Date: Sat, 02 Jan 1999 00:00
101 lines
3767 bytes
3767 bytes
Hi Robert Doyle:
I will list all my action here, I want if you can poit out what's wrong.
I put Database1 Query1 and Command1 to Form1.
then double click Database1 and set name: ls ,Driver NAME:INTRBASE.
Parameter override here:
SERVER NAME=C:\Program Files\InterBase Corp\InterBase\Isc4.gdb
USER NAME=SYSDBA
OPEN MODE=READ/WRITE
SCHEMA CACHE SIZE=8
LANGDRIVER=
SQLQRYMODE=
SQLPASSTHRU MODE=SHARED AUTOCOMMIT
SCHEMA CACHE TIME=-1
MAX ROWS=-1
BATCH COUNT=200
ENABLE SCHEMA CACHE=FALSE
SCHEMA CACHE DIR=
ENABLE BCD=FALSE
BLOBS TO CACHE=64
BLOB SIZE=32
PASSWORD=masterkey
then set Query1 with DATANAME=ls.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Database1->Connected=true;
Query1->SQL->Clear();
Query1->SQL->Add("declare external function f_IBPassword");
Query1->SQL->Add("cstring(32)");
Query1->SQL->Add("returns");
Query1->SQL->Add("cstring(32)");
Query1->SQL->Add("entry_point 'IBPassword' module_name 'FreeUDFLib.dll';");
Query1->ExecSQL();
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("create exception exc_not_permitted 'Action not
permitted';");
Query1->ExecSQL();
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("create procedure ChangePassword");
Query1->SQL->Add("(user_name varchar(128), passwd varchar(32))");
Query1->SQL->Add("as");
Query1->SQL->Add("begin");
Query1->SQL->Add("if (((USER != 'SYSDBA') and (USER != :user_name)) or");
Query1->SQL->Add("(:user_name is null) or");
Query1->SQL->Add("(:user_name = '') or");
Query1->SQL->Add("(:passwd is null) or");
Query1->SQL->Add("(:passwd = '')) then");
Query1->SQL->Add("exception exc_not_permitted;");
Query1->SQL->Add("update users");
Query1->SQL->Add("set passwd = f_IBPassword(:passwd)");
Query1->SQL->Add("where user_name = UPPER(:user_name);");
Query1->SQL->Add("end");
Query1->Prepare();
Query1->ExecSQL();
Query1->Close();
Database1->Connected=false;
ShowMessage("success");
}
when I run the program and click Command1 , but the third EXECSQL ERROR:
'General SQL error Invalid Command'.
This all. You said "Yes it will",but why I come to the Error.
And I also find Query can't Execute "Set Names ...", "Set term ^" and
"Create Database ...".
Robert Doyle wrote in message <368A0C8A.B9E9D8F0@inprise.com>...
>Yes it will
>
>Robert
>
>winprise wrote:
>
>> Hi nikoly:
>> Thank you for your answer.
>> But I want to run a full SQL Script in BCB.
>> The Script include create table and Store_procedure.
>> I just want to know Can TQUERY suport to run Store_procedure
>> even whole Script language.
>>
>> >Hi winprise.
>> >
>> >First you must create a TQuery.
>> >Next, assign a SQL property of this query a string list withs your SQL
text
>> >Next execute a method ExecSQL of this Query.
>> >Note, what you must disable a table schema cache in your BDE ALIAS.
>> >like SCHEMA CACHE SIZE=0
>> >
>> >for example:
>> >
>> >TQuery *Query = new TQuery(0);
>> >Query->SQL->Add("CREATE TABLE TEST (FIELD1 INTEGER,FIELD2 INTEGER)");
>> >Query->ExecSQL();
>> >delete Query;
>> >
>> >
>
>
>
Technical Details
Message-ID:
<76jurs$3884@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<75dgcp$1dd13@forums.borland.com> <01be2cf5$28657520$75c09ec2@intermec> <765g2d$kif5@forums.borland.com> <368A0C8A.B9E9D8F0@inprise.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcd2b,ae055b32f3111ea9 X-Google-Attributes: gidfcd2b,public From: "���������̳" <xinsoft@163.net> Subject: Re: HELP! How to run SQL script in C++Builder Program Date: 1999/01/02 Message-ID: <76jurs$3884@forums.borland.com> X-Deja-AN: 427876793 References: <75dgcp$1dd13@forums.borland.com> <01be2cf5$28657520$75c09ec2@intermec> <765g2d$kif5@forums.borland.com> <368A0C8A.B9E9D8F0@inprise.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.cppbuilder.database.multi-tier