🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
6 messages
6 total messages Started by winprise Sat, 19 Dec 1998 00:00
HELP! How to run SQL script in C++Builder Program
#1877
Author: winprise
Date: Sat, 19 Dec 1998 00:00
3 lines
585 bytes
Hi! how do you do
   How can I run a InterBase SQL script like
"CreateTable.sql" in C++Builder Program.
Re: HELP! How to run SQL script in C++Builder Program
#1880
Author: nikoly
Date: Mon, 21 Dec 1998 00:00
29 lines
1147 bytes

winprise <winprise@163.net> �������� � ������
<75dgcp$1dd13@forums.borland.com>...
> Hi! how do you do
>    How can I run a InterBase SQL script like
> "CreateTable.sql" in C++Builder Program.
> 
> 
> 
> 
> 
> 
> 

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;
Re: HELP! How to run SQL script in C++Builder Program
#1884
Author: winprise
Date: Mon, 28 Dec 1998 00:00
25 lines
1240 bytes
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;
>
>
Re: HELP! How to run SQL script in C++Builder Program
#1887
Author: Robert Doyle
Date: Wed, 30 Dec 1998 00:00
29 lines
1402 bytes
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;
> >
> >
Re: HELP! How to run SQL script in C++Builder Program
#1888
Author: ���������̳
Date: Sat, 02 Jan 1999 00:00
101 lines
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;
>> >
>> >
>
>
>
Re: HELP! How to run SQL script in C++Builder Program
#1889
Author: winprise
Date: Wed, 06 Jan 1999 00:00
5 lines
675 bytes
Hi nikoly:
   I know what's wrong.then I add :
   Query->ParamCheck=false
  to my program.
   Now it run well.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads