76 |
|
InputParams, OutputParams, ExecuteSQL: TStrings); |
77 |
|
function GetStatementType(SQL: string; var IsStoredProcedure: boolean): TIBSQLTypes; |
78 |
|
function GetFieldNames(FieldList: TListBox): TStrings; |
79 |
< |
procedure TestSQL(SQL: string); |
79 |
> |
procedure TestSQL(SQL: string; GenerateParamNames: boolean = false); |
80 |
|
end; |
81 |
|
|
82 |
|
implementation |
83 |
|
|
84 |
< |
uses IB, Dialogs; |
84 |
> |
uses IB, Dialogs, IBUtils; |
85 |
|
|
86 |
|
{ TIBSystemTables } |
87 |
|
|
181 |
|
Inc(Count); |
182 |
|
if QuotedStrings then |
183 |
|
WhereClause := WhereClause + Separator + '"' + FGetPrimaryKeys.FieldByName('ColumnName').AsString + |
184 |
< |
'" = ' + Prefix+ FGetPrimaryKeys.FieldByName('ColumnName').AsString |
184 |
> |
'" = ' + Prefix+ AnsiUpperCase(FGetPrimaryKeys.FieldByName('ColumnName').AsString) |
185 |
|
else |
186 |
< |
WhereClause := WhereClause + Separator + FGetPrimaryKeys.FieldByName('ColumnName').AsString + |
187 |
< |
' = ' + Prefix + FGetPrimaryKeys.FieldByName('ColumnName').AsString; |
186 |
> |
WhereClause := WhereClause + Separator + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,FGetPrimaryKeys.FieldByName('ColumnName').AsString) + |
187 |
> |
' = ' + Prefix + AnsiUpperCase(FGetPrimaryKeys.FieldByName('ColumnName').AsString); |
188 |
|
Separator := ' AND A.'; |
189 |
|
FGetPrimaryKeys.Next |
190 |
|
end; |
269 |
|
FGetProcedures := TIBSQL.Create(nil); |
270 |
|
FTestSQL := TIBSQL.Create(nil); |
271 |
|
FTableAndColumnSQL := TIBSQL.Create(nil); |
272 |
+ |
FTableAndColumnSQL.GenerateParamNames := true; {Permissive} |
273 |
|
FGetGeneratorsSQL := TIBSQL.Create(nil); |
274 |
|
FGetProcedureParams := TIBSQL.Create(nil); |
275 |
|
FGetProcedureInfo := TIBSQL.Create(nil); |
531 |
|
if QuotedStrings then |
532 |
|
SelectSQL := SelectSQL + Separator + '"' + FieldNames[I] + '"' |
533 |
|
else |
534 |
< |
SelectSQL := SelectSQL + Separator + FieldNames[I]; |
534 |
> |
SelectSQL := SelectSQL + Separator + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,FieldNames[I]); |
535 |
|
Separator := ', A.'; |
536 |
|
end; |
537 |
|
SelectSQL := SelectSQL + ' From ' + TableName + ' A'; |
558 |
|
if QuotedStrings then |
559 |
|
InsertSQL := InsertSQL + Separator + '"' + FieldNames[I] + '"' |
560 |
|
else |
561 |
< |
InsertSQL := InsertSQL + Separator + FieldNames[I] ; |
561 |
> |
InsertSQL := InsertSQL + Separator + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,FieldNames[I]) ; |
562 |
|
Separator := ', '; |
563 |
|
end; |
564 |
|
InsertSQL := InsertSQL + ')'; |
567 |
|
Separator := ':'; |
568 |
|
for I := 0 to FieldNames.Count - 1 do |
569 |
|
begin |
570 |
< |
InsertSQL := InsertSQL + Separator + FieldNames[I] ; |
570 |
> |
InsertSQL := InsertSQL + Separator + AnsiUpperCase(FieldNames[I]) ; |
571 |
|
Separator := ', :'; |
572 |
|
end; |
573 |
|
InsertSQL := InsertSQL + ')'; |
586 |
|
for I := 0 to FieldNames.Count - 1 do |
587 |
|
begin |
588 |
|
if QuotedStrings then |
589 |
< |
UpdateSQL := UpdateSQL + Separator + '"' + FieldNames[I] + '" = :' + FieldNames[I] |
589 |
> |
UpdateSQL := UpdateSQL + Separator + '"' + FieldNames[I] + '" = :' + AnsiUpperCase(FieldNames[I]) |
590 |
|
else |
591 |
< |
UpdateSQL := UpdateSQL + Separator + FieldNames[I] + ' = :' + FieldNames[I]; |
591 |
> |
UpdateSQL := UpdateSQL + Separator + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,FieldNames[I]) + ' = :' + AnsiUpperCase(FieldNames[I]); |
592 |
|
Separator := ','#$0d#$0a' A.'; |
593 |
|
end; |
594 |
|
SQL.Add(UpdateSQL); |
618 |
|
if QuotedStrings then |
619 |
|
SQL := SQL + Separator + '"' + OutputParams[I] + '"' |
620 |
|
else |
621 |
< |
SQL := SQL + Separator + OutputParams[I]; |
621 |
> |
SQL := SQL + Separator + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,OutputParams[I]); |
622 |
|
Separator := ', '; |
623 |
|
end; |
624 |
|
SQL := SQL + ' From ' + ProcName; |
627 |
|
Separator := '(:'; |
628 |
|
for I := 0 to InputParams.Count - 1 do |
629 |
|
begin |
630 |
< |
SQL := SQL + Separator + InputParams[I]; |
630 |
> |
SQL := SQL + Separator + AnsiUpperCase(InputParams[I]); |
631 |
|
Separator := ', :'; |
632 |
|
end; |
633 |
|
SQL := SQL + ')' |
638 |
|
if QuotedStrings then |
639 |
|
SQL := 'Execute Procedure "' + ProcName + '"' |
640 |
|
else |
641 |
< |
SQL := 'Execute Procedure ' + ProcName; |
641 |
> |
SQL := 'Execute Procedure ' + QuoteIdentifierIfNeeded(FGetFieldNames.Database.SQLDialect,ProcName); |
642 |
|
if InputParams.Count > 0 then |
643 |
|
begin |
644 |
|
Separator := ' :'; |
647 |
|
if QuotedStrings then |
648 |
|
SQL := SQL + Separator + '"' + InputParams[I] + '"' |
649 |
|
else |
650 |
< |
SQL := SQL + Separator + InputParams[I]; |
650 |
> |
SQL := SQL + Separator + AnsiUpperCase(InputParams[I]); |
651 |
|
Separator := ', :'; |
652 |
|
end; |
653 |
|
end |
664 |
|
Exit; |
665 |
|
IsStoredProcedure := false; |
666 |
|
FTestSQL.SQL.Text := SQL; |
667 |
+ |
FTestSQL.GenerateParamNames := true; {permissive} |
668 |
|
try |
669 |
|
FTestSQL.Prepare; |
670 |
|
Result := FTestSQL.SQLType |
703 |
|
end; |
704 |
|
end; |
705 |
|
|
706 |
< |
procedure TIBSystemTables.TestSQL(SQL: string); |
706 |
> |
procedure TIBSystemTables.TestSQL(SQL: string; |
707 |
> |
GenerateParamNames: boolean); |
708 |
|
begin |
709 |
|
if not assigned(FTestSQL.Database) or not FTestSQL.Database.Connected or |
710 |
|
not assigned(FTestSQL.Transaction) then |
712 |
|
Messagedlg('No Database Connected',mtError,[mbOK],0); |
713 |
|
Exit; |
714 |
|
end; |
715 |
+ |
FTestSQL.GenerateParamNames := GenerateParamNames; |
716 |
|
FTestSQL.SQL.Text := SQL; |
717 |
|
try |
718 |
|
FTestSQL.Prepare; |
723 |
|
end; |
724 |
|
|
725 |
|
end. |
726 |
< |
|
726 |
> |
|